From 781675ddcf6f1138d697cb9c71dae484daa0548b Mon Sep 17 00:00:00 2001 From: wangxiang Date: Mon, 6 Mar 2023 01:35:46 +0800 Subject: [PATCH] fix: added logs related to executing commands in the container (#10530) Signed-off-by: scott --- workflow/common/util.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/workflow/common/util.go b/workflow/common/util.go index 5f1713d38661..f9ee45beadcf 100644 --- a/workflow/common/util.go +++ b/workflow/common/util.go @@ -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) @@ -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) }