Unverified Commit 74ec8d0f authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #55288 from Random-Liu/e2e-log-for-alternative-runtime

Automatic merge from submit-queue (batch tested with PRs 55283, 55461, 55288, 53970, 55487). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Support collecting log for alternative container runtime in e2e test. Fixes https://github.com/kubernetes/kubernetes/issues/55629. Add support to collect logs for alternative container runtime in e2e. Example for `cri-containerd`: ``` $ go run hack/e2e.go -- --test -v --test_args="--report-dir=$PWD --container-runtime-services=cri-containerd,containerd,cri-containerd-installation" ``` ```release-note none ``` /cc @kubernetes/sig-node-pr-reviews @kubernetes/sig-testing-pr-reviews
parents 14674f45 32c4295b
...@@ -50,7 +50,7 @@ readonly gce_logfiles="startupscript" ...@@ -50,7 +50,7 @@ readonly gce_logfiles="startupscript"
readonly kern_logfile="kern" readonly kern_logfile="kern"
readonly initd_logfiles="docker" readonly initd_logfiles="docker"
readonly supervisord_logfiles="kubelet supervisor/supervisord supervisor/kubelet-stdout supervisor/kubelet-stderr supervisor/docker-stdout supervisor/docker-stderr" readonly supervisord_logfiles="kubelet supervisor/supervisord supervisor/kubelet-stdout supervisor/kubelet-stderr supervisor/docker-stdout supervisor/docker-stderr"
readonly systemd_services="kubelet docker" readonly systemd_services="kubelet ${SYSTEMD_SERVICES:-docker}"
# Limit the number of concurrent node connections so that we don't run out of # Limit the number of concurrent node connections so that we don't run out of
# file descriptors for large clusters. # file descriptors for large clusters.
......
...@@ -65,6 +65,9 @@ type TestContextType struct { ...@@ -65,6 +65,9 @@ type TestContextType struct {
GCEUpgradeScript string GCEUpgradeScript string
ContainerRuntime string ContainerRuntime string
ContainerRuntimeEndpoint string ContainerRuntimeEndpoint string
// SystemdServices are comma separated list of systemd services the test framework
// will dump logs for.
SystemdServices string
ImageServiceEndpoint string ImageServiceEndpoint string
MasterOSDistro string MasterOSDistro string
NodeOSDistro string NodeOSDistro string
...@@ -201,6 +204,7 @@ func RegisterCommonFlags() { ...@@ -201,6 +204,7 @@ func RegisterCommonFlags() {
flag.StringVar(&TestContext.Viper, "viper-config", "e2e", "The name of the viper config i.e. 'e2e' will read values from 'e2e.json' locally. All e2e parameters are meant to be configurable by viper.") flag.StringVar(&TestContext.Viper, "viper-config", "e2e", "The name of the viper config i.e. 'e2e' will read values from 'e2e.json' locally. All e2e parameters are meant to be configurable by viper.")
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker/rkt/remote).") flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker/rkt/remote).")
flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "", "The container runtime endpoint of cluster VM instances.") flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "", "The container runtime endpoint of cluster VM instances.")
flag.StringVar(&TestContext.SystemdServices, "systemd-services", "docker", "The comma separated list of systemd services the framework will dump logs for.")
flag.StringVar(&TestContext.ImageServiceEndpoint, "image-service-endpoint", "", "The image service endpoint of cluster VM instances.") flag.StringVar(&TestContext.ImageServiceEndpoint, "image-service-endpoint", "", "The image service endpoint of cluster VM instances.")
flag.StringVar(&TestContext.DockershimCheckpointDir, "dockershim-checkpoint-dir", "/var/lib/dockershim/sandbox", "The directory for dockershim to store sandbox checkpoints.") flag.StringVar(&TestContext.DockershimCheckpointDir, "dockershim-checkpoint-dir", "/var/lib/dockershim/sandbox", "The directory for dockershim to store sandbox checkpoints.")
flag.StringVar(&TestContext.KubernetesAnywherePath, "kubernetes-anywhere-path", "/workspace/kubernetes-anywhere", "Which directory kubernetes-anywhere is installed to.") flag.StringVar(&TestContext.KubernetesAnywherePath, "kubernetes-anywhere-path", "/workspace/kubernetes-anywhere", "Which directory kubernetes-anywhere is installed to.")
......
...@@ -4560,6 +4560,7 @@ func CoreDump(dir string) { ...@@ -4560,6 +4560,7 @@ func CoreDump(dir string) {
Logf("Dumping logs locally to: %s", dir) Logf("Dumping logs locally to: %s", dir)
cmd = exec.Command(path.Join(TestContext.RepoRoot, "cluster", "log-dump", "log-dump.sh"), dir) cmd = exec.Command(path.Join(TestContext.RepoRoot, "cluster", "log-dump", "log-dump.sh"), dir)
} }
cmd.Env = append(os.Environ(), fmt.Sprintf("SYSTEMD_SERVICES=%s", parseSystemdServices(TestContext.SystemdServices)))
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
...@@ -4567,6 +4568,11 @@ func CoreDump(dir string) { ...@@ -4567,6 +4568,11 @@ func CoreDump(dir string) {
} }
} }
// parseSystemdServices converts services separator from comma to space.
func parseSystemdServices(services string) string {
return strings.TrimSpace(strings.Replace(services, ",", " ", -1))
}
func UpdatePodWithRetries(client clientset.Interface, ns, name string, update func(*v1.Pod)) (*v1.Pod, error) { func UpdatePodWithRetries(client clientset.Interface, ns, name string, update func(*v1.Pod)) (*v1.Pod, error) {
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
pod, err := client.CoreV1().Pods(ns).Get(name, metav1.GetOptions{}) pod, err := client.CoreV1().Pods(ns).Get(name, metav1.GetOptions{})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment