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

fix: added logs related to executing commands in the container #10530

Merged
merged 1 commit into from
Mar 5, 2023
Merged
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
13 changes: 11 additions & 2 deletions workflow/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ func (d *WebsocketRoundTripper) RoundTrip(r *http.Request) (*http.Response, erro
}

// ExecPodContainer runs a command in a container in a pod and returns the remotecommand.Executor
func ExecPodContainer(restConfig *rest.Config, namespace string, pod string, container string, stdout bool, stderr bool, command ...string) (remotecommand.Executor, error) {
func ExecPodContainer(restConfig *rest.Config, namespace string, pod string, container string, stdout bool, stderr bool, command ...string) (exec remotecommand.Executor, err error) {
defer func() {
log.WithField("namespace", namespace).
WithField("pod", pod).
WithField("container", container).
WithField("command", command).
WithError(err).
Debug("exec container command")
}()

clientset, err := kubernetes.NewForConfig(restConfig)
if err != nil {
return nil, errors.InternalWrapError(err)
Expand All @@ -81,7 +90,7 @@ func ExecPodContainer(restConfig *rest.Config, namespace string, pod string, con
}

log.Info(execRequest.URL())
exec, err := remotecommand.NewSPDYExecutor(restConfig, "POST", execRequest.URL())
exec, err = remotecommand.NewSPDYExecutor(restConfig, "POST", execRequest.URL())
if err != nil {
return nil, errors.InternalWrapError(err)
}
Expand Down