Conversation
When a cluster is created with a custom --node-name, adding a new node fails because --control-plane defaults to "node1". Discover the actual control-plane node from container labels before creating the cluster manager. Fixes: #32 Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add integration test that creates a cluster with --node-name and adds a worker node without specifying --control-plane, covering the scenario from issue #32. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reviewer's GuideAuto-detects the control-plane node name from existing containers during node addition and adds an integration test flow (with helpers) to verify adding a worker node when the control-plane uses a custom node name. Sequence diagram for node addition with control-plane auto-detectionsequenceDiagram
actor User
participant CLIAddNode
participant PodmanClient
participant ClusterMgr
User->>CLIAddNode: runAdd(nodeName, controlPlane, nodeImage, role)
alt [controlPlane not set]
CLIAddNode->>PodmanClient: findControlPlaneNode(ctx, podmanClient, clusterName, "")
PodmanClient-->>CLIAddNode: discoveredControlPlaneName
CLIAddNode->>CLIAddNode: controlPlane = discoveredControlPlaneName
end
CLIAddNode->>ClusterMgr: New(cluster.Config{ Name, ControlPlane, HostNetworkPopulator, Logger })
CLIAddNode->>ClusterMgr: EnsureImagesVolume(ctx, nodeImage)
ClusterMgr-->>CLIAddNode: clusterImagesVolume
CLIAddNode-->>User: node added with images volume ensured
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new auto-detection logic runs unconditionally and will overwrite a user-specified
--control-planevalue; consider only callingfindControlPlaneNode(or only assigning its result) when thecontrolPlaneargument is empty to respect explicit CLI input. - If
findControlPlaneNodereturns an error, the code silently ignores it; adding at least a debug log would make it easier to diagnose cases where control-plane discovery fails andEnsureImagesVolumesubsequently misbehaves. - The log message
Step 0: Ensuring cluster images volume...now appears afterStep 1: Creating ... node; consider renumbering or reordering these steps so the log output reflects the actual execution order.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new auto-detection logic runs unconditionally and will overwrite a user-specified `--control-plane` value; consider only calling `findControlPlaneNode` (or only assigning its result) when the `controlPlane` argument is empty to respect explicit CLI input.
- If `findControlPlaneNode` returns an error, the code silently ignores it; adding at least a debug log would make it easier to diagnose cases where control-plane discovery fails and `EnsureImagesVolume` subsequently misbehaves.
- The log message `Step 0: Ensuring cluster images volume...` now appears after `Step 1: Creating ... node`; consider renumbering or reordering these steps so the log output reflects the actual execution order.
## Individual Comments
### Comment 1
<location path="internal/cli/node/add.go" line_range="128-132" />
<code_context>
}
}
+ // Auto-detect the control-plane node name from container labels
+ discovered, err := findControlPlaneNode(ctx, podmanClient, clusterName, "")
+ if err == nil {
+ controlPlane = discovered
+ }
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Avoid silently overriding an explicitly provided controlPlane value.
This unconditionally overwrites any user-specified `controlPlane` when `findControlPlaneNode` returns a value, which can break explicit targeting. Only apply the auto-detected value when `controlPlane` is empty/unset, e.g. `if controlPlane == "" && err == nil { ... }`.
```suggestion
// Auto-detect the control-plane node name from container labels
if controlPlane == "" {
discovered, err := findControlPlaneNode(ctx, podmanClient, clusterName, "")
if err == nil {
controlPlane = discovered
}
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Auto-detect the control-plane node name from container labels when
--control-planeis not explicitly setFixes: #32
Summary by Sourcery
Auto-detect the control-plane node name when adding nodes so clusters with custom control-plane names work without explicitly specifying --control-plane.
Bug Fixes:
Tests: