Merge pull request #14432 from mesosphere/sur-k8sm-492-launch-grace-period
MESOS make launchGracePeriod configurable
This commit is contained in:
@@ -48,7 +48,6 @@ import (
|
||||
|
||||
const (
|
||||
containerPollTime = 1 * time.Second
|
||||
launchGracePeriod = 5 * time.Minute
|
||||
podRelistPeriod = 5 * time.Minute
|
||||
)
|
||||
|
||||
@@ -124,6 +123,7 @@ type KubernetesExecutor struct {
|
||||
staticPodsConfigPath string
|
||||
initialRegComplete chan struct{}
|
||||
podController *framework.Controller
|
||||
launchGracePeriod time.Duration
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
@@ -139,6 +139,7 @@ type Config struct {
|
||||
PodStatusFunc func(KubeletInterface, *api.Pod) (*api.PodStatus, error)
|
||||
StaticPodsConfigPath string
|
||||
PodLW cache.ListerWatcher
|
||||
LaunchGracePeriod time.Duration
|
||||
}
|
||||
|
||||
func (k *KubernetesExecutor) isConnected() bool {
|
||||
@@ -166,6 +167,7 @@ func New(config Config) *KubernetesExecutor {
|
||||
podStatusFunc: config.PodStatusFunc,
|
||||
initialRegComplete: make(chan struct{}),
|
||||
staticPodsConfigPath: config.StaticPodsConfigPath,
|
||||
launchGracePeriod: config.LaunchGracePeriod,
|
||||
}
|
||||
|
||||
// watch pods from the given pod ListWatch
|
||||
@@ -599,7 +601,10 @@ func (k *KubernetesExecutor) launchTask(driver bindings.ExecutorDriver, taskId s
|
||||
func (k *KubernetesExecutor) _launchTask(driver bindings.ExecutorDriver, taskId, podFullName string, psf podStatusFunc) {
|
||||
|
||||
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) {
|
||||
// potentially long call..
|
||||
@@ -638,7 +643,7 @@ waitForRunningPod:
|
||||
for {
|
||||
select {
|
||||
case <-expired:
|
||||
log.Warningf("Launch expired grace period of '%v'", launchGracePeriod)
|
||||
log.Warningf("Launch expired grace period of '%v'", k.launchGracePeriod)
|
||||
break waitForRunningPod
|
||||
case <-time.After(containerPollTime):
|
||||
if data, cancel := getMarshalledInfo(); cancel {
|
||||
|
Reference in New Issue
Block a user