Skip to content

Set k8s normal default when assuming non aggressive probe is used#4864

Closed
nak3 wants to merge 4 commits intoknative:masterfrom
nak3:default-non-aggressive-readiness
Closed

Set k8s normal default when assuming non aggressive probe is used#4864
nak3 wants to merge 4 commits intoknative:masterfrom
nak3:default-non-aggressive-readiness

Conversation

@nak3
Copy link
Copy Markdown
Contributor

@nak3 nak3 commented Jul 22, 2019

Currently we have to set all periodSeconds, timeoutSeconds and
failureThreshold greater than 0, when we would like to use k8s style
readiness probe.

However, it could be assume that the user would like to use non
aggressive readiness probe when setting one of these values.
Hence, this patch sets k8s's normal default values for such case.

/lint

Ref #4780 (comment)

Proposed Changes

  • Set k8s normal default when assuming non aggressive probe is used

Release Note

NONE

Currently we have to set all periodSeconds, timeoutSeconds and
failureThreshold greater than 0, when we would like to use k8s style
readiness probe.

However, it could be assume that the user would like to use non
aggressive readiness probe when setting one of these values.
Hence, this patch sets k8s's normal default values for such  case.
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 22, 2019
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 22, 2019
Copy link
Copy Markdown
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@nak3: 0 warnings.

Details

In response to this:

Currently we have to set all periodSeconds, timeoutSeconds and
failureThreshold greater than 0, when we would like to use k8s style
readiness probe.

However, it could be assume that the user would like to use non
aggressive readiness probe when setting one of these values.
Hence, this patch sets k8s's normal default values for such case.

/lint

Ref #4780 (comment)

Proposed Changes

  • Set k8s normal default when assuming non aggressive probe is used

Release Note

NONE

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot knative-prow-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 22, 2019
@knative-prow-robot
Copy link
Copy Markdown
Contributor

Hi @nak3. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot knative-prow-robot added the area/API API objects and controllers label Jul 22, 2019
Copy link
Copy Markdown
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

Minor nits.

},
},
}, {
name: "defaluting non aggressive probe",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
name: "defaluting non aggressive probe",
name: "defaulting non aggressive probe",

(Don't use the commit button, please apply the change manually)

rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory] = *rsrc
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe fetch a pointer to the probe once to make this a bit more readable.

readinessProbe := &rs.PodSpec.Containers[idx].ReadinessProbe

I think that works, feel free to ignore if it doesn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it worked and it makes more readable! Thank you for the suggestion. Updated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ugh, but now you need to derefence on every call. May I instead suggest you obtain a pointer to the container at the start of the loop?

ctr := &rs.PodSpec.Containers[idx]

You can then replace a lot of boilerplate in the whole function and simplify all of the below to ctr.ReadinessProbe... which is simple enough I think. No dereferences should be needed then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Updated. (Sorry, I should have noticed it by myself.)

Copy link
Copy Markdown
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

/approve

I was about to propose to vendor https://github.com/kubernetes/kubernetes/blob/1cb3b5807ec37490b4582f22d991c043cc468195/pkg/apis/core/v1/defaults.go#L192-L205 and use that but... oh well, vendoring kubernetes/kubernetes is probably not a good idea for the few LoC we need here.

/assign @dgerd

Leaving the LGTM for Dan.

@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: markusthoemmes, nak3
To complete the pull request process, please assign vaikas-google
You can assign the PR to them by writing /assign @vaikas-google in a comment when ready.

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

Details 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

@markusthoemmes
Copy link
Copy Markdown
Contributor

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 22, 2019
@dgerd
Copy link
Copy Markdown

dgerd commented Jul 23, 2019

/hold

I don't have any problems with the code, but I would like to have a discussion on this in the API WG meeting on the behavior before merging this in.

I do have some reservation with the general behavior of changing a value causing the default behavior of another value to change. To make matters worse the defaults only change some of the time (i.e. successThreshold does not change the probe behavior, but failureThreshold does.) This can be very difficult to understand for new users, and can have a cascading effect if we were to use this pattern elsewhere.

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 23, 2019
Copy link
Copy Markdown
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2019
@markusthoemmes
Copy link
Copy Markdown
Contributor

@dgerd Pingeroo!

@dgerd
Copy link
Copy Markdown

dgerd commented Sep 23, 2019

This has taken a different direction with detailed errors rather than assuming user intent. #5385 adds the error behavior that we want.

@dgerd dgerd closed this Sep 23, 2019
@nak3 nak3 deleted the default-non-aggressive-readiness branch October 20, 2019 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/API API objects and controllers cla: yes Indicates the PR's author has signed the CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

6 participants