From 00da68dbc25d9d12b05200b9207abc14dde71246 Mon Sep 17 00:00:00 2001 From: Amim Knabben Date: Wed, 2 Dec 2020 18:05:22 -0500 Subject: [PATCH] Adding restart kubelet flag on e2e test --- test/e2e/framework/test_context.go | 2 ++ test/e2e_node/e2e_node_suite_test.go | 1 + test/e2e_node/services/kubelet.go | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 82c4addc3aa..24ecf476345 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -221,6 +221,8 @@ type NodeTestContextType struct { // the node e2e test. If empty, the default one (system.DefaultSpec) is // used. The system specs are in test/e2e_node/system/specs/. SystemSpecName string + // RestartKubelet restarts Kubelet unit when the process is killed. + RestartKubelet bool // ExtraEnvs is a map of environment names to values. ExtraEnvs map[string]string } diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/e2e_node/e2e_node_suite_test.go index c9eb85332fb..5f304fd7270 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/e2e_node/e2e_node_suite_test.go @@ -80,6 +80,7 @@ func registerNodeFlags(flags *flag.FlagSet) { // It is hard and unnecessary to deal with the complexity inside the test suite. flags.BoolVar(&framework.TestContext.NodeConformance, "conformance", false, "If true, the test suite will not start kubelet, and fetch system log (kernel, docker, kubelet log etc.) to the report directory.") flags.BoolVar(&framework.TestContext.PrepullImages, "prepull-images", true, "If true, prepull images so image pull failures do not cause test failures.") + flags.BoolVar(&framework.TestContext.RestartKubelet, "restart-kubelet", true, "If true, restart Kubelet unit when the process is killed.") flags.StringVar(&framework.TestContext.ImageDescription, "image-description", "", "The description of the image which the test will be running on.") flags.StringVar(&framework.TestContext.SystemSpecName, "system-spec-name", "", "The name of the system spec (e.g., gke) that's used in the node e2e test. The system specs are in test/e2e_node/system/specs/. This is used by the test framework to determine which tests to run for validating the system requirements.") flags.Var(cliflag.NewMapStringString(&framework.TestContext.ExtraEnvs), "extra-envs", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2") diff --git a/test/e2e_node/services/kubelet.go b/test/e2e_node/services/kubelet.go index 5327f357b25..42527ef3adf 100644 --- a/test/e2e_node/services/kubelet.go +++ b/test/e2e_node/services/kubelet.go @@ -302,6 +302,7 @@ func (e *E2EServices) startKubelet() (*server, error) { } cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...) + restartOnExit := framework.TestContext.RestartKubelet server := newServer( "kubelet", cmd, @@ -310,7 +311,7 @@ func (e *E2EServices) startKubelet() (*server, error) { []string{kubeletHealthCheckURL}, "kubelet.log", e.monitorParent, - true /* restartOnExit */) + restartOnExit) return server, server.start() }