Skip to content

Commit

Permalink
fix: added logs related to executing commands in the container (#10530)
Browse files Browse the repository at this point in the history
Signed-off-by: scott <scottwangsxll@gmail.com>
  • Loading branch information
sxllwx authored and terrytangyuan committed Mar 29, 2023
1 parent ae06f85 commit 584998a
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 @@ -66,7 +66,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 @@ -87,7 +96,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 584998a

Please sign in to comment.