Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Hiltunen <shiltunen@gitlab.com>2020-07-14 17:36:59 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2020-07-17 16:30:46 +0300
commit7bbc7cc429d2dca040328570f676e2e88b45ccd7 (patch)
tree7c1d00519d26ece0eac008e99cb961613cf50595 /internal/praefect/config
parentfdd1fe70085c1a20b10553680d88a967a4cfbfae (diff)
repository state tracking stores
Adds an in-memory and a Postgres implemenation of repository state tracking stores. The two tables added are: 1. `repositories` which contains the expected state of repositories in the virtual storage. 2. `storage_repositories` which contains the state of the repositories on the physical storages. Cross-referencing these two makes it easier to identify outdated repositories. This commit implements only the stores without hooking them up to the rest of the code.
Diffstat (limited to 'internal/praefect/config')
-rw-r--r--internal/praefect/config/config.go15
-rw-r--r--internal/praefect/config/config_test.go12
2 files changed, 27 insertions, 0 deletions
diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go
index 31b1b4d25..4cd10154f 100644
--- a/internal/praefect/config/config.go
+++ b/internal/praefect/config/config.go
@@ -172,6 +172,21 @@ func (c *Config) VirtualStorageNames() []string {
return names
}
+// StorageNames returns storage names by virtual storage.
+func (c *Config) StorageNames() map[string][]string {
+ storages := make(map[string][]string, len(c.VirtualStorages))
+ for _, vs := range c.VirtualStorages {
+ nodes := make([]string, len(vs.Nodes))
+ for i, n := range vs.Nodes {
+ nodes[i] = n.Storage
+ }
+
+ storages[vs.Name] = nodes
+ }
+
+ return storages
+}
+
// DB holds Postgres client configuration data.
type DB struct {
Host string `toml:"host"`
diff --git a/internal/praefect/config/config_test.go b/internal/praefect/config/config_test.go
index 1ffde42ee..51c2d254c 100644
--- a/internal/praefect/config/config_test.go
+++ b/internal/praefect/config/config_test.go
@@ -336,6 +336,18 @@ func TestVirtualStorageNames(t *testing.T) {
require.Equal(t, []string{"praefect-1", "praefect-2"}, conf.VirtualStorageNames())
}
+func TestStorageNames(t *testing.T) {
+ conf := Config{
+ VirtualStorages: []*VirtualStorage{
+ {Name: "virtual-storage-1", Nodes: []*Node{{Storage: "gitaly-1"}, {Storage: "gitaly-2"}}},
+ {Name: "virtual-storage-2", Nodes: []*Node{{Storage: "gitaly-3"}, {Storage: "gitaly-4"}}},
+ }}
+ require.Equal(t, map[string][]string{
+ "virtual-storage-1": {"gitaly-1", "gitaly-2"},
+ "virtual-storage-2": {"gitaly-3", "gitaly-4"},
+ }, conf.StorageNames())
+}
+
func TestToPQString(t *testing.T) {
testCases := []struct {
desc string