Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve autopilot logging when it starts up #27464

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/27464.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
storage/raft: Improve autopilot logging on startup to show config values clearly and avoid spurious logs
```
28 changes: 26 additions & 2 deletions physical/raft/raft_autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -832,24 +853,27 @@ 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),
autopilot.WithPromoter(b.autopilotPromoter()),
}
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()
Expand Down
Loading