Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy: default maxSurge/maxUnavailable separately #11678

Merged
merged 1 commit into from Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/deploy/api/v1/defaults.go
Expand Up @@ -71,6 +71,7 @@ func SetDefaults_RecreateDeploymentStrategyParams(obj *RecreateDeploymentStrateg
obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds)
}
}

func SetDefaults_RollingDeploymentStrategyParams(obj *RollingDeploymentStrategyParams) {
if obj.IntervalSeconds == nil {
obj.IntervalSeconds = mkintp(deployapi.DefaultRollingIntervalSeconds)
Expand All @@ -91,6 +92,18 @@ func SetDefaults_RollingDeploymentStrategyParams(obj *RollingDeploymentStrategyP
maxSurge := intstr.FromString("25%")
obj.MaxSurge = &maxSurge
}

if obj.MaxUnavailable == nil && obj.MaxSurge != nil &&
(*obj.MaxSurge == intstr.FromInt(0) || *obj.MaxSurge == intstr.FromString("0%")) {
maxUnavailable := intstr.FromString("25%")
obj.MaxUnavailable = &maxUnavailable
}

if obj.MaxSurge == nil && obj.MaxUnavailable != nil &&
(*obj.MaxUnavailable == intstr.FromInt(0) || *obj.MaxUnavailable == intstr.FromString("0%")) {
maxSurge := intstr.FromString("25%")
obj.MaxSurge = &maxSurge
}
}

func SetDefaults_DeploymentConfig(obj *DeploymentConfig) {
Expand Down
35 changes: 35 additions & 0 deletions pkg/deploy/api/v1/defaults_test.go
Expand Up @@ -232,6 +232,41 @@ func TestDefaults(t *testing.T) {
},
},
},
{
original: &deployv1.DeploymentConfig{
Spec: deployv1.DeploymentConfigSpec{
Strategy: deployv1.DeploymentStrategy{
Type: deployv1.DeploymentStrategyTypeRolling,
RollingParams: &deployv1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
MaxSurge: newIntOrString(intstr.FromInt(0)),
},
},
Triggers: []deployv1.DeploymentTriggerPolicy{
{},
},
},
},
expected: &deployv1.DeploymentConfig{
Spec: deployv1.DeploymentConfigSpec{
Strategy: deployv1.DeploymentStrategy{
Type: deployv1.DeploymentStrategyTypeRolling,
RollingParams: &deployv1.RollingDeploymentStrategyParams{
UpdatePeriodSeconds: newInt64(5),
IntervalSeconds: newInt64(6),
TimeoutSeconds: newInt64(7),
MaxUnavailable: newIntOrString(intstr.FromString("25%")),
MaxSurge: newIntOrString(intstr.FromInt(0)),
},
},
Triggers: []deployv1.DeploymentTriggerPolicy{
{},
},
},
},
},
}

for i, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/controller/deploymentconfig/controller.go
Expand Up @@ -351,7 +351,7 @@ func updateConditions(config deployapi.DeploymentConfig, newStatus *deployapi.De
if latestRC != nil {
switch deployutil.DeploymentStatusFor(latestRC) {
case deployapi.DeploymentStatusPending:
msg := fmt.Sprintf("Waiting on deployer pod for replication controller %q to be scheduled", latestRC.Name)
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)
deployutil.SetDeploymentCondition(newStatus, *condition)
case deployapi.DeploymentStatusRunning:
Expand Down