executor,scheduler: make launchGracePeriod configurable

This commit is contained in:
Sergiusz Urbaniak
2015-09-23 17:00:26 +02:00
parent 719cf5617e
commit 42c84954fd
5 changed files with 33 additions and 18 deletions

View File

@@ -47,7 +47,6 @@ import (
const (
containerPollTime = 1 * time.Second
launchGracePeriod = 5 * time.Minute
podRelistPeriod = 5 * time.Minute
)
@@ -123,6 +122,7 @@ type KubernetesExecutor struct {
staticPodsConfigPath string
initialRegComplete chan struct{}
podController *framework.Controller
launchGracePeriod time.Duration
}
type Config struct {
@@ -138,6 +138,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 {
@@ -165,6 +166,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
@@ -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) {
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..
@@ -633,7 +638,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 {