You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6e0913c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(commands): retire talm dmesg ahead of upstream, redirect operators to logs kernel
Upstream Talos signaled retirement of the `dmesg` command in
siderolabs/talos#13333 ("Kernel logs are available with
`talosctl logs kernel` which supports `--tail=N`, we will
probably retire `dmesg` command"). The current wrapper-side
cushion for the `--tail=N` ParseBool footgun points operators
at a pipe workaround that becomes obsolete the moment upstream
removes the surface — and `logs kernel --tail=N` is the better
target right now anyway, because it matches the line-count
semantics operators reach for.
Removes `talm dmesg` proactively:
- Adds `dmesg` to `excludedCommands` in the talosctl-wrapper
init so the upstream `dmesg` command is no longer imported.
- Replaces the cushion in `pkg/commands/dmesg_handler.go` with
a hidden migration stub. Every `talm dmesg ...` invocation
errors with "talm dmesg has been removed" plus a hint
pointing at `talm logs kernel --tail=N --nodes <node>` and a
reference to siderolabs/talos#13333.
- `DisableFlagParsing` on the stub lets operator-supplied
flags pass through to RunE so the hint surfaces regardless
of what arguments accompanied the call.
- Adds `dmesg` to `skipConfigCommands` in main.go so the
migration hint fires even when the operator runs the command
outside a talm project (mirrors the init / completion
treatment).
The stub is `Hidden: true` so operators reading `talm --help`
don't see a retired command as available. Existing scripts that
call `talm dmesg <flags>` get an immediate, actionable
migration nudge instead of a silent break on the next Talos
bump.
Contract pins (TestDmesgRemoved_StubSurfacesMigrationHint,
TestDmesgExcludedFromTalosctlWrap):
- exactly one `dmesg` entry registered (the stub, not the
upstream wrap),
- stub is hidden + always-erroring,
- error names the migration target (logs kernel + --tail).
Test plan (docs/manual-test-plan.md):
- I0-1 read-only command sweep: `dmesg --tail` replaced with
`logs kernel --tail 3` so the bake hits the new supported
path.
- I0-1a new entry pinning the migration-stub UX (both
bare-invocation and `--tail` invocations error with the
hint; stub is hidden from --help; cwd-independent).
- H2b regression anchor for reset: `dmesg | grep ephemeral`
swapped for `logs kernel | grep ephemeral`.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Copy file name to clipboardExpand all lines: docs/manual-test-plan.md
+14-3Lines changed: 14 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -545,7 +545,7 @@ Regression anchor: when EITHER of these commands is run the wrapper MUST NOT sil
545
545
546
546
Expected: only STATE wiped, EPHEMERAL kept (containerd image cache survives the reset), node returns. The operator's explicit narrower list must be honored byte-for-byte; the wrapper MUST NOT silently expand to `STATE,EPHEMERAL`.
547
547
548
-
Regression anchor: after the node returns, `talm dmesg --nodes $NODE | grep -i ephemeral` should show no fresh-format markers for the EPHEMERAL partition. If the wrapper silently expanded the operator's list, EPHEMERAL would have been wiped too.
548
+
Regression anchor: after the node returns, `talm logs kernel --nodes $NODE | grep -i ephemeral` should show no fresh-format markers for the EPHEMERAL partition. If the wrapper silently expanded the operator's list, EPHEMERAL would have been wiped too.
549
549
550
550
### H2c. Reset with `--graceful=false` (ungraceful, preserves safe default)
551
551
@@ -604,14 +604,25 @@ NODE=$NODE
604
604
forcmdin version "get machineconfig -o yaml" containers processes \
timeout 8 /tmp/talm-safety $cmd --nodes $NODE --endpoints $NODE2>&1| head -1
611
611
done
612
612
```
613
613
614
-
Expected: every command prints either a header row (table) or an error from the node side. None should hang past the timeout.
614
+
Expected: every command prints either a header row (table) or an error from the node side. None should hang past the timeout. The `logs kernel` entry replaces the retired `dmesg` command; `logs kernel --tail=N` is the supported way to read the last N kernel-log lines.
615
+
616
+
### I0-1a. `talm dmesg` is retired — migration stub surfaces a hint
617
+
618
+
```bash
619
+
/tmp/talm-safety dmesg --tail 3
620
+
/tmp/talm-safety dmesg --nodes $NODE
621
+
```
622
+
623
+
Expected: both invocations exit non-zero with `talm dmesg has been removed` and a hint pointing at `talm logs kernel --tail=N --nodes <node>`. The stub is hidden from `talm --help` (operators don't see a retired command as available). The migration hint surfaces regardless of cwd (the stub skips Chart.yaml loading, mirroring `init` and `completion`).
624
+
625
+
Regression anchor: a regression that re-enables the upstream `dmesg` wrap (removing it from `excludedCommands` in `pkg/commands/talosctl_wrapper.go`) would either collide with the talm-owned stub at cobra registration, or — if the stub is also dropped — leave operators with the original cryptic `strconv.ParseBool` failure on `--tail=N`. Both shapes are documented elsewhere; this anchor pins the proactive removal + migration-hint contract.
errors.Wrap(err, "talm dmesg --tail is a boolean toggle (tail-mode for --follow), not a line count"),
62
-
"for the last N lines, pipe to tail(1): `talm dmesg --nodes <node> | tail -n N`; to stream only new messages, use `--follow --tail`",
63
-
)
64
-
}
48
+
// Side effect of DisableFlagParsing: cobra does NOT intercept
49
+
// `--help` either — `talm dmesg --help` reaches RunE and
50
+
// surfaces the same migration hint instead of cobra's help
51
+
// renderer. Intentional: every invocation of the retired
52
+
// command should reach the same nudge. A future maintainer
53
+
// who flips DisableFlagParsing to false would silently
54
+
// re-introduce the original pflag failure shape on `--tail=N`
55
+
// for any operator who didn't migrate yet.
56
+
//
57
+
//nolint:gochecknoglobals // cobra command registration requires a package-level value
58
+
vardmesgCmd=&cobra.Command{
59
+
Use: dmesgCmdName,
60
+
Short: "[removed] use `talm logs kernel` instead",
61
+
Hidden: true,
62
+
DisableFlagParsing: true,
63
+
RunE: func(_*cobra.Command, _ []string) error {
64
+
returnerrors.WithHint(
65
+
errors.New("talm dmesg has been removed"),
66
+
"use `talm logs kernel --tail=N --nodes <node>` for the last N kernel-log lines, or `talm logs kernel --follow --nodes <node>` to stream new messages. Upstream Talos is retiring the `dmesg` command (see siderolabs/talos#13333) and talm drops it ahead of time to avoid a silent break on the next Talos bump.",
// Find the registered talm `dmesg` stub among package
364
+
// commands. Iterate Commands rather than rootCmd.Commands
365
+
// because rootCmd assembly happens in main.go's init, which
366
+
// the test package doesn't drive.
367
+
varstub*cobra.Command
368
+
369
+
for_, cmd:=rangeCommands {
350
370
ifcmd.Name() =="dmesg" {
351
-
dmesgCmd=cmd
371
+
stub=cmd
352
372
353
373
break
354
374
}
355
375
}
356
376
357
-
ifdmesgCmd==nil {
358
-
t.Skip("upstream taloscommands.Commands has no 'dmesg' command — schema changed")
377
+
ifstub==nil {
378
+
t.Fatal("talm must register a `dmesg` stub command so `talm dmesg ...` invocations surface a migration hint; got no command with that name in Commands")
359
379
}
360
380
361
-
wrapped:=wrapTalosCommand(dmesgCmd, "dmesg")
362
-
363
-
// FlagErrorFunc is invoked by cobra's Execute() lifecycle on a
364
-
// ParseFlags failure. Reproduce that path by capturing the
365
-
// ParseFlags error and feeding it through the registered hook —
366
-
// this is exactly what cobra does internally in command.execute.
367
-
rawErr:=wrapped.ParseFlags([]string{"--tail=3"})
368
-
ifrawErr==nil {
369
-
t.Fatal("--tail=3 must error from pflag (upstream --tail is bool); got nil")
381
+
if!stub.Hidden {
382
+
t.Error("dmesg stub must be hidden from --help so operators don't see a retired command as available")
370
383
}
371
384
372
-
hook:=wrapped.FlagErrorFunc()
373
-
ifhook==nil {
374
-
t.Fatal("wrapped dmesg must register a FlagErrorFunc to rewrite ParseBool errors")
385
+
// Invoke RunE to verify the migration error fires with the
386
+
// hint pointing at `logs kernel`. RunE invocation skips
387
+
// cobra's flag parsing layer; the stub uses
388
+
// DisableFlagParsing so any operator-supplied flags pass
389
+
// through and don't error before reaching RunE.
390
+
ifstub.RunE==nil {
391
+
t.Fatal("stub must have a RunE that returns the migration error")
t.Errorf("hint must point at `talm logs kernel` covering both `--tail=N` (last N lines) and `--follow` (stream); missing %q in hints:\n%s", want, hints)
415
+
}
386
416
}
417
+
}
387
418
388
-
// Chain must preserve the original ParseBool error via
389
-
// errors.Wrap so the underlying pflag failure remains
390
-
// reachable for verbose debugging (errors.Unwrap,
391
-
// fmt.Sprintf("%+v", err), etc.). Without wrap-not-replace,
392
-
// downstream tooling that walks the chain or matches against
393
-
// the upstream error type loses information.
394
-
if!strings.Contains(msg, "ParseBool") {
395
-
t.Errorf("rewritten error must wrap (not replace) the original ParseBool error so the chain stays inspectable; got: %q", msg)
419
+
// TestDmesgExcludedFromTalosctlWrap pins the other half of the
420
+
// removal contract: the upstream taloscommands.Commands entry
421
+
// for `dmesg` MUST NOT be wrapped through wrapTalosCommand.
422
+
// Without this guard the talm-owned stub and the wrapped
423
+
// upstream command would collide on cobra registration. The
424
+
// excludedCommands map in talosctl_wrapper.go's init is the
425
+
// load-bearing piece; this test surfaces a regression that
426
+
// removes "dmesg" from the map while leaving the stub.
// The talm Commands slice is built from two sources:
431
+
// upstream taloscommands.Commands (excluding the
432
+
// excludedCommands map) and talm-native registrations
433
+
// (apply, init, template, talosconfig, plus our new dmesg
434
+
// stub). Exactly one entry named `dmesg` should exist (the
435
+
// stub). If two are present, the exclusion failed.
436
+
count:=0
437
+
438
+
for_, cmd:=rangeCommands {
439
+
ifcmd.Name() =="dmesg" {
440
+
count++
441
+
}
396
442
}
397
443
398
-
ifunwrapped:=errors.Unwrap(err); unwrapped==nil {
399
-
t.Errorf("rewritten error must be unwrappable to the original; errors.Unwrap returned nil for %q", msg)
444
+
ifcount!=1 {
445
+
t.Errorf("Commands slice must contain exactly one entry named 'dmesg' (the talm stub); got %d — upstream taloscommands.Commands entry was not excluded", count)
0 commit comments