mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
e2e storage: add logging to proxy
This is optional and can be used to capture the result of command execution in the log output.
This commit is contained in:
parent
5301d92150
commit
64731baffe
@ -20,6 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
"k8s.io/kubernetes/test/e2e/storage/drivers/csi-test/mock/service"
|
"k8s.io/kubernetes/test/e2e/storage/drivers/csi-test/mock/service"
|
||||||
@ -30,6 +31,7 @@ type PodDirIO struct {
|
|||||||
Namespace string
|
Namespace string
|
||||||
PodName string
|
PodName string
|
||||||
ContainerName string
|
ContainerName string
|
||||||
|
Logger *klog.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ service.DirIO = PodDirIO{}
|
var _ service.DirIO = PodDirIO{}
|
||||||
@ -88,7 +90,7 @@ func (p PodDirIO) RemoveAll(path string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p PodDirIO) execute(command []string, stdin io.Reader) (string, string, error) {
|
func (p PodDirIO) execute(command []string, stdin io.Reader) (string, string, error) {
|
||||||
return e2epod.ExecWithOptions(p.F, e2epod.ExecOptions{
|
stdout, stderr, err := e2epod.ExecWithOptions(framework.ExecOptions{
|
||||||
Command: command,
|
Command: command,
|
||||||
Namespace: p.Namespace,
|
Namespace: p.Namespace,
|
||||||
PodName: p.PodName,
|
PodName: p.PodName,
|
||||||
@ -98,4 +100,10 @@ func (p PodDirIO) execute(command []string, stdin io.Reader) (string, string, er
|
|||||||
CaptureStderr: true,
|
CaptureStderr: true,
|
||||||
Quiet: true,
|
Quiet: true,
|
||||||
})
|
})
|
||||||
|
if p.Logger != nil {
|
||||||
|
p.Logger.Info("Command completed", "command", command, "stdout", stdout, "stderr", stderr, "err", err)
|
||||||
|
|
||||||
|
}
|
||||||
|
return stdout, stderr, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user