Change:
// Populate global DefaultFeatureGate with value from TestContext.FeatureGates. // This way, statically-linked components see the same feature gate config as the test context. utilconfig.DefaultFeatureGate.Set(framework.TestContext.FeatureGates) <del> e := newE2EService() </del> <ins> e := newE2EServices() </ins> if err := e.run(); err != nil { glog.Fatalf("Failed to run e2e services: %v", err) } } <del> // Ports of different e2e services. </del> const ( <del> kubeletPort         = "10250" kubeletReadOnlyPort = "10255" ) // Health check urls of different e2e services. var ( kubeletHealthCheckURL = getEndpoint(kubeletReadOnlyPort) + "/healthz" ) // getEndpoint generates endpoint url from service port. func getEndpoint(port string) string { return "http://127.0.0.1:" + port } func getHealthCheckURLs() []string { return []string{ getEtcdHealthCheckURL(), getAPIServerHealthCheckURL(), kubeletHealthCheckURL, } } // e2eService manages e2e services in current process. type e2eService struct { services []*server rmDirs   []string logFiles map[string]logFileData // statically linked e2e services etcdServer   *EtcdServer apiServer    *APIServer nsController *NamespaceController } // logFileData holds data about logfiles to fetch with a journalctl command or // symlink from a node's file system. type logFileData struct { files             []string journalctlCommand []string } const ( // This is consistent with the level used in a cluster e2e test. </del> <ins> // services.log is the combined log of all services servicesLogFile = "services.log" // LOG_VERBOSITY_LEVEL is consistent with the level used in a cluster e2e test. </ins> LOG_VERBOSITY_LEVEL = "4" ) <del> func newE2EService() *e2eService { // Special log files that need to be collected for additional debugging. var logFiles = map[string]logFileData{ "kern.log":       {[]string{"/var/log/kern.log"}, []string{"-k"}}, "docker.log":     {[]string{"/var/log/docker.log", "/var/log/upstart/docker.log"}, []string{"-u", "docker"}}, "cloud-init.log": {[]string{"/var/log/cloud-init.log"}, []string{"-u", "cloud*"}}, } return &e2eService{logFiles: logFiles} } // terminationSignals are signals that cause the program to exit in the // supported platforms (linux, darwin, windows). var terminationSignals = []os.Signal{syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT} // run starts all e2e services and wait for the termination signal. Once receives the // termination signal, it will stop the e2e services gracefully. func (es *e2eService) run() error { defer es.stop() if err := es.start(); err != nil { return err } // Wait until receiving a termination signal. sig := make(chan os.Signal, 1) signal.Notify(sig, terminationSignals...) <-sig return nil } // start starts the tests embedded services or returns an error. func (es *e2eService) start() error { glog.Info("Starting e2e services...") err := es.startEtcd() if err != nil { return err } err = es.startApiServer() if err != nil { return err } s, err := es.startKubelet() if err != nil { return err } es.services = append(es.services, s) err = es.startNamespaceController() if err != nil { return nil } glog.Info("E2E services started.") return nil } // getLogFiles gets logs of interest either via journalctl or by creating sym // links. Since we scp files from the remote directory, symlinks will be // treated as normal files and file contents will be copied over. func (es *e2eService) getLogFiles() { // Nothing to do if report dir is not specified. if framework.TestContext.ReportDir == "" { return } glog.Info("Fetching log files...") journaldFound := isJournaldAvailable() for targetFileName, logFileData := range es.logFiles { targetLink := path.Join(framework.TestContext.ReportDir, targetFileName) if journaldFound { // Skip log files that do not have an equivalent in journald-based machines. if len(logFileData.journalctlCommand) == 0 { continue } glog.Infof("Get log file %q with journalctl command %v.", targetFileName, logFileData.journalctlCommand) out, err := exec.Command("sudo", append([]string{"journalctl"}, logFileData.journalctlCommand...)...).CombinedOutput() if err != nil { glog.Errorf("failed to get %q from journald: %v, %v", targetFileName, string(out), err) } else { if err = ioutil.WriteFile(targetLink, out, 0644); err != nil { glog.Errorf("failed to write logs to %q: %v", targetLink, err) } } continue } for _, file := range logFileData.files { if _, err := os.Stat(file); err != nil { // Expected file not found on this distro. continue } if err := copyLogFile(file, targetLink); err != nil { glog.Error(err) } else { break } } } } // stop stops the embedded e2e services. func (es *e2eService) stop() { glog.Info("Stopping e2e services...") es.getLogFiles() // TODO(random-liu): Use a loop to stop all services after introducing // service interface. glog.Info("Stopping namespace controller") if es.nsController != nil { if err := es.nsController.Stop(); err != nil { glog.Errorf("Failed to stop %q: %v", es.nsController.Name(), err) } } glog.Info("Stopping API server") if es.apiServer != nil { if err := es.apiServer.Stop(); err != nil { glog.Errorf("Failed to stop %q: %v", es.apiServer.Name(), err) } } for _, s := range es.services { glog.Info("Stopping service %q", s.name) if err := s.kill(); err != nil { glog.Errorf("Failed to stop %v: %v", s.name, err) } } glog.Info("Stopping etcd") if es.etcdServer != nil { if err := es.etcdServer.Stop(); err != nil { glog.Errorf("Failed to stop %q: %v", es.etcdServer.Name(), err) } } for _, d := range es.rmDirs { glog.Info("Deleting directory %v", d) err := os.RemoveAll(d) if err != nil { glog.Errorf("Failed to delete directory %s.n%v", d, err) } } glog.Info("E2E services stopped.") } // startEtcd starts the embedded etcd instance or returns an error. func (es *e2eService) startEtcd() error { glog.Info("Starting etcd") dataDir, err := ioutil.TempDir("", "node-e2e") </del> <ins> // startInternalServices starts the internal services in a separate process. func (e *E2EServices) startInternalServices() (*server, error) { testBin, err := osext.Executable() </ins> if err != nil { <del> return err </del> <ins> return nil, fmt.Errorf("can't get current binary: %v", err) </ins> } <del> // Mark the dataDir as directories to remove. es.rmDirs = append(es.rmDirs, dataDir) es.etcdServer = NewEtcd(dataDir) return es.etcdServer.Start() } // startApiServer starts the embedded API server or returns an error. func (es *e2eService) startApiServer() error { glog.Info("Starting API server") es.apiServer = NewAPIServer() return es.apiServer.Start() </del> <ins> startCmd := exec.Command("sudo", testBin, // TODO(mtaufen): Flags e.g. that target the TestContext need to be manually forwarded to the //                test binary when we start it up in run-services mode. This is not ideal. //                Very unintuitive because it prevents any flags NOT manually forwarded here //                from being set via TEST_ARGS when running tests from the command line. "--run-services-mode", "--server-start-timeout", serverStartTimeout.String(), "--feature-gates", framework.TestContext.FeatureGates, "--logtostderr", "--vmodule=*="+LOG_VERBOSITY_LEVEL, ) server := newServer("services", startCmd, nil, nil, getServicesHealthCheckURLs(), servicesLogFile, e.monitorParent, false) return server, server.start() </ins> } <del> // startNamespaceController starts the embedded namespace controller or returns an error. func (es *e2eService) startNamespaceController() error { glog.Info("Starting namespace controller") es.nsController = NewNamespaceController() return es.nsController.Start() } </del> <ins> const ( // Ports of different e2e services. kubeletPort         = "10250" kubeletReadOnlyPort = "10255" // Health check url of kubelet kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz" ) </ins> // startKubelet starts the Kubelet in a separate process or returns an error // if the Kubelet fails to start. <del> func (es *e2eService) startKubelet() (*server, error) { </del> <ins> func (e *E2EServices) startKubelet() (*server, error) { </ins> glog.Info("Starting kubelet") var killCommand, restartCommand *exec.Cmd cmdArgs := []string{}

Discussion:
In node e2e, we have the option to keep the services running after test for further debug. However, we set to for the services, which means that once the parent exits, they will receive and exit with the parent if they don't trap the signal. With this, option will never work. If we still need this feature, we should not set if is false. /cc
We still need this feature. It helps with debugging test failures by keeping all the daemons running upon failure. , Lantao Liu wrote: