Skip to content

Commit 19245e4

Browse files
committed
fix(apply): preflight resolves nodes from talosconfig when --nodes omitted
Address review feedback from coderabbitai on pkg/commands/apply.go:178: the direct-patch closure iterated GlobalArgs.Nodes only, but wrapWithNodeContext fills ctx via client.WithNodes from the talosconfig context when --nodes is omitted without mutating GlobalArgs.Nodes itself. The preflight loop was a no-op in that path and the log line printed an empty node list. Mirror wrapWithNodeContext's resolution into a local targetNodes slice and use it for both the log line and the per-node preflight loop. With --nodes set, behavior is unchanged. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent b6e0618 commit 19245e4

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎pkg/commands/apply.go‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,23 @@ func apply(args []string) error {
168168
}
169169

170170
if err := withApplyClient(func(ctx context.Context, c *client.Client) error {
171-
fmt.Printf("- talm: file=%s, nodes=%s, endpoints=%s\n", configFile, GlobalArgs.Nodes, GlobalArgs.Endpoints)
171+
// wrapWithNodeContext fills ctx via client.WithNodes from
172+
// talosconfig when --nodes is omitted, but does not mutate
173+
// GlobalArgs.Nodes. Mirror its resolution here so the log line
174+
// and the per-node preflight loop see the actual targets.
175+
targetNodes := append([]string(nil), GlobalArgs.Nodes...)
176+
if len(targetNodes) == 0 {
177+
if cfg := c.GetConfigContext(); cfg != nil {
178+
targetNodes = append(targetNodes, cfg.Nodes...)
179+
}
180+
}
181+
fmt.Printf("- talm: file=%s, nodes=%s, endpoints=%s\n", configFile, targetNodes, GlobalArgs.Endpoints)
172182

173-
// withApplyClient injects all target nodes into ctx via
174-
// client.WithNodes; COSI does not support multi-node proxying
183+
// COSI does not support multi-node proxying
175184
// (see rotate_ca_handler.go:317). Run preflight per node with
176185
// a single-target context.
177186
read := cosiVersionReader(c)
178-
for _, node := range GlobalArgs.Nodes {
187+
for _, node := range targetNodes {
179188
preflightCheckTalosVersion(client.WithNode(ctx, node), read, applyCmdFlags.talosVersion, os.Stderr)
180189
}
181190

0 commit comments

Comments
 (0)