Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.17] OCPBUGS-44508: Show node-joiner container logs when error occurs #1912

Open
wants to merge 1 commit into
base: release-4.17
Choose a base branch
from
Open
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
16 changes: 7 additions & 9 deletions pkg/cli/admin/nodeimage/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,14 @@ func (o *CreateOptions) Run() error {
}

err = o.waitForCompletion(ctx)
if err != nil {
return err
}
// Something went wrong during the node-joiner tool execution,
// let's show the logs and return an error
if o.nodeJoinerExitCode != 0 {
err = o.printLogsInPod(ctx)
if err != nil {
return err
if err != nil || o.nodeJoinerExitCode != 0 {
printErr := o.printLogsInPod(ctx)
if printErr != nil {
return printErr
}
return fmt.Errorf("image generation error (exit code: %d)", o.nodeJoinerExitCode)
return fmt.Errorf("image generation error: %v (exit code: %d)", err, o.nodeJoinerExitCode)
}

err = o.copyArtifactsFromNodeJoinerPod()
Expand All @@ -315,6 +312,7 @@ func (o *CreateOptions) Run() error {
}

func (o *CreateOptions) printLogsInPod(ctx context.Context) error {
klog.V(1).Info("Printing pod logs")
logOptions := &corev1.PodLogOptions{
Container: nodeJoinerContainer,
Timestamps: true,
Expand Down Expand Up @@ -405,7 +403,7 @@ func (o *CreateOptions) waitForCompletion(ctx context.Context) error {
return wait.PollUntilContextTimeout(
ctx,
time.Second*5,
time.Minute*5,
time.Minute*15,
true,
func(ctx context.Context) (done bool, err error) {
w := &bytes.Buffer{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/admin/nodeimage/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestRun(t *testing.T) {
nodesConfig: defaultNodesConfigYaml,
objects: defaultClusterVersionObjectFn,
remoteExecOutput: "1",
expectedError: `image generation error (exit code: 1)`,
expectedError: `image generation error: <nil> (exit code: 1)`,
},
{
name: "node-joiner unsupported prior to 4.17",
Expand Down