Skip to content

Commit

Permalink
improve autopilot logging when it starts up (#27464)
Browse files Browse the repository at this point in the history
* improve autopilot logging when it starts up

* add changelog
  • Loading branch information
raskchanky authored Jun 12, 2024
1 parent 663c9a3 commit f33f1b1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
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

0 comments on commit f33f1b1

Please sign in to comment.