Skip to content

chore: drop the rig fork replace and build against rig v2.2.1 - #707

Merged
james-nesbitt merged 2 commits into
mainfrom
chore/rig-v2.2.1
Nov 12, 2026
Merged

james-nesbitt merged 2 commits into
mainfrom
chore/rig-v2.2.1

Conversation

@james-nesbitt

@james-nesbitt james-nesbitt commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

What

Removes the replace directive pinning rig to a fork, so launchpad builds against github.com/k0sproject/rig/v2 v2.2.1 from upstream.

-replace github.com/k0sproject/rig/v2 => github.com/james-nesbitt/rig/v2 v2.0.0-alpha.2.0.20260916132849-b534cbe07c9f

Three lines of go.mod/go.sum plus a changelog entry, and then — in 94d90fe — 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:

bound WinRM command.Wait() and remotefs upload against dead sessions — both could block forever on a silently dead WinRM session, observed as a 40+ minute hang in smoke-windows right after a Windows host reboot, during remotefs.Upload.

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:

Tag commandTimeout/errRcpTimeout in remotefs/winfile.go
v2.1.0 0
v2.2.1 14

and v2.2.1's command.Wait() has the ctx race the fork added:

select {
case <-done:
case <-c.ctx.Done():

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): honour StrictHostKeyChecking=yes instead of always accepting new hosts
  • 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 can identify
  • 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 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. isTransientAuthError in pkg/product/common/phase/connect.go 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. shouldRetryConnect is 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 ResolveLinuxCompat stands down when os-release identifies the host, and TestOSRegistryOrderingIsStable passes against rig's DefaultRegistry.

The second half still earns its place, measured rather than assumed:

rigos.DefaultRegistry().Get(bare host with apt-get, no os-release)
  → ID="linux" IDLike=["debian"] err=<nil>

Every matcher registered through configurer.RegisterOSModule compares r.ID to an exact distribution name and none consults IDLike, 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, as os.ErrNotRecognized. Its comment now says that is the only reason it exists.

Testing

go build ./...     clean
make lint          0 issues
make unit-test     35 packages ok, 0 failures

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:

Run commit smoke-windows smoke-modern
43175998290 c8d5d8d — fork replace dropped success success
43176554486 94d90fe — workarounds removed success success

smoke-windows is the one that matters here: the hang the fork existed for was a Windows remotefs.Upload against a dead WinRM session, which smoke-modern cannot reach.

Checklist

  • Tests added or updated — connect_test.go moved to rig v2.2's error shapes; osregistry_test.go asserts the ordering fix against rig's own registry
  • Docs updated if user-visible behaviour changed — changelog entry added
  • No debug output or dead code left in

Written by AI: claude-opus-5

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>
@james-nesbitt james-nesbitt added smoke-modern Run modern smoke test smoke-windows Run windows smoke test labels Nov 12, 2026
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>

Copilot AI left a comment

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.

🟡 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

Comment thread pkg/product/common/phase/connect.go Resolved
@james-nesbitt
james-nesbitt merged commit fa0a347 into main Nov 12, 2026
17 checks passed
@james-nesbitt
james-nesbitt deleted the chore/rig-v2.2.1 branch November 12, 2026 08:39
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

smoke-modern Run modern smoke test smoke-windows Run windows smoke test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants