Skip to content

Commit

Permalink
agent: fix error message
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Bond <danbond@protonmail.com>
  • Loading branch information
loshz committed May 15, 2023
1 parent 5c74255 commit bd54fa0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions agent/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func DefaultSource() Source {
segment_limit = 64
server = false
server_rejoin_age_max = "168h"
syslog_facility = "LOCAL0"
tls = {
Expand Down
2 changes: 2 additions & 0 deletions agent/consul/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions agent/consul/server_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down

0 comments on commit bd54fa0

Please sign in to comment.