mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Add the monitorParent option when starting services, and set
monitorParent to false when stop-services=false.
This commit is contained in:
parent
0d3befd7ea
commit
f501acebab
@ -114,7 +114,9 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||||||
maskLocksmithdOnCoreos()
|
maskLocksmithdOnCoreos()
|
||||||
|
|
||||||
if *startServices {
|
if *startServices {
|
||||||
e2es = services.NewE2EServices()
|
// If the services are expected to stop after test, they should monitor the test process.
|
||||||
|
// If the services are expected to keep running after test, they should not monitor the test process.
|
||||||
|
e2es = services.NewE2EServices(*stopServices)
|
||||||
Expect(e2es.Start()).To(Succeed(), "should be able to start node services.")
|
Expect(e2es.Start()).To(Succeed(), "should be able to start node services.")
|
||||||
glog.Infof("Node services started. Running tests...")
|
glog.Infof("Node services started. Running tests...")
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,6 +54,9 @@ type server struct {
|
|||||||
// outFilename is the name of the log file. The stdout and stderr of the server
|
// outFilename is the name of the log file. The stdout and stderr of the server
|
||||||
// will be redirected to this file.
|
// will be redirected to this file.
|
||||||
outFilename string
|
outFilename string
|
||||||
|
// monitorParent determines whether the server should watch its parent process and exit
|
||||||
|
// if its parent is gone.
|
||||||
|
monitorParent bool
|
||||||
// restartOnExit determines whether a restart loop is launched with the server
|
// restartOnExit determines whether a restart loop is launched with the server
|
||||||
restartOnExit bool
|
restartOnExit bool
|
||||||
// Writing to this channel, if it is not nil, stops the restart loop.
|
// Writing to this channel, if it is not nil, stops the restart loop.
|
||||||
@ -65,7 +68,7 @@ type server struct {
|
|||||||
|
|
||||||
// newServer returns a new server with the given name, commands, health check
|
// newServer returns a new server with the given name, commands, health check
|
||||||
// URLs, etc.
|
// URLs, etc.
|
||||||
func newServer(name string, start, kill, restart *exec.Cmd, urls []string, outputFileName string, restartOnExit bool) *server {
|
func newServer(name string, start, kill, restart *exec.Cmd, urls []string, outputFileName string, monitorParent, restartOnExit bool) *server {
|
||||||
return &server{
|
return &server{
|
||||||
name: name,
|
name: name,
|
||||||
startCommand: start,
|
startCommand: start,
|
||||||
@ -73,6 +76,7 @@ func newServer(name string, start, kill, restart *exec.Cmd, urls []string, outpu
|
|||||||
restartCommand: restart,
|
restartCommand: restart,
|
||||||
healthCheckUrls: urls,
|
healthCheckUrls: urls,
|
||||||
outFilename: outputFileName,
|
outFilename: outputFileName,
|
||||||
|
monitorParent: monitorParent,
|
||||||
restartOnExit: restartOnExit,
|
restartOnExit: restartOnExit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,6 +181,8 @@ func (s *server) start() error {
|
|||||||
s.startCommand.Stdout = outfile
|
s.startCommand.Stdout = outfile
|
||||||
s.startCommand.Stderr = outfile
|
s.startCommand.Stderr = outfile
|
||||||
|
|
||||||
|
// If monitorParent is set, set Pdeathsig when starting the server.
|
||||||
|
if s.monitorParent {
|
||||||
// Death of this test process should kill the server as well.
|
// Death of this test process should kill the server as well.
|
||||||
attrs := &syscall.SysProcAttr{}
|
attrs := &syscall.SysProcAttr{}
|
||||||
// Hack to set linux-only field without build tags.
|
// Hack to set linux-only field without build tags.
|
||||||
@ -188,6 +194,7 @@ func (s *server) start() error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.startCommand.SysProcAttr = attrs
|
s.startCommand.SysProcAttr = attrs
|
||||||
|
}
|
||||||
|
|
||||||
// Start the command
|
// Start the command
|
||||||
err = s.startCommand.Start()
|
err = s.startCommand.Start()
|
||||||
|
@ -37,6 +37,9 @@ import (
|
|||||||
// E2EServices starts and stops e2e services in a separate process. The test
|
// E2EServices starts and stops e2e services in a separate process. The test
|
||||||
// uses it to start and stop all e2e services.
|
// uses it to start and stop all e2e services.
|
||||||
type E2EServices struct {
|
type E2EServices struct {
|
||||||
|
// monitorParent determines whether the sub-processes should watch and die with the current
|
||||||
|
// process.
|
||||||
|
monitorParent bool
|
||||||
services *server
|
services *server
|
||||||
kubelet *server
|
kubelet *server
|
||||||
logFiles map[string]logFileData
|
logFiles map[string]logFileData
|
||||||
@ -50,8 +53,9 @@ type logFileData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewE2EServices returns a new E2EServices instance.
|
// NewE2EServices returns a new E2EServices instance.
|
||||||
func NewE2EServices() *E2EServices {
|
func NewE2EServices(monitorParent bool) *E2EServices {
|
||||||
return &E2EServices{
|
return &E2EServices{
|
||||||
|
monitorParent: monitorParent,
|
||||||
// Special log files that need to be collected for additional debugging.
|
// Special log files that need to be collected for additional debugging.
|
||||||
logFiles: map[string]logFileData{
|
logFiles: map[string]logFileData{
|
||||||
"kern.log": {[]string{"/var/log/kern.log"}, []string{"-k"}},
|
"kern.log": {[]string{"/var/log/kern.log"}, []string{"-k"}},
|
||||||
@ -151,7 +155,7 @@ func (e *E2EServices) startInternalServices() (*server, error) {
|
|||||||
"--logtostderr",
|
"--logtostderr",
|
||||||
"--vmodule=*="+LOG_VERBOSITY_LEVEL,
|
"--vmodule=*="+LOG_VERBOSITY_LEVEL,
|
||||||
)
|
)
|
||||||
server := newServer("services", startCmd, nil, nil, getServicesHealthCheckURLs(), servicesLogFile, false)
|
server := newServer("services", startCmd, nil, nil, getServicesHealthCheckURLs(), servicesLogFile, e.monitorParent, false)
|
||||||
return server, server.start()
|
return server, server.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +210,6 @@ func (e *E2EServices) startKubelet() (*server, error) {
|
|||||||
"--eviction-hard", framework.TestContext.EvictionHard,
|
"--eviction-hard", framework.TestContext.EvictionHard,
|
||||||
"--eviction-pressure-transition-period", "30s",
|
"--eviction-pressure-transition-period", "30s",
|
||||||
"--feature-gates", framework.TestContext.FeatureGates,
|
"--feature-gates", framework.TestContext.FeatureGates,
|
||||||
"--runtime-integration-type", framework.TestContext.RuntimeIntegrationType,
|
|
||||||
"--v", LOG_VERBOSITY_LEVEL, "--logtostderr",
|
"--v", LOG_VERBOSITY_LEVEL, "--logtostderr",
|
||||||
)
|
)
|
||||||
if framework.TestContext.RuntimeIntegrationType != "" {
|
if framework.TestContext.RuntimeIntegrationType != "" {
|
||||||
@ -238,6 +241,7 @@ func (e *E2EServices) startKubelet() (*server, error) {
|
|||||||
restartCommand,
|
restartCommand,
|
||||||
[]string{kubeletHealthCheckURL},
|
[]string{kubeletHealthCheckURL},
|
||||||
"kubelet.log",
|
"kubelet.log",
|
||||||
|
e.monitorParent,
|
||||||
true /* restartOnExit */)
|
true /* restartOnExit */)
|
||||||
return server, server.start()
|
return server, server.start()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user