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

Probe port different than container port #12606

Merged
merged 16 commits into from
Mar 8, 2022
Merged

Probe port different than container port #12606

merged 16 commits into from
Mar 8, 2022

Conversation

izabelacg
Copy link
Member

@izabelacg izabelacg commented Feb 9, 2022

Fixes #8288

Proposed Changes

  • Allow readiness probe port to be different than the user container port.

Release Note

Allow readiness probe port to be different than the user container port.

@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 9, 2022
@knative-prow-robot
Copy link
Contributor

Welcome @izabelacg! It looks like this is your first PR to knative/serving 🎉

@knative-prow-robot
Copy link
Contributor

Hi @izabelacg. 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.

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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/API API objects and controllers labels Feb 9, 2022
@nader-ziada
Copy link
Member

/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 Feb 9, 2022
@nader-ziada
Copy link
Member

This PR is related to #8471

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 11, 2022
@izabelacg izabelacg changed the title [WIP] Probe port different than container port Probe port different than container port Feb 15, 2022
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 15, 2022
@nader-ziada
Copy link
Member

I worked with @izabelacg on this PR, so would you folks mind reviewing @dprotaso @psschwei

@nader-ziada
Copy link
Member

/retest

@dprotaso
Copy link
Member

kicked off the GithubAction workflows

@codecov
Copy link

codecov bot commented Feb 16, 2022

Codecov Report

Merging #12606 (c3f62df) into main (4262dcb) will decrease coverage by 0.20%.
The diff coverage is 57.14%.

❗ Current head c3f62df differs from pull request most recent head 6d475fb. Consider uploading reports for the commit 6d475fb to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12606      +/-   ##
==========================================
- Coverage   87.48%   87.28%   -0.21%     
==========================================
  Files         195      196       +1     
  Lines        9718     9744      +26     
==========================================
+ Hits         8502     8505       +3     
- Misses        931      953      +22     
- Partials      285      286       +1     
Impacted Files Coverage Δ
pkg/apis/serving/k8s_validation.go 93.17% <50.00%> (-0.45%) ⬇️
pkg/reconciler/revision/resources/queue.go 98.22% <66.66%> (-0.01%) ⬇️
pkg/activator/net/throttler.go 87.95% <0.00%> (-0.90%) ⬇️
pkg/apis/serving/v1/revision_types.go 100.00% <0.00%> (ø)
pkg/reconciler/revision/rate_limiter.go 16.66% <0.00%> (ø)
pkg/reconciler/configuration/configuration.go 86.15% <0.00%> (+1.53%) ⬆️

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 4262dcb...6d475fb. Read the comment docs.

@nader-ziada
Copy link
Member

kicked off the GithubAction workflows

why aren't the actions triggered automatically? and do you need special permissions to kick it off?

@nader-ziada
Copy link
Member

@carlisia would you mind reviewing as well?

@izabelacg
Copy link
Member Author

/retest

@carlisia carlisia self-assigned this Feb 17, 2022
@dprotaso
Copy link
Member

why aren't the actions triggered automatically? and do you need special permissions to kick it off?

PRs from non-org members don't automatically kick off the actions for security reasons - ie. bitcoin miners

I created an issue for /ok-to-test approve the action run

knative/test-infra#3057

@izabelacg
Copy link
Member Author

/retest

test/test_images/readinessport/README.md Outdated Show resolved Hide resolved
v1test "knative.dev/serving/test/v1"
)

func TestReadinessPort(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func TestReadinessPort(t *testing.T) {
func TestReadinessAlternatePort(t *testing.T) {

Copy link
Member

Choose a reason for hiding this comment

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

this was reverted

pkg/apis/serving/k8s_validation_test.go Show resolved Hide resolved
pkg/apis/serving/k8s_validation.go Outdated Show resolved Hide resolved
pkg/apis/serving/k8s_validation.go Outdated Show resolved Hide resolved
pkg/reconciler/revision/resources/deploy_test.go Outdated Show resolved Hide resolved
pkg/reconciler/revision/resources/queue.go Outdated Show resolved Hide resolved
Comment on lines 925 to 936
if container == nil {
return fmt.Sprintf(testProbeJSONTemplate, v1.DefaultUserPort)
}

if container.ReadinessProbe.TCPSocket != nil && container.ReadinessProbe.TCPSocket.Port != intstr.FromInt(int(0)) {
return fmt.Sprintf(testProbeJSONTemplate, container.ReadinessProbe.TCPSocket.Port.IntVal)
}
if container.ReadinessProbe.HTTPGet != nil && container.ReadinessProbe.HTTPGet.Port != intstr.FromInt(int(0)) {
return fmt.Sprintf(testProbeJSONTemplate, container.ReadinessProbe.HTTPGet.Port.IntVal)
}
if ports := container.Ports; len(ports) > 0 && ports[0].ContainerPort != 0 {
return fmt.Sprintf(testProbeJSONTemplate, ports[0].ContainerPort)
}
Copy link
Member

@dprotaso dprotaso Feb 22, 2022

Choose a reason for hiding this comment

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

nit: I'd probably just make a switch statement so this reads a bit easier.

I was scanning to see if the template changes under any condition and it doesn't

Copy link
Member

Choose a reason for hiding this comment

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

but what would you switch on, the if condition is checking different fields, can you clarify please?

@dprotaso
Copy link
Member

dprotaso commented Mar 1, 2022

/retest

@dprotaso
Copy link
Member

dprotaso commented Mar 1, 2022

@izabelacg the failures are legit and not flakey

probeServer.HandleFunc("/", handleHealthz)

go func() {
http.ListenAndServe(":"+strconv.Itoa(healthcheckPort), probeServer)
Copy link
Member

Choose a reason for hiding this comment

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

if the health check port isn't set we want it on the mainServer

That's probably the cause of the failures

Copy link
Member

Choose a reason for hiding this comment

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

Or you could add the handleHealthz handler to both servers to keep things simple

http.ListenAndServe(":8080", mainServer)
}()

<-finish
Copy link
Member

@dprotaso dprotaso Mar 1, 2022

Choose a reason for hiding this comment

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

You can drop the use of the channel and just call http.ListenAndServe to block. Invoking that in a go routine isn't needed

Copy link
Member

Choose a reason for hiding this comment

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

I think the go func is required cause you have two ListenAndServe, which doesn't work on the same thread

Copy link
Member

Choose a reason for hiding this comment

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

If you invoke one ListenAndServe in a go routine and the other on the main go routine you don't need the finish channel

@dprotaso
Copy link
Member

dprotaso commented Mar 1, 2022

I resolved some of the earlier comments - there's one or two outstanding

Copy link
Member

@carlisia carlisia left a comment

Choose a reason for hiding this comment

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

LGTM! I only have a couple super minor comments.

test/e2e/readinessport_test.go Outdated Show resolved Hide resolved
pkg/apis/serving/k8s_validation_test.go Show resolved Hide resolved
test/conformance.go Outdated Show resolved Hide resolved
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Knative Authors
Copyright 2022 The Knative Authors
Copy link
Member

@dprotaso dprotaso Mar 7, 2022

Choose a reason for hiding this comment

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

we don't need to modify the copyright of existing files - please undo

Copy link
Member Author

Choose a reason for hiding this comment

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

oh sorry, so basically only test/e2e/readinessport_test.go needs change on the copyright. Will revert changes

@dprotaso
Copy link
Member

dprotaso commented Mar 7, 2022

Updated the boilerplate year checks here: #12699

@dprotaso
Copy link
Member

dprotaso commented Mar 8, 2022

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, izabelacg

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 8, 2022
@knative-prow-robot knative-prow-robot merged commit afe46a9 into knative:main Mar 8, 2022
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 area/test-and-release It flags unit/e2e/conformance/perf test issues for product features 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/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
5 participants