Skip to content

Commit

Permalink
apps: deployment config stuck in the new state should respect timeout…
Browse files Browse the repository at this point in the history
…Secods
  • Loading branch information
mfojtik committed Oct 23, 2017
1 parent 50389c0 commit a904877
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,15 @@ func updateConditions(config *deployapi.DeploymentConfig, newStatus *deployapi.D
// Condition about progress.
if latestRC != nil {
switch deployutil.DeploymentStatusFor(latestRC) {
case deployapi.DeploymentStatusNew:
// In case we fail to created the deployer pod within strategy
// timeoutSeconds do not leave the deployment config in New state forever
// but timeout.
if deployutil.ConfigExceededTimeoutSeconds(config, latestRC) {
msg := fmt.Sprintf("rollout of replication controller %s timed out to create the deployer pod", latestRC.Name)
condition := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionFalse, deployapi.TimedOutReason, msg)
deployutil.SetDeploymentCondition(newStatus, *condition)
}
case deployapi.DeploymentStatusPending:
msg := fmt.Sprintf("replication controller %q is waiting for pod %q to run", latestRC.Name, deployutil.DeployerPodNameForDeployment(latestRC.Name))
condition := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionUnknown, "", msg)
Expand Down
17 changes: 17 additions & 0 deletions pkg/apps/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,23 @@ func DeploymentsForCleanup(configuration *deployapi.DeploymentConfig, deployment
return relevantDeployments
}

func ConfigExceededTimeoutSeconds(config *deployapi.DeploymentConfig, latestRC *v1.ReplicationController) bool {
var timeoutSeconds int64
if params := config.Spec.Strategy.RollingParams; params != nil {
timeoutSeconds = deployapi.DefaultRollingTimeoutSeconds
if params.TimeoutSeconds != nil {
timeoutSeconds = *params.TimeoutSeconds
}
}
if params := config.Spec.Strategy.RecreateParams; params != nil {
timeoutSeconds = deployapi.DefaultRecreateTimeoutSeconds
if params.TimeoutSeconds != nil {
timeoutSeconds = *params.TimeoutSeconds
}
}
return int64(time.Since(latestRC.CreationTimestamp.Time)*time.Second) > timeoutSeconds
}

// WaitForRunningDeployerPod waits a given period of time until the deployer pod
// for given replication controller is not running.
func WaitForRunningDeployerPod(podClient kcoreclient.PodsGetter, rc *api.ReplicationController, timeout time.Duration) error {
Expand Down

0 comments on commit a904877

Please sign in to comment.