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

Default extensions/v1beta1 Deployment's ProgressDeadlineSeconds to MaxInt32 #66581

Merged
merged 3 commits into from Jul 31, 2018

Conversation

janetkuo
Copy link
Member

@janetkuo janetkuo commented Jul 24, 2018

What this PR does / why we need it: Default values should be set in all API versions, because defaulting happens whenever a serialized version is read. When we switched to apps/v1 as the storage version in 1.10 (#58854), extensions/v1beta1 DeploymentSpec.ProgressDeadlineSeconds gets apps/v1 default value (600) instead of being unset.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #66135

Special notes for your reviewer: We need to cherrypick this fix to 1.10 and 1.11. Note that this fix will only help people who haven't upgraded to 1.10 or 1.11 when the storage version is changed.

@kubernetes/sig-apps-bugs

Release note:

extensions/v1beta1.Deployment .spec.progressDeadlineSeconds should be defaulted to "no deadline" instead of 600. 

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 24, 2018
@k8s-github-robot k8s-github-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Jul 24, 2018
@janetkuo janetkuo force-pushed the deploy-progress branch 2 times, most recently from 2b950f9 to 0fa3593 Compare July 24, 2018 22:11
@@ -289,7 +289,8 @@ func ValidateDeploymentSpec(spec *extensions.DeploymentSpec, fldPath *field.Path
}
if spec.ProgressDeadlineSeconds != nil {
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*spec.ProgressDeadlineSeconds), fldPath.Child("progressDeadlineSeconds"))...)
if *spec.ProgressDeadlineSeconds <= spec.MinReadySeconds {
if *spec.ProgressDeadlineSeconds > 0 && *spec.ProgressDeadlineSeconds <= spec.MinReadySeconds {
Copy link
Member

Choose a reason for hiding this comment

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

Is it safe to relax validation to allow 0? The API guidelines say, "Validation rules on spec fields can neither be relaxed nor strengthened."

In this case, I'm not too worried about clients being broken by 0, but what happens on the server if, for example, you roll back to a previous patch release after some objects have been persisted with a 0 value? Will the object become inaccessible? Will a "list all" fail? Or does the server handle this gracefully somehow?

Copy link
Member Author

@janetkuo janetkuo Jul 25, 2018

Choose a reason for hiding this comment

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

Good point. Even if the object is still accessible with 0 value after downgrade, the old controller will treat deadline == 0 as "immediately pass deadline" instead of "no deadline".

It's safer to use max int instead, then.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to use max int32 instead.

@janetkuo janetkuo changed the title Default extensions/v1beta1 Deployment's ProgressDeadlineSeconds to 0 Default extensions/v1beta1 Deployment's ProgressDeadlineSeconds to MaxInt32 Jul 25, 2018
@smarterclayton
Copy link
Contributor

smarterclayton commented Jul 25, 2018 via email

@janetkuo
Copy link
Member Author

Doesn't this mean that anytime we have an effective default on a pointer field, where we want to leave the field unset, we can't change the default across versions?

@smarterclayton Yes. We cannot leave a field unset in one version but defaulted in another version, because defaulting are not just applied when an object is created, but every time a serialized version is read.

Pretty sure we've introduced more of these as we've become quite pointer happy these days.

I opened an umbrella issue #66582 to track other violations.

@janetkuo
Copy link
Member Author

/test pull-kubernetes-e2e-gce

Copy link
Member

@enisoc enisoc left a comment

Choose a reason for hiding this comment

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

LGTM other than nits.

@@ -47,7 +47,7 @@ func (dc *DeploymentController) syncRolloutStatus(allRSs []*apps.ReplicaSet, new
isCompleteDeployment := newStatus.Replicas == newStatus.UpdatedReplicas && currentCond != nil && currentCond.Reason == util.NewRSAvailableReason
// Check for progress only if there is a progress deadline set and the latest rollout
// hasn't completed yet.
if d.Spec.ProgressDeadlineSeconds != nil && !isCompleteDeployment {
if !util.NoProgressDeadline(d) && !isCompleteDeployment {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: could we invert the function to HasProgressDeadline to avoid the double negative?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Done.

// not be estimated during the time a deployment is paused. This is not set
// by default.
// not be estimated during the time a deployment is paused. This is set to
// the max value of int32 (1<<31 - 1) by default, which means "no deadline".
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Since this may end up in generated user docs, it might be better to give the explicit value instead (2147483647) so it looks the same way people will see it printed in objects, and so people don't need to be familiar with bit shift syntax.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

…xInt32.

1. MaxInt32 has the same meaning as unset, for compatibility
2. Deployment controller treats MaxInt32 the same as unset (nil)
1. hack/update-generated-protobuf.sh
2. hack/update-generated-swagger-docs.sh
3. hack/update-swagger-spec.sh
4. hack/update-openapi-spec.sh
5. hack/update-api-reference-docs.sh
@janetkuo
Copy link
Member Author

@enisoc PTAL

@david-mcmahon david-mcmahon removed their request for review July 27, 2018 17:37
Copy link
Member

@enisoc enisoc left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 27, 2018
@janetkuo janetkuo removed the request for review from gmarek July 27, 2018 18:06
@janetkuo
Copy link
Member Author

/assign @smarterclayton

Would you approve it? Thanks!

Copy link
Contributor

@tnozicka tnozicka left a comment

Choose a reason for hiding this comment

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

nit; lgtm otherwise

@@ -330,7 +338,7 @@ func TestSyncRolloutStatus(t *testing.T) {
newCond := util.GetDeploymentCondition(test.d.Status, test.conditionType)
switch {
case newCond == nil:
if test.d.Spec.ProgressDeadlineSeconds != nil {
if test.d.Spec.ProgressDeadlineSeconds != nil && *test.d.Spec.ProgressDeadlineSeconds != math.MaxInt32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: deploymentutil.HasProgressDeadline

Copy link
Member Author

Choose a reason for hiding this comment

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

Intentionally write it explicitly in the test, so that if we break deploymentutil.HasProgressDeadline() in the future, this test will still catch that.

@smarterclayton
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enisoc, janetkuo, smarterclayton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 31, 2018
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@nikhita
Copy link
Member

nikhita commented Sep 12, 2018

This should include a release note.

@janetkuo Can you update the main PR body to include a release note? Thanks!

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 1, 2018
@janetkuo
Copy link
Member Author

janetkuo commented Oct 1, 2018

Added a release note. Thanks!

k8s-ci-robot added a commit that referenced this pull request Jan 18, 2019
…81-upstream-release-1.11

Automated cherry pick of #66581 upstream release 1.11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1.10.0 ProgressDeadlineSeconds default added to v1beta1 deployment
8 participants