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

docker: fix script check execution #24098

Merged
merged 1 commit into from
Oct 1, 2024
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
12 changes: 3 additions & 9 deletions drivers/docker/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,11 @@ func (h *taskHandle) Exec(ctx context.Context, cmd string, args []string) (*driv
Detach: false,
Tty: false,
}
if err := h.dockerClient.ContainerExecStart(ctx, exec.ID, startOpts); err != nil {
return nil, err
}

// hijack exec output streams
hijacked, err := h.dockerClient.ContainerExecAttach(ctx, exec.ID, containerapi.ExecStartOptions{
Detach: false,
Tty: false,
})
hijacked, err := h.dockerClient.ContainerExecAttach(ctx, exec.ID, startOpts)
if err != nil {
return nil, fmt.Errorf("failed to attach to exec: %v", err)
return nil, fmt.Errorf("failed to attach to exec object: %w", err)
}

_, err = stdcopy.StdCopy(stdout, stderr, hijacked.Reader)
Expand All @@ -128,7 +122,7 @@ func (h *taskHandle) Exec(ctx context.Context, cmd string, args []string) (*driv
execResult.Stderr = stderr.Bytes()
res, err := h.dockerClient.ContainerExecInspect(ctx, exec.ID)
if err != nil {
return execResult, err
return execResult, fmt.Errorf("failed to inspect exit code of exec object: %w", err)
}

execResult.ExitResult.ExitCode = res.ExitCode
Expand Down
2 changes: 0 additions & 2 deletions e2e/consul/input/on_update_check_restart.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ job "test" {
on_update = "ignore_warnings"

args = [
"-c",
Copy link
Member Author

Choose a reason for hiding this comment

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

This was causing the wrong error code because -c means "run this script literal", not "run this script file".

"/local/ready.sh"
]

Expand Down Expand Up @@ -95,4 +94,3 @@ EOT
}
}
}