Skip to content

stagger k3s startup using persisted control-plane rank#5819

Merged
rene merged 1 commit intolf-edge:masterfrom
naiming-zededa:naiming-rank-node-startup
Apr 28, 2026
Merged

stagger k3s startup using persisted control-plane rank#5819
rene merged 1 commit intolf-edge:masterfrom
naiming-zededa:naiming-rank-node-startup

Conversation

@naiming-zededa
Copy link
Copy Markdown
Contributor

Description

  • When all cluster nodes power-on simultaneously, concurrent etcd joins can fail due to authentication races. This patch introduces a rank-based startup delay to serialize k3s restarts across nodes.
  • save_cluster_startup_rank runs each main loop iteration and writes this node's 0-based position (sorted by InternalIP) among control-plane nodes to /var/lib/cluster-startup-rank.
  • On the next boot, staggered_cluster_startup_delay reads the rank and sleeps rank * 25 seconds before k3s starts

PR dependencies

How to test and validate this PR

config an edge-node cluster w/ 3 nodes, and power all the nodes off and on
at the same time, and monitor each node will join the cluster in a deterministic
way, from the lowest to highest ip addresses.

Changelog notes

stagger k3s startup using persisted control-plane rank

PR Backports

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR

For backport PRs (remove it if it's not a backport):

  • I've added a reference link to the original PR
  • PR's title follows the template

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

@naiming-zededa naiming-zededa force-pushed the naiming-rank-node-startup branch 2 times, most recently from cc83c87 to d8d78d6 Compare April 17, 2026 05:03
@eriknordmark eriknordmark requested a review from rucoder April 17, 2026 07:11
Copy link
Copy Markdown
Contributor

@andrewd-zededa andrewd-zededa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small request for live debugging, otherwise LGTM

Comment thread pkg/kube/cluster-init.sh Outdated
Comment on lines +631 to +632
sleep "$delay"
logmsg "staggered_cluster_startup_delay: delay complete"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be swapped? My thinking is after the day we're starting k3s and no longer are reviewing this log or cluster-init.sh to see why k3s isn't running. With the logmsg before the sleep a quick check in k3s-install.log on a live system becomes "ok check back in a moment"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. updated.

- When all cluster nodes power-on simultaneously, concurrent etcd joins
  can fail due to authentication races.  This patch introduces a
  rank-based startup delay to serialize k3s restarts across nodes.
- save_cluster_startup_rank runs each main loop iteration and writes
  this node's 0-based position (sorted by InternalIP) among
  control-plane nodes to /var/lib/cluster-startup-rank.
- On the next boot, staggered_cluster_startup_delay reads the rank and
  sleeps rank * 25 seconds before k3s starts

Signed-off-by: naiming-zededa <naiming@zededa.com>
@naiming-zededa naiming-zededa force-pushed the naiming-rank-node-startup branch from d8d78d6 to 57fd0e7 Compare April 24, 2026 17:55
@github-actions github-actions Bot requested a review from andrewd-zededa April 24, 2026 17:55
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.03%. Comparing base (2281599) to head (57fd0e7).
⚠️ Report is 610 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5819      +/-   ##
==========================================
- Coverage   19.52%   17.03%   -2.50%     
==========================================
  Files          19      477     +458     
  Lines        3021    85762   +82741     
==========================================
+ Hits          590    14609   +14019     
- Misses       2310    69644   +67334     
- Partials      121     1509    +1388     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@zedi-pramodh zedi-pramodh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rene rene merged commit be1537e into lf-edge:master Apr 28, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants