diff --git a/agent/agent.go b/agent/agent.go index ba95be356936..73906f853fcc 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -630,7 +630,7 @@ func (a *Agent) Start(ctx context.Context) error { if err := a.checkServerLastSeen(consul.ReadServerMetadata); err != nil { deadline := time.Now().Add(time.Minute) for time.Now().Before(deadline) { - a.logger.Error("startup error: %s", err) + a.logger.Error("startup error", "error", err) time.Sleep(10 * time.Second) } return err diff --git a/agent/config/default.go b/agent/config/default.go index 4c88c2ac3d86..3af8d0867d4c 100644 --- a/agent/config/default.go +++ b/agent/config/default.go @@ -58,6 +58,7 @@ func DefaultSource() Source { segment_limit = 64 server = false + server_rejoin_age_max = "168h" syslog_facility = "LOCAL0" tls = { diff --git a/agent/consul/config.go b/agent/consul/config.go index c28896a54419..eef4bc4376f4 100644 --- a/agent/consul/config.go +++ b/agent/consul/config.go @@ -578,6 +578,8 @@ func DefaultConfig() *Config { PeeringTestAllowPeerRegistrations: false, EnterpriseConfig: DefaultEnterpriseConfig(), + + ServerRejoinAgeMax: 24 * 7 * time.Hour, } // Increase our reap interval to 3 days instead of 24h. diff --git a/agent/consul/server_metadata_test.go b/agent/consul/server_metadata_test.go index 2abe01c13d0a..d091bfdf3630 100644 --- a/agent/consul/server_metadata_test.go +++ b/agent/consul/server_metadata_test.go @@ -28,23 +28,23 @@ func TestServerMetadata(t *testing.T) { now := time.Now() t.Run("TestIsLastSeenStaleTrue", func(t *testing.T) { - // Create a server that is 24 hours old. + // Create a server that is 48 hours old. md := &ServerMetadata{ - LastSeenUnix: now.Add(-24 * time.Hour).Unix(), + LastSeenUnix: now.Add(-48 * time.Hour).Unix(), } - ok := md.IsLastSeenStale(1 * time.Hour) - assert.True(t, ok) + stale := md.IsLastSeenStale(24 * time.Hour) + assert.True(t, stale) }) t.Run("TestIsLastSeenStaleFalse", func(t *testing.T) { - // Create a server that is 24 hours old. + // Create a server that is 1 hour old. md := &ServerMetadata{ LastSeenUnix: now.Add(-1 * time.Hour).Unix(), } - ok := md.IsLastSeenStale(24 * time.Hour) - assert.False(t, ok) + stale := md.IsLastSeenStale(24 * time.Hour) + assert.False(t, stale) }) }