Repository navigation
fix: upgrade stopped workers when --force given, not rejoin them - #1270
Merged
kke merged 1 commit intoNov 16, 2026
Merged
Conversation
There was a problem hiding this comment.
๐ข Approval recommended
No active review issues remain for the change to upgrade stopped workers with outdated binaries when --force is used.
No open issues ๐
What changed in this PR
Updates k0sctlโs apply flow so stopped workers with outdated binaries follow the upgrade path when --force is used, rather than being treated as fresh joins. This addresses the stopped-node upgrade scenario in #1118.
Changes:
- Adds a stopped-service helper that marks workers for upgrade using the existing version check.
- Mentions
--forcein the stopped-service error while preserving existing behavior for controllers and up-to-date workers. - Adds four unit-test cases covering forced and non-forced handling.
| File | Description |
|---|---|
phase/โgather_k0s_facts.go |
Routes stopped-service handling through the new helper and marks outdated workers for upgrade. |
phase/โgather_k0s_facts_test.go |
Tests the error guidance and upgrade decisions for stopped workers and controllers. |
Review effort: Balanced
When k0s is installed as a service but not running, the error now says that --force can be used to proceed. With --force, a stopped worker whose installed k0s binary differs from the target version is marked for upgrade, so it goes through UpgradeWorkers instead of being treated as a fresh join by InstallWorkers, whose cleanup can reset the host. Fixes k0sproject#1118 Signed-off-by: Ahmed Laban <79754427+amlaban65@users.noreply.github.com>
kke
force-pushed
the
upgrade-stopped-workers-with-force
branch
from
November 16, 2026 11:36
b60ad12 to
0bbca01
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1118
This follows the two steps kke outlined in the issue.
Problem
If k0s is installed as a service on a host but isn't running,
GatherK0sFactsstops the apply with:--forcegets past this check, but the message doesn't mention it. Even with--force, the host keepsK0sRunningVersion == nilandNeedsUpgrade == false. SoUpgradeWorkersskips it andInstallWorkerstreats it as a fresh join: it creates a new token and reinstalls the service. If the node then doesn't become Ready,InstallWorkers.CleanUprunsk0s reseton it. That's not what you'd expect from an upgrade.Changes
The not-running-but-installed branch of
investigateK0snow calls a newhandleStoppedServicehelper:--force, the error now ends withplease remove it, start the service or use --force to proceed anyway.--forceon a worker, the helper calls the existingneedsUpgradeand stores the result inh.Metadata.NeedsUpgrade. The binary providers already fall back to the installed binary version when nothing is running. So a stopped worker with an outdated binary now goes throughUpgradeWorkers: stop the service (a no-op here), replace the binary, reinstall and start the service.InstallWorkersskips it.--forcebehaviour. A stopped controller has no running version, so it can also end up as the fallback leader forInitializeK0s. Marking it for upgrade as well would send the same host through both phases. That case needs more thought, so I left it out.A stopped worker whose binary already matches the target version still takes the existing
InstallWorkerspath. Only the version mismatch from the issue is rerouted. Without--no-drain,UpgradeWorkersstill cordons and drains the node through the leader, as for any other upgrade. The issue's workaround is--force --no-drain.Testing
TestHandleStoppedServicewith four cases:--force, the error mentions--force;--force, an outdated stopped worker is marked for upgrade;--force, andNeedsUpgradestays false. Both pass with the change.go test ./...andgo vet ./phase/pass, andgofmtreports nothing for the changed files. My environment didn't have Go 1.27, so I ran these with Go 1.25.1 against local copies of the dependencies, with small compatibility shims in the rig v2 copy only. The repository's own files are unchanged apart from this diff.