Repository navigation
chore: drop the rig fork replace and build against rig v2.2.1 - #707
Merged
Merged
Conversation
go.mod carried
replace github.com/k0sproject/rig/v2 =>
github.com/james-nesbitt/rig/v2 v2.0.0-alpha.2.0.20260916132849-b534cbe07c9f
introduced with the rig v2 migration (#651). The fork existed to carry
one fix: bounding winrm.(*command).Wait() and remotefs.(*winFile)
.command() against a silently dead WinRM session, seen as a 40+ minute
smoke-windows hang after a Windows host reboot during remotefs.Upload.
Upstream had not merged it, so the replace was the only way to get it.
Upstream has merged it since -- k0sproject/rig#473, issue #472 closed --
and released it. Verified by content rather than by commit SHA, which is
why this was missed before: upstream merged a rebased commit, so the
fork's SHA is not an ancestor of upstream main and an ancestry check
reports the fix as absent when it is present. In remotefs/winfile.go,
commandTimeout and errRcpTimeout appear 0 times at v2.1.0 and 14 times
at v2.2.1, and v2.2.1's command.Wait() carries the ctx race the fork
added.
#706 bumped the require line to v2.2.1 but the replace silently
discarded it; removing the replace is what actually moves rig.
Roughly fifty commits arrive with it. Beyond the WinRM hang fix, the
ones touching paths launchpad uses:
fix(ssh): honour StrictHostKeyChecking=yes instead of always accepting
fix(cmd,sudo): impose a POSIX shell instead of trusting $SHELL
fix(initsystem): don't let SysVinit match systemd hosts
fix(os): stop ResolveLinuxCompat claiming hosts os-release identifies
fix(remotefs): several ErrNotExist misclassifications in WinFS stat
feat(remotefs): atomic downloads, opt-in resume, HTTPHead
feat(winrm): export ErrAuthFailed, stop marking 401/403 non-retryable
Two of those overlap workarounds the migration added: launchpad builds
its own OS release registry via rig.WithOSReleaseProvider to drop the
compat fallback, and handles the 401/403 retry classification itself.
Both still compile and are left alone here -- whether they are now
redundant is a separate question from whether the update is safe.
Verified: go build ./... clean, make lint 0 issues, make unit-test 35
packages ok and 0 failures.
Not covered by unit tests: this is the host connectivity layer, so the
smoke suites are the real exercise. smoke-modern is labelled on the PR.
Written by AI: claude-opus-5
Signed-off-by: James Nesbitt <jnesbitt@mirantis.com>
Two migration-era workarounds overlapped fixes that arrived with v2.2.1. One is now entirely upstream's; the other turned out to be only half overlap, and the half that still earns its place is kept. 401/403 retry classification -- removed in full. isTransientAuthError matched "http error 401" and three sibling shapes by substring, because rig v2.1 wrapped a WinRM credential rejection in ErrNonRetryable and this phase, whose whole job is waiting for hosts to become reachable, abandoned a host on its first attempt. smoke-fips regressed on exactly that. rig v2.2 tags a rejection with protocol.ErrAuthFailed and deliberately leaves it outside ErrNonRetryable, documenting the same reasoning: "WinRM starts answering before authentication has been configured, and sshd accepts connections before authorized_keys has been written". shouldRetryConnect is now one line and the substring table is gone. The test keeps its cases and moves them to the shapes rig produces now. OS release registry -- kept, with its rationale corrected. It was introduced for two reasons. The first is upstream's now: rig's registry promoted the winning resolver to the front, letting ResolveLinuxCompat -- which matches every Linux host -- overtake ResolveLinux after a Windows host resolved, so mixed clusters misreported Linux hosts as "linux". v2.2's ResolveLinuxCompat stands down when os-release identifies the host, so ordering no longer decides the outcome. TestOSRegistryOrderingIsStable now asserts that against rig's own DefaultRegistry and passes. The second reason stands, and dropping the registry regressed it -- caught by TestOSRegistryRejectsUnreadableOSRelease failing. Measured against rig's default registry, a host with no readable os-release but with apt-get resolves to ID "linux", IDLike ["debian"] rather than erroring. Every matcher registered through configurer.RegisterOSModule compares r.ID to an exact distribution name and none consults IDLike, so that host matches no configurer and fails later, further from the cause. The registry still excludes compat so the failure stays at resolution as os.ErrNotRecognized. Verified: go build ./... clean, make lint 0 issues, make unit-test 0 failures. Written by AI: claude-opus-5 Signed-off-by: James Nesbitt <jnesbitt@mirantis.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The PR description and testing scope need to reflect the removal of the 401/403 workaround and delegation of retry classification to upstream rig.
1 open issue
What changed in this PR
Moves Launchpad’s host connectivity layer from the rig fork to upstream v2.2.1, which includes the Windows dead-session protections that motivated the fork.
Changes:
- Removes the fork replacement and updates dependency checksums.
- Removes local WinRM authentication-error matching, relying on upstream retry classification.
- Updates regression tests and clarifies why the custom OS registry remains necessary.
| File | Description |
|---|---|
pkg/product/mke/config/osregistry_test.go |
Tests mixed-OS resolver ordering against upstream’s default registry. |
pkg/product/mke/config/host.go |
Updates comments explaining the retained OS registry workaround; no runtime change. |
pkg/product/common/phase/connect.go |
Removes substring-based authentication-error classification. |
pkg/product/common/phase/connect_test.go |
Uses upstream’s authentication-failure sentinel in retry tests. |
go.sum |
Replaces fork checksums with upstream v2.2.1 checksums. |
go.mod |
Removes the rig fork replacement. |
.changes/rig-v2.2.1.md |
Documents the return to upstream rig and its included fixes. |
Review effort: Balanced
james-nesbitt
added a commit
that referenced
this pull request
Nov 12, 2026
Brings in Go 1.27.4 (#706) and rig v2.2.1 (#707), which is what clears Security Scan on this branch. cluster_test.go conflicted. Both sides inserted a test function at the same anchor, and git split that single collision into two marker blocks by aligning the identical YAML prologue -- `return ` plus apiVersion through version: 3.3.7 -- that both new functions happen to share. A verbatim ours-then-theirs union of those blocks produces a function with two openers and one body. Resolved by reconstructing both functions whole from the three stages rather than splicing the marker regions: ours' TestAdminPasswordIsRequired and main's TestWinRMPasswordExposureWarning each get their own copy of the shared prologue and their own closing brace. A first attempt took main's file and inserted only ours' new function. That compiled, and it was wrong: this branch is not a pure insertion at file level -- it also adds adminPassword to 27 existing fixtures, and that edit was silently dropped. Twelve unrelated tests failed on the required tag, which is what exposed it. git merge-file over the three stages keeps those edits and reduces the conflict to the two genuine blocks. Four fixtures that arrived with main omit spec.mke.adminPassword and now fail validation, this branch having made it required: TestWinRMPasswordExposureWarning, ...IsPerHost, TestEmptyWinRMPasswordIsRejected and TestHostWithNoProtocolIsRejected. Each gains adminPassword: fake-admin-password, the same value and convention the branch already applied to the fixtures that predated it. TestAdminPasswordIsRequired's own fixture is deliberately left without one, since its absence is what that test asserts. Verified by counting removals rather than by a passing suite, because a wrong splice here compiles and passes both: diffing the merged file against each stage shows zero lines removed from ours and zero from theirs. make unit-test 0 failures, make lint 0 issues. Written by AI: claude-opus-5 Signed-off-by: James Nesbitt <jnesbitt@mirantis.com>
james-nesbitt
added a commit
that referenced
this pull request
Nov 12, 2026
TestRigRedactionIsLiteral's comment said go.mod replaces rig with a fork and that neither property could be assumed from upstream's source. The replace directive is gone (#707) and launchpad builds on upstream v2.2.1. Both properties still hold: the two tests pass unchanged against upstream. That is the point worth recording -- the behaviour the redaction sites depend on is not fork-specific. Written by AI: claude-opus-5 Signed-off-by: James Nesbitt <jnesbitt@mirantis.com>
4 tasks done
james-nesbitt
added a commit
that referenced
this pull request
Nov 12, 2026
* [PRODENG-3922] Close credential redaction gaps in logging Both plausible readings of rig's redaction API are implemented somewhere in this codebase, and both are wrong: go.mod replaces github.com/k0sproject/rig/v2 with a fork whose cmd.Redact matches literally (strings.ReplaceAll) and whose repeated Redact options compose rather than overwrite. Two classes of call site assumed the opposite of what the fork does. Regex patterns handed to the literal matcher never matched anything, so nothing was redacted: init_swarm.go's `--token \S+` left the swarm manager join token in the log of every cluster init, and mke.go's CA-dump pattern left the full certificate unredacted. Neither secret is known at the call site -- both are in the command's OUTPUT, not its arguments -- so no Redact pattern, literal or regex, can mask them; both now use cmd.HideOutput() instead. The swarm tokens are read back later with `swarm join-token` when needed and the CA PEM is returned to the caller, so nothing is lost. regexp.QuoteMeta applied to a value before handing it to the literal matcher escapes it into a spelling that never appears in the log. This is invisible in testing, because QuoteMeta is the identity function for alphanumeric input: only a credential containing a regex metacharacter exposed it. Seven sites in pkg/configurer's two AuthenticateDocker implementations and two more inside install_mke.go's adminCredentialRedactions helper, which doubly escaped one of its two values (regexp.QuoteMeta(shellescape.Quote(value))). All now pass literal values. pkg/configurer/redaction_semantics_test.go pins the fork's actual behaviour -- a metacharacter-bearing value is masked, the QuoteMeta'd form is not, and two Redact options both take effect -- so a future bump that flips the semantics back toward regex fails this test rather than silently disabling redaction. install_mke_test.go's own redact() harness compiled each value as a regex before this change: production assumed regex, the test assumed regex, they agreed with each other and neither agreed with rig. It now calls the real rig code path. upgrade_msr.go gains redaction for the MKE credentials BuildMKEFlags injects into the command line; nothing covered it before. msr.Destroy has the same gap and is deliberately left to PRODENG-3923, which removes that credential from argv entirely rather than redacting it in place; 3923 rewrites msr.Destroy today and a second hand in that file in the same afternoon is the more expensive mistake. This PR must not merge before PRODENG-3923 (#691). pkg/config/config.go's case-sensitive config-dump regex never matched the schema's camelCase adminUsername/adminPassword and missed keyData/certData entirely. It is replaced with pkg/util/redact.YAML, the key-based masking PRODENG-3921 introduced. A configuration that fails to parse is still dumped -- a debug dump of a broken configuration is exactly when the output is wanted -- using the old regex as a documented best-effort fallback: the log line announcing the fallback states explicitly that the masking is partial, so an operator deciding whether to share the output knows which guarantee they are relying on. install_mke.go's raw `installFlags.Join()` debug line is removed. It ran before rig's own redaction and printed --admin-password and --license with their values; rig already logs the rendered command with the redactions above applied. Trace and Debug records previously reached the persistent log file (~/.mirantis-launchpad/cluster/<name>/*.log) on every run regardless of flags, because the file hook was registered for log.AllLevels while the logger itself was set to TraceLevel unconditionally. That is what made every other gap in this PR persistent on disk rather than transient on a terminal. The file hook now receives Trace only with --trace and Debug only with --debug; the logger's level is unchanged, so command behaviour elsewhere is unaffected. .changes/PRODENG-3922.md documents the operator-visible change. Written by AI: claude-opus-5 Signed-off-by: James Nesbitt <jnesbitt@mirantis.com> * [PRODENG-3922] Close review findings on redaction ordering and coverage Three measured defects from the review of #695, plus a strengthened fallback. Registration order decided whether a credential was masked. rig replaces each registered value in turn with strings.ReplaceAll, so a value that is a prefix of another destroys the longer match before it is tried. Measured with the real code path: username "admin" and password "admin!s3cr3t" registered in that order yield "login -u [REDACTED] -p [REDACTED]!s3cr3t", and the distinctive part of the password survives. redact.ByLengthDesc orders values longest first and drops empty ones; every site that registers more than one value now uses it -- both AuthenticateDocker implementations, adminCredentialRedactions, and the MSR helper. msrCredentialRedactions missed two spellings. A flag and its value in separate list elements ("--ucp-password", "split-secret") form a working command once Flags.Join concatenates them, but Flags.Get returns only the flag, so nothing was registered; the value is now read from the following element. And FlagValue uses strconv.Unquote, which does not decode the shell quoting BuildMKEFlags produces, so for a password containing a quote only the rendered spelling was registered and the password itself stayed visible wherever the bootstrapper echoed it back; the shell-decoded form is now registered alongside the rendered one. The unparseable-config fallback no longer uses the old two-word case-sensitive regex. redact.Text applies the same key set and the same environment-variable fragments as the structured path, line by line, so a configuration that fails to parse keeps camelCase and environment coverage instead of losing it. The real limit is now multi-line values rather than key names: a credential in a block scalar is not masked, which is what the log line means by best-effort. That limit is pinned by a test, and the test that pinned the previous weaker limit failed when this landed, which is what it was written to do. Four regression tests for the MSR helper, two for the fallback, one for ordering. The test helper in install_mke_test.go is renamed to applyRedactions to avoid shadowing the redact package. Written by AI: claude-opus-5 Signed-off-by: James Nesbitt <jnesbitt@mirantis.com> * Correct the rig fork reference in the redaction semantics test TestRigRedactionIsLiteral's comment said go.mod replaces rig with a fork and that neither property could be assumed from upstream's source. The replace directive is gone (#707) and launchpad builds on upstream v2.2.1. Both properties still hold: the two tests pass unchanged against upstream. That is the point worth recording -- the behaviour the redaction sites depend on is not fork-specific. Written by AI: claude-opus-5 Signed-off-by: James Nesbitt <jnesbitt@mirantis.com> --------- Signed-off-by: James Nesbitt <jnesbitt@mirantis.com>
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.

What
Removes the
replacedirective pinning rig to a fork, so launchpad builds againstgithub.com/k0sproject/rig/v2 v2.2.1from upstream.-replace github.com/k0sproject/rig/v2 => github.com/james-nesbitt/rig/v2 v2.0.0-alpha.2.0.20260916132849-b534cbe07c9fThree lines of
go.mod/go.sumplus a changelog entry, and then — in94d90fe— the two launchpad workarounds that existed only because the fork lagged upstream. See "Two migration-era workarounds" below; this is not a dependency-only change.Why the fork existed, and why it no longer needs to
The replace came in with the rig v2 migration (#651, 2026-09-19), pinned at
b534cbe. That commit carried exactly one fix:Upstream had not merged it, so the fork was the only way to get it. Upstream has merged it since — k0sproject/rig#473, with issue #472 closed — and released it.
Verified by content, not by commit SHA. Upstream merged a rebased commit, so the fork's SHA is not an ancestor of upstream
main; an ancestry check reports the fix as absent when it is present. I made that mistake earlier in this investigation. The content check:commandTimeout/errRcpTimeoutinremotefs/winfile.gov2.1.0v2.2.1and
v2.2.1'scommand.Wait()has the ctx race the fork added:Note #706 bumped the require line to
v2.2.1, but the replace silently discarded it. Removing the replace is what actually moves rig.What arrives
Roughly fifty commits between the fork point and
v2.2.1. The ones touching paths launchpad uses:fix(ssh): honourStrictHostKeyChecking=yesinstead of always accepting new hostsfix(cmd,sudo): impose a POSIX shell instead of trusting$SHELLfix(initsystem): don't let SysVinit match systemd hostsfix(os): stopResolveLinuxCompatclaiming hosts os-release can identifyfix(remotefs): severalErrNotExistmisclassifications in WinFS statfeat(remotefs): atomic downloads, opt-in resume,HTTPHeadfeat(winrm): exportErrAuthFailed, stop marking 401/403 non-retryableTwo migration-era workarounds, now addressed (
94d90fe)Both were originally left for a follow-up; they are handled here instead. One was genuinely redundant, the other only half.
Removed in full — the 401/403 retry classification.
isTransientAuthErrorinpkg/product/common/phase/connect.gomatched"http error 401"and three sibling shapes by substring, because rig v2.1 wrapped a WinRM credential rejection inErrNonRetryableand this phase — whose whole job is waiting for hosts to become reachable — abandoned a host on its first attempt.smoke-fipsregressed on exactly that.rig v2.2 tags a rejection with
protocol.ErrAuthFailedand deliberately leaves it outsideErrNonRetryable, documenting the same reasoning.shouldRetryConnectis one line now and the substring table is gone. The test keeps all seven cases, moved to the error shapes rig produces today.Kept, with its rationale corrected — the OS release registry. Removing it looked right and was caught by its own test failing. The ordering half is upstream's now: v2.2's
ResolveLinuxCompatstands down when os-release identifies the host, andTestOSRegistryOrderingIsStablepasses against rig'sDefaultRegistry.The second half still earns its place, measured rather than assumed:
Every matcher registered through
configurer.RegisterOSModulecomparesr.IDto an exact distribution name and none consultsIDLike, so such a host matches no configurer and fails later, further from the cause. The registry keeps excluding compat so the failure stays at resolution, asos.ErrNotRecognized. Its comment now says that is the only reason it exists.Testing
Unit tests are not the real exercise: this is the host connectivity layer every phase uses to reach every host. Both labelled suites passed, on both commits:
c8d5d8d— fork replace dropped94d90fe— workarounds removedsmoke-windowsis the one that matters here: the hang the fork existed for was a Windowsremotefs.Uploadagainst a dead WinRM session, whichsmoke-moderncannot reach.Checklist
connect_test.gomoved to rig v2.2's error shapes;osregistry_test.goasserts the ordering fix against rig's own registryWritten by AI: claude-opus-5