diff --git a/changelog/27464.txt b/changelog/27464.txt new file mode 100644 index 000000000000..ff9d9f508bc7 --- /dev/null +++ b/changelog/27464.txt @@ -0,0 +1,3 @@ +```release-note:improvement +storage/raft: Improve autopilot logging on startup to show config values clearly and avoid spurious logs +``` diff --git a/physical/raft/raft_autopilot.go b/physical/raft/raft_autopilot.go index fd65ccbf2e2f..d6f88898094c 100644 --- a/physical/raft/raft_autopilot.go +++ b/physical/raft/raft_autopilot.go @@ -89,6 +89,27 @@ type AutopilotConfig struct { UpgradeVersionTag string `mapstructure:"upgrade_version_tag"` } +func (ac *AutopilotConfig) String() string { + s := "CleanupDeadServers:%t " + + "LastContactThreshold:%s " + + "DeadServerLastContactThreshold:%s " + + "MaxTrailingLogs:%d " + + "MinQuorum:%d " + + "ServerStabilizationTime:%s " + + "DisableUpgradeMigration:%t " + + "RedundancyZoneTag:%s " + + "UpgradeVersionTag:%s" + return fmt.Sprintf(s, ac.CleanupDeadServers, + ac.LastContactThreshold, + ac.DeadServerLastContactThreshold, + ac.MaxTrailingLogs, + ac.MinQuorum, + ac.ServerStabilizationTime, + ac.DisableUpgradeMigration, + ac.RedundancyZoneTag, + ac.UpgradeVersionTag) +} + // Merge combines the supplied config with the receiver. Supplied ones take // priority. func (to *AutopilotConfig) Merge(from *AutopilotConfig) { @@ -832,6 +853,8 @@ func (b *RaftBackend) SetupAutopilot(ctx context.Context, storageConfig *Autopil // Merge the setting provided over the API b.autopilotConfig.Merge(storageConfig) + infoArgs := []interface{}{"config", b.autopilotConfig} + // Create the autopilot instance options := []autopilot.Option{ autopilot.WithLogger(b.logger), @@ -839,17 +862,18 @@ func (b *RaftBackend) SetupAutopilot(ctx context.Context, storageConfig *Autopil } if b.autopilotReconcileInterval != 0 { options = append(options, autopilot.WithReconcileInterval(b.autopilotReconcileInterval)) + infoArgs = append(infoArgs, []interface{}{"reconcile_interval", b.autopilotReconcileInterval}...) } if b.autopilotUpdateInterval != 0 { options = append(options, autopilot.WithUpdateInterval(b.autopilotUpdateInterval)) + infoArgs = append(infoArgs, []interface{}{"update_interval", b.autopilotUpdateInterval}...) } b.autopilot = autopilot.New(b.raft, NewDelegate(b), options...) b.followerStates = followerStates b.followerHeartbeatTicker = time.NewTicker(1 * time.Second) - b.l.Unlock() - b.logger.Info("starting autopilot", "config", b.autopilotConfig, "reconcile_interval", b.autopilotReconcileInterval) + b.logger.Info("starting autopilot", infoArgs...) b.autopilot.Start(ctx) go b.startFollowerHeartbeatTracker()