diff options
author | John Cai <jcai@gitlab.com> | 2020-04-30 00:50:05 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2020-04-30 00:50:05 +0300 |
commit | 93d4e5d10da54445aad2bc41037a127ca91a9177 (patch) | |
tree | 0a78ac0cdf361019b86fcb0ec0897a9fe3290b08 | |
parent | 195bd095213b3619bb2825b6af282e3a29b60e89 (diff) |
Revert "Merge branch 'jc-remove-virtual-storage-name' into 'master'"revert-195bd0
This reverts commit 195bd095213b3619bb2825b6af282e3a29b60e89, reversing
changes made to bc7bbe6d7b583d1d3922fab91fb6d8d17ef0a34b.
-rw-r--r-- | internal/praefect/config/config.go | 22 | ||||
-rw-r--r-- | internal/praefect/config/config_test.go | 35 | ||||
-rw-r--r-- | internal/praefect/config/testdata/single-virtual-storage.config.toml | 25 |
3 files changed, 79 insertions, 3 deletions
diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go index 4d948f699..1b01b33b2 100644 --- a/internal/praefect/config/config.go +++ b/internal/praefect/config/config.go @@ -21,9 +21,12 @@ type Failover struct { // Config is a container for everything found in the TOML config file type Config struct { - ListenAddr string `toml:"listen_addr"` - SocketPath string `toml:"socket_path"` - VirtualStorages []*VirtualStorage `toml:"virtual_storage"` + ListenAddr string `toml:"listen_addr"` + SocketPath string `toml:"socket_path"` + VirtualStorages []*VirtualStorage `toml:"virtual_storage"` + //TODO: Remove VirtualStorageName and Nodes once omnibus and gdk are updated with support for + // VirtualStorages + VirtualStorageName string `toml:"virtual_storage_name"` Nodes []*models.Node `toml:"node"` Logging log.Config `toml:"logging"` Sentry sentry.Config `toml:"sentry"` @@ -54,6 +57,19 @@ func FromFile(filePath string) (Config, error) { _, err = toml.DecodeReader(cfgFile, config) + // TODO: Remove this after the virtual storages change is merged in omnibus + // and gdk. This is for backwards compatibility purposes only + if len(config.VirtualStorages) == 0 && config.VirtualStorageName != "" && len(config.Nodes) > 0 { + config.VirtualStorages = []*VirtualStorage{ + &VirtualStorage{ + Name: config.VirtualStorageName, + Nodes: config.Nodes, + }, + } + config.VirtualStorageName = "" + config.Nodes = nil + } + // TODO: Remove this after failover_enabled has moved under a separate failover section. This is for // backwards compatibility only if config.FailoverEnabled { diff --git a/internal/praefect/config/config_test.go b/internal/praefect/config/config_test.go index eed4abe3b..4a01db1a4 100644 --- a/internal/praefect/config/config_test.go +++ b/internal/praefect/config/config_test.go @@ -182,6 +182,41 @@ func TestConfigParsing(t *testing.T) { PostgresQueueEnabled: true, }, }, + //TODO: Remove this test, as well as the fixture in testdata/single-virtual-storage.config.toml + // once omnibus and gdk are updated with support for VirtualStorages + { + filePath: "testdata/single-virtual-storage.config.toml", + expected: Config{ + Logging: log.Config{ + Level: "info", + Format: "json", + }, + Sentry: sentry.Config{ + DSN: "abcd123", + Environment: "production", + }, + VirtualStorages: []*VirtualStorage{ + &VirtualStorage{ + Name: "praefect", + Nodes: []*models.Node{ + &models.Node{ + Address: "tcp://gitaly-internal-1.example.com", + Storage: "praefect-internal-1", + DefaultPrimary: true, + }, + { + Address: "tcp://gitaly-internal-2.example.com", + Storage: "praefect-internal-2", + }, + { + Address: "tcp://gitaly-internal-3.example.com", + Storage: "praefect-internal-3", + }, + }, + }, + }, + }, + }, } for _, tc := range testCases { diff --git a/internal/praefect/config/testdata/single-virtual-storage.config.toml b/internal/praefect/config/testdata/single-virtual-storage.config.toml new file mode 100644 index 000000000..e98381875 --- /dev/null +++ b/internal/praefect/config/testdata/single-virtual-storage.config.toml @@ -0,0 +1,25 @@ +listen_addr = "" +socket_path = "" +prometheus_listen_addr = "" +virtual_storage_name = "praefect" + +[logging] + format = "json" + level = "info" + +[sentry] + sentry_environment = "production" + sentry_dsn = "abcd123" + +[[node]] + address = "tcp://gitaly-internal-1.example.com" + storage = "praefect-internal-1" + primary = true + +[[node]] + address = "tcp://gitaly-internal-2.example.com" + storage = "praefect-internal-2" + +[[node]] + address = "tcp://gitaly-internal-3.example.com" + storage = "praefect-internal-3" |