From 9ebc6a1a23b8f83e8d4e5c0a435ab03792ba98a2 Mon Sep 17 00:00:00 2001 From: Dan Bond Date: Wed, 10 May 2023 16:27:46 +0100 Subject: [PATCH] follow instructions for adding new config Signed-off-by: Dan Bond --- agent/agent.go | 2 ++ agent/config/runtime_test.go | 3 ++- agent/config/testdata/TestRuntimeConfig_Sanitize.golden | 4 ++-- agent/config/testdata/full-config.hcl | 1 + agent/config/testdata/full-config.json | 1 + agent/consul/config.go | 4 ++++ 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 8851c7ac7d3c..f37dfbd5419c 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -1529,6 +1529,8 @@ func newConsulConfig(runtimeCfg *config.RuntimeConfig, logger hclog.Logger) (*co cfg.Reporting.License.Enabled = runtimeCfg.Reporting.License.Enabled + cfg.ServerRejoinAgeMax = runtimeCfg.ServerRejoinAgeMax + enterpriseConsulConfig(cfg, runtimeCfg) return cfg, nil diff --git a/agent/config/runtime_test.go b/agent/config/runtime_test.go index 1325a3280378..a290adac04f6 100644 --- a/agent/config/runtime_test.go +++ b/agent/config/runtime_test.go @@ -6418,6 +6418,7 @@ func TestLoad_FullConfig(t *testing.T) { SerfPortWAN: 8302, ServerMode: true, ServerName: "Oerr9n1G", + ServerRejoinAgeMax: 604800 * time.Second, ServerPort: 3757, Services: []*structs.ServiceDefinition{ { @@ -7163,7 +7164,7 @@ func TestRuntimeConfig_Sanitize(t *testing.T) { }, }, Locality: &Locality{Region: strPtr("us-west-1"), Zone: strPtr("us-west-1a")}, - ServerRejoinAgeMax: time.Duration(168 * time.Hour), + ServerRejoinAgeMax: 168 * time.Hour, } b, err := json.MarshalIndent(rt.Sanitized(), "", " ") diff --git a/agent/config/testdata/TestRuntimeConfig_Sanitize.golden b/agent/config/testdata/TestRuntimeConfig_Sanitize.golden index 0aee0c28987f..c17636eef730 100644 --- a/agent/config/testdata/TestRuntimeConfig_Sanitize.golden +++ b/agent/config/testdata/TestRuntimeConfig_Sanitize.golden @@ -332,7 +332,7 @@ "ServerMode": false, "ServerName": "", "ServerPort": 0, - "ServerRejoinAgeMax": "168h0m0s", + "ServerRejoinAgeMax": "168h0m0s", "Services": [ { "Address": "", @@ -510,4 +510,4 @@ "VersionPrerelease": "", "Watches": [], "XDSUpdateRateLimit": 0 -} +} \ No newline at end of file diff --git a/agent/config/testdata/full-config.hcl b/agent/config/testdata/full-config.hcl index 718c879b2974..c29c334b9504 100644 --- a/agent/config/testdata/full-config.hcl +++ b/agent/config/testdata/full-config.hcl @@ -394,6 +394,7 @@ serf_lan = "99.43.63.15" serf_wan = "67.88.33.19" server = true server_name = "Oerr9n1G" +server_rejoin_age_max = "604800s" service = { id = "dLOXpSCI" name = "o1ynPkp0" diff --git a/agent/config/testdata/full-config.json b/agent/config/testdata/full-config.json index f98bfe4dab2b..7640394a4fa0 100644 --- a/agent/config/testdata/full-config.json +++ b/agent/config/testdata/full-config.json @@ -453,6 +453,7 @@ "serf_wan": "67.88.33.19", "server": true, "server_name": "Oerr9n1G", + "server_rejoin_age_max": "604800s", "service": { "id": "dLOXpSCI", "name": "o1ynPkp0", diff --git a/agent/consul/config.go b/agent/consul/config.go index e35fceb5560d..c28896a54419 100644 --- a/agent/consul/config.go +++ b/agent/consul/config.go @@ -447,6 +447,10 @@ type Config struct { // Embedded Consul Enterprise specific configuration *EnterpriseConfig + + // ServerRejoinAgeMax is used to specify the duration of time a server + // is allowed to be down/offline before a startup operation is refused. + ServerRejoinAgeMax time.Duration } func (c *Config) InPrimaryDatacenter() bool {