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

Allow probes to explicitly set the port to the containerPort (#8288) #12225

Merged
merged 2 commits into from
Nov 8, 2021

Conversation

evankanderson
Copy link
Member

Fixes #8288

Proposed Changes

  • Accept specs which specify an explicit probe on the containerPort.
    • Baseline Kubernetes does not permit TCP / HTTP probes without a port specified. Requiring these to be unset makes it hard to build generic tools for both k8s Deployment/etc and Knative, and seems overly restrictive.

Release Note

Allow setting TCP and HTTP port to be equal to containerPort on readiness and liveness probes.

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 4, 2021
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/API API objects and controllers approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 4, 2021
@codecov
Copy link

codecov bot commented Nov 5, 2021

Codecov Report

Merging #12225 (00e2b4f) into main (cad72a3) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12225      +/-   ##
==========================================
- Coverage   87.36%   87.32%   -0.05%     
==========================================
  Files         196      195       -1     
  Lines        9611     9583      -28     
==========================================
- Hits         8397     8368      -29     
- Misses        935      936       +1     
  Partials      279      279              
Impacted Files Coverage Δ
pkg/apis/serving/fieldmask.go 95.07% <100.00%> (+0.03%) ⬆️
pkg/apis/serving/k8s_validation.go 93.50% <100.00%> (+0.19%) ⬆️
pkg/autoscaler/scaling/multiscaler.go 87.27% <0.00%> (-1.82%) ⬇️
pkg/queue/health/handler.go 100.00% <0.00%> (ø)
pkg/queue/health/health_state.go
cmd/queue/main.go 0.49% <0.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cad72a3...00e2b4f. Read the comment docs.

func validateContainersPorts(containers []corev1.Container) *apis.FieldError {
// validateContainersPorts validates port when specified multiple containers,
// and returns the single serving port if error is nil
func validateContainersPorts(containers []corev1.Container) (*apis.FieldError, intstr.IntOrString) {
Copy link
Member

Choose a reason for hiding this comment

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

elsewhere (1, 2) where we've returned a value as well as the field error in validation we've kept to the convention of the err being last (even though it's a slightly special err type), probably worth staying consistent

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I'll admit that I sort of just got annoyed and skipped a bunch of other stuff I was doing yesterday when I realized that I'd bumped this bug but hadn't actually made sure it got fixed.

var count int
var port = intstr.IntOrString{IntVal: 8080, StrVal: "http"}
Copy link
Member

Choose a reason for hiding this comment

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

fwiw I got a bit confused about this use of IntOrString because we're really using it as an IntAndString here I think (which is a bit at odds with the Type field in IntOrString and some of its methods). What do you think about returning the matched ContainerPort struct instead (and then we could use the explicit Name and ContainerPort fields in validateProbe)?

Copy link
Member Author

Choose a reason for hiding this comment

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

/shrug

Sure, why not.

@evankanderson
Copy link
Member Author

Ready for another look

Copy link
Member

@julz julz left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 8, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: evankanderson, julz

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

@knative-prow-robot knative-prow-robot merged commit 77ba3bd into knative:main Nov 8, 2021
@dprotaso
Copy link
Member

/cherry-pick release-1.0

@knative-prow-robot
Copy link
Contributor

@dprotaso: new pull request created: #12270

In response to this:

/cherry-pick release-1.0

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.

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. area/API API objects and controllers cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. ¯\_(ツ)_/¯
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add port spec in probes
4 participants