Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/kubeadm/v20260301/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ func (n *nodeJoinAction) runJoin(
return status.Errorf(codes.Internal, "resolve kubeadm binary: %s", err)
}

if err := utilexec.New().CommandContext(ctx, kubeadmCommand, "join", "--config", joinConfig, "-v", "5").Run(); err != nil {
return status.Errorf(codes.Internal, "kubeadm join: %s", err)
if output, err := utilexec.New().CommandContext(ctx, kubeadmCommand, "join", "--config", joinConfig, "-v", "5").CombinedOutput(); err != nil {
return status.Errorf(codes.Internal, "kubeadm join: %s\n%s", err, string(output))
Comment on lines +270 to +271
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CombinedOutput() buffers all kubeadm stdout/stderr in memory and then embeds it verbatim into the gRPC status message. This makes the returned error unbounded in size (potentially causing high memory usage and/or exceeding gRPC message/log size limits). Consider truncating the captured output (e.g., last N KB/lines) and/or logging full output separately, and only including a bounded summary in the returned error message.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error formatting always adds a newline and string(output), even when the command produced no output. This can result in noisy/odd error strings (trailing blank line). Consider conditionally appending the output only when it is non-empty (and trimming whitespace) so the error message stays clean.

Suggested change
return status.Errorf(codes.Internal, "kubeadm join: %s\n%s", err, string(output))
trimmedOutput := strings.TrimSpace(string(output))
if trimmedOutput != "" {
return status.Errorf(codes.Internal, "kubeadm join: %s\n%s", err, trimmedOutput)
}
return status.Errorf(codes.Internal, "kubeadm join: %s", err)

Copilot uses AI. Check for mistakes.
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions components/kubeadm/v20260301/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ func (n *nodeResetAction) runReset(ctx context.Context) error {
// --force skips the interactive confirmation prompt and proceeds even
// when the node is unreachable by the control plane.
// -v 5 provides verbose output for debugging.
if err := utilexec.New().CommandContext(
if output, err := utilexec.New().CommandContext(
ctx, kubeadmBinary, "reset", "--force", "-v", "5",
).Run(); err != nil {
return status.Errorf(codes.Internal, "kubeadm reset: %s", err)
).CombinedOutput(); err != nil {
return status.Errorf(codes.Internal, "kubeadm reset: %s\n%s", err, string(output))
Comment on lines +78 to +81
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CombinedOutput() captures the full kubeadm output into memory and then returns it in the gRPC error. Since kubeadm can be quite verbose (especially with -v 5), this can cause large allocations and very large error payloads/log lines. Consider bounding/truncating the output and/or emitting the full output to logs instead of returning it verbatim.

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +81
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The returned error string always includes a newline plus string(output), even if output is empty. Consider only appending trimmed output when it is non-empty to avoid trailing blank lines in the error message.

Copilot uses AI. Check for mistakes.
}

return nil
Expand Down
Loading