mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
executor,scheduler: make launchGracePeriod configurable
This commit is contained in:
parent
719cf5617e
commit
42c84954fd
@ -26,4 +26,5 @@ const (
|
|||||||
DefaultInfoSource = "kubernetes"
|
DefaultInfoSource = "kubernetes"
|
||||||
DefaultInfoName = "Kubelet-Executor"
|
DefaultInfoName = "Kubelet-Executor"
|
||||||
DefaultSuicideTimeout = 20 * time.Minute
|
DefaultSuicideTimeout = 20 * time.Minute
|
||||||
|
DefaultLaunchGracePeriod = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
@ -47,7 +47,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
containerPollTime = 1 * time.Second
|
containerPollTime = 1 * time.Second
|
||||||
launchGracePeriod = 5 * time.Minute
|
|
||||||
podRelistPeriod = 5 * time.Minute
|
podRelistPeriod = 5 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -123,6 +122,7 @@ type KubernetesExecutor struct {
|
|||||||
staticPodsConfigPath string
|
staticPodsConfigPath string
|
||||||
initialRegComplete chan struct{}
|
initialRegComplete chan struct{}
|
||||||
podController *framework.Controller
|
podController *framework.Controller
|
||||||
|
launchGracePeriod time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -138,6 +138,7 @@ type Config struct {
|
|||||||
PodStatusFunc func(KubeletInterface, *api.Pod) (*api.PodStatus, error)
|
PodStatusFunc func(KubeletInterface, *api.Pod) (*api.PodStatus, error)
|
||||||
StaticPodsConfigPath string
|
StaticPodsConfigPath string
|
||||||
PodLW cache.ListerWatcher
|
PodLW cache.ListerWatcher
|
||||||
|
LaunchGracePeriod time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *KubernetesExecutor) isConnected() bool {
|
func (k *KubernetesExecutor) isConnected() bool {
|
||||||
@ -165,6 +166,7 @@ func New(config Config) *KubernetesExecutor {
|
|||||||
podStatusFunc: config.PodStatusFunc,
|
podStatusFunc: config.PodStatusFunc,
|
||||||
initialRegComplete: make(chan struct{}),
|
initialRegComplete: make(chan struct{}),
|
||||||
staticPodsConfigPath: config.StaticPodsConfigPath,
|
staticPodsConfigPath: config.StaticPodsConfigPath,
|
||||||
|
launchGracePeriod: config.LaunchGracePeriod,
|
||||||
}
|
}
|
||||||
|
|
||||||
// watch pods from the given pod ListWatch
|
// watch pods from the given pod ListWatch
|
||||||
@ -594,7 +596,10 @@ func (k *KubernetesExecutor) launchTask(driver bindings.ExecutorDriver, taskId s
|
|||||||
func (k *KubernetesExecutor) _launchTask(driver bindings.ExecutorDriver, taskId, podFullName string, psf podStatusFunc) {
|
func (k *KubernetesExecutor) _launchTask(driver bindings.ExecutorDriver, taskId, podFullName string, psf podStatusFunc) {
|
||||||
|
|
||||||
expired := make(chan struct{})
|
expired := make(chan struct{})
|
||||||
time.AfterFunc(launchGracePeriod, func() { close(expired) })
|
|
||||||
|
if k.launchGracePeriod > 0 {
|
||||||
|
time.AfterFunc(k.launchGracePeriod, func() { close(expired) })
|
||||||
|
}
|
||||||
|
|
||||||
getMarshalledInfo := func() (data []byte, cancel bool) {
|
getMarshalledInfo := func() (data []byte, cancel bool) {
|
||||||
// potentially long call..
|
// potentially long call..
|
||||||
@ -633,7 +638,7 @@ waitForRunningPod:
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-expired:
|
case <-expired:
|
||||||
log.Warningf("Launch expired grace period of '%v'", launchGracePeriod)
|
log.Warningf("Launch expired grace period of '%v'", k.launchGracePeriod)
|
||||||
break waitForRunningPod
|
break waitForRunningPod
|
||||||
case <-time.After(containerPollTime):
|
case <-time.After(containerPollTime):
|
||||||
if data, cancel := getMarshalledInfo(); cancel {
|
if data, cancel := getMarshalledInfo(); cancel {
|
||||||
|
@ -59,12 +59,14 @@ const (
|
|||||||
type KubeletExecutorServer struct {
|
type KubeletExecutorServer struct {
|
||||||
*app.KubeletServer
|
*app.KubeletServer
|
||||||
SuicideTimeout time.Duration
|
SuicideTimeout time.Duration
|
||||||
|
LaunchGracePeriod time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKubeletExecutorServer() *KubeletExecutorServer {
|
func NewKubeletExecutorServer() *KubeletExecutorServer {
|
||||||
k := &KubeletExecutorServer{
|
k := &KubeletExecutorServer{
|
||||||
KubeletServer: app.NewKubeletServer(),
|
KubeletServer: app.NewKubeletServer(),
|
||||||
SuicideTimeout: config.DefaultSuicideTimeout,
|
SuicideTimeout: config.DefaultSuicideTimeout,
|
||||||
|
LaunchGracePeriod: config.DefaultLaunchGracePeriod,
|
||||||
}
|
}
|
||||||
if pwd, err := os.Getwd(); err != nil {
|
if pwd, err := os.Getwd(); err != nil {
|
||||||
log.Warningf("failed to determine current directory: %v", err)
|
log.Warningf("failed to determine current directory: %v", err)
|
||||||
@ -79,6 +81,7 @@ func NewKubeletExecutorServer() *KubeletExecutorServer {
|
|||||||
func (s *KubeletExecutorServer) AddFlags(fs *pflag.FlagSet) {
|
func (s *KubeletExecutorServer) AddFlags(fs *pflag.FlagSet) {
|
||||||
s.KubeletServer.AddFlags(fs)
|
s.KubeletServer.AddFlags(fs)
|
||||||
fs.DurationVar(&s.SuicideTimeout, "suicide-timeout", s.SuicideTimeout, "Self-terminate after this period of inactivity. Zero disables suicide watch.")
|
fs.DurationVar(&s.SuicideTimeout, "suicide-timeout", s.SuicideTimeout, "Self-terminate after this period of inactivity. Zero disables suicide watch.")
|
||||||
|
fs.DurationVar(&s.LaunchGracePeriod, "mesos-launch-grace-period", s.LaunchGracePeriod, "Launch grace period after which launching tasks will be cancelled. Zero disables launch cancellation.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run runs the specified KubeletExecutorServer.
|
// Run runs the specified KubeletExecutorServer.
|
||||||
@ -336,6 +339,7 @@ func (ks *KubeletExecutorServer) createAndInitKubelet(
|
|||||||
APIClient: kc.KubeClient,
|
APIClient: kc.KubeClient,
|
||||||
Docker: kc.DockerClient,
|
Docker: kc.DockerClient,
|
||||||
SuicideTimeout: ks.SuicideTimeout,
|
SuicideTimeout: ks.SuicideTimeout,
|
||||||
|
LaunchGracePeriod: ks.LaunchGracePeriod,
|
||||||
KubeletFinished: kubeletFinished,
|
KubeletFinished: kubeletFinished,
|
||||||
ExitFunc: os.Exit,
|
ExitFunc: os.Exit,
|
||||||
PodStatusFunc: func(_ executor.KubeletInterface, pod *api.Pod) (*api.PodStatus, error) {
|
PodStatusFunc: func(_ executor.KubeletInterface, pod *api.Pod) (*api.PodStatus, error) {
|
||||||
|
@ -109,6 +109,7 @@ type SchedulerServer struct {
|
|||||||
ExecutorLogV int
|
ExecutorLogV int
|
||||||
ExecutorBindall bool
|
ExecutorBindall bool
|
||||||
ExecutorSuicideTimeout time.Duration
|
ExecutorSuicideTimeout time.Duration
|
||||||
|
LaunchGracePeriod time.Duration
|
||||||
|
|
||||||
RunProxy bool
|
RunProxy bool
|
||||||
ProxyBindall bool
|
ProxyBindall bool
|
||||||
@ -173,6 +174,7 @@ func NewSchedulerServer() *SchedulerServer {
|
|||||||
|
|
||||||
RunProxy: true,
|
RunProxy: true,
|
||||||
ExecutorSuicideTimeout: execcfg.DefaultSuicideTimeout,
|
ExecutorSuicideTimeout: execcfg.DefaultSuicideTimeout,
|
||||||
|
LaunchGracePeriod: execcfg.DefaultLaunchGracePeriod,
|
||||||
DefaultContainerCPULimit: mresource.DefaultDefaultContainerCPULimit,
|
DefaultContainerCPULimit: mresource.DefaultDefaultContainerCPULimit,
|
||||||
DefaultContainerMemLimit: mresource.DefaultDefaultContainerMemLimit,
|
DefaultContainerMemLimit: mresource.DefaultDefaultContainerMemLimit,
|
||||||
|
|
||||||
@ -255,6 +257,7 @@ func (s *SchedulerServer) addCoreFlags(fs *pflag.FlagSet) {
|
|||||||
fs.IntVar(&s.ExecutorLogV, "executor-logv", s.ExecutorLogV, "Logging verbosity of spawned minion and executor processes.")
|
fs.IntVar(&s.ExecutorLogV, "executor-logv", s.ExecutorLogV, "Logging verbosity of spawned minion and executor processes.")
|
||||||
fs.BoolVar(&s.ExecutorBindall, "executor-bindall", s.ExecutorBindall, "When true will set -address of the executor to 0.0.0.0.")
|
fs.BoolVar(&s.ExecutorBindall, "executor-bindall", s.ExecutorBindall, "When true will set -address of the executor to 0.0.0.0.")
|
||||||
fs.DurationVar(&s.ExecutorSuicideTimeout, "executor-suicide-timeout", s.ExecutorSuicideTimeout, "Executor self-terminates after this period of inactivity. Zero disables suicide watch.")
|
fs.DurationVar(&s.ExecutorSuicideTimeout, "executor-suicide-timeout", s.ExecutorSuicideTimeout, "Executor self-terminates after this period of inactivity. Zero disables suicide watch.")
|
||||||
|
fs.DurationVar(&s.LaunchGracePeriod, "mesos-launch-grace-period", s.LaunchGracePeriod, "Launch grace period after which launching tasks will be cancelled. Zero disables launch cancellation.")
|
||||||
|
|
||||||
fs.BoolVar(&s.ProxyBindall, "proxy-bindall", s.ProxyBindall, "When true pass -proxy-bindall to the executor.")
|
fs.BoolVar(&s.ProxyBindall, "proxy-bindall", s.ProxyBindall, "When true pass -proxy-bindall to the executor.")
|
||||||
fs.BoolVar(&s.RunProxy, "run-proxy", s.RunProxy, "Run the kube-proxy as a side process of the executor.")
|
fs.BoolVar(&s.RunProxy, "run-proxy", s.RunProxy, "Run the kube-proxy as a side process of the executor.")
|
||||||
@ -376,6 +379,7 @@ func (s *SchedulerServer) prepareExecutorInfo(hks hyperkube.Interface) (*mesos.E
|
|||||||
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--v=%d", s.ExecutorLogV)) // this also applies to the minion
|
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--v=%d", s.ExecutorLogV)) // this also applies to the minion
|
||||||
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--allow-privileged=%t", s.AllowPrivileged))
|
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--allow-privileged=%t", s.AllowPrivileged))
|
||||||
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--suicide-timeout=%v", s.ExecutorSuicideTimeout))
|
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--suicide-timeout=%v", s.ExecutorSuicideTimeout))
|
||||||
|
ci.Arguments = append(ci.Arguments, fmt.Sprintf("--mesos-launch-grace-period=%v", s.LaunchGracePeriod))
|
||||||
|
|
||||||
if s.ExecutorBindall {
|
if s.ExecutorBindall {
|
||||||
//TODO(jdef) determine whether hostname-override is really needed for bindall because
|
//TODO(jdef) determine whether hostname-override is really needed for bindall because
|
||||||
|
@ -175,6 +175,7 @@ mesos-executor-mem
|
|||||||
mesos-master
|
mesos-master
|
||||||
mesos-role
|
mesos-role
|
||||||
mesos-user
|
mesos-user
|
||||||
|
mesos-launch-grace-period
|
||||||
minimum-container-ttl-duration
|
minimum-container-ttl-duration
|
||||||
minion-max-log-age
|
minion-max-log-age
|
||||||
minion-max-log-backups
|
minion-max-log-backups
|
||||||
|
Loading…
Reference in New Issue
Block a user