Skip to content

Commit

Permalink
fix: added logs related to executing commands in the container (argop…
Browse files Browse the repository at this point in the history
…roj#10530)

Signed-off-by: scott <scottwangsxll@gmail.com>
  • Loading branch information
sxllwx authored Mar 5, 2023
1 parent f29a9ee commit 781675d
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit 781675d

Please sign in to comment.