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

Disable readyReplicas validation for Deployments #43465

Merged
merged 1 commit into from
Mar 22, 2017
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
4 changes: 3 additions & 1 deletion pkg/apis/extensions/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ func ValidateDeploymentStatus(status *extensions.DeploymentStatus, fldPath *fiel
if status.AvailableReplicas > status.Replicas {
allErrs = append(allErrs, field.Invalid(fldPath.Child("availableReplicas"), status.AvailableReplicas, msg))
}
if status.AvailableReplicas > status.ReadyReplicas {
// TODO: ReadyReplicas is introduced in 1.6 and this check breaks the Deployment controller when pre-1.6 clusters get upgraded.
// Remove the comparison to zero once we stop supporting upgrades from 1.5.
if status.ReadyReplicas > 0 && status.AvailableReplicas > status.ReadyReplicas {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't really add new required fields, even in status - we may never be able to get rid of this, and it should probably have been a pointer to begin with.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should definitely have been a pointer. Is it too late to change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may never be able to get rid of this

Care to elaborate? Once we stop supporting updates from 1.5, why can't this be removed?

allErrs = append(allErrs, field.Invalid(fldPath.Child("availableReplicas"), status.AvailableReplicas, "cannot be greater than readyReplicas"))
}
return allErrs
Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/extensions/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,15 @@ func TestValidateDeploymentStatus(t *testing.T) {
observedGeneration: 1,
expectedErr: true,
},
// TODO: Remove the following test case once we stop supporting upgrades from 1.5.
{
name: "don't validate readyReplicas when it's zero",
replicas: 3,
readyReplicas: 0,
availableReplicas: 3,
observedGeneration: 1,
expectedErr: false,
},
}

for _, test := range tests {
Expand Down