diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 832e51706bf..344601cb539 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -229,6 +229,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 900e009442e..5206167129c 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 44a7e33bac1..089620c3511 100644 --- a/test/e2e_node/services/kubelet.go +++ b/test/e2e_node/services/kubelet.go @@ -301,6 +301,7 @@ func (e *E2EServices) startKubelet() (*server, error) { } cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...) + restartOnExit := framework.TestContext.RestartKubelet server := newServer( "kubelet", cmd, @@ -309,7 +310,7 @@ func (e *E2EServices) startKubelet() (*server, error) { []string{kubeletHealthCheckURL}, "kubelet.log", e.monitorParent, - true /* restartOnExit */) + restartOnExit) return server, server.start() }