Skip to content

Add common probe path in autoscaler, networking and activator#7445

Merged
knative-prow-robot merged 6 commits intoknative:masterfrom
shreejad:probepath
Apr 2, 2020
Merged

Add common probe path in autoscaler, networking and activator#7445
knative-prow-robot merged 6 commits intoknative:masterfrom
shreejad:probepath

Conversation

@shreejad
Copy link
Contributor

@shreejad shreejad commented Mar 31, 2020

Fixes #5918

  • In PR 6505, a new probe path was added in activator code which can be whitelisted
  • This PR adds a common probe path '/healthz' in networking, autoscaler and activator (modifies previous custom path) to be whitelisted

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 31, 2020
@knative-prow-robot knative-prow-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 31, 2020
@knative-prow-robot knative-prow-robot added area/API API objects and controllers area/autoscale area/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features labels Mar 31, 2020
Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@shreejad
Copy link
Contributor Author

/assign @vagababov

Copy link
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.

/assign @JRBANCEL
For pkg/network changes.


httpDest := url.URL{
Scheme: "http",
Host: fmt.Sprintf("%s:%d", svc, port),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Host: fmt.Sprintf("%s:%d", svc, port),
Host: svc + ":" + strconv.Itoa(port),

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also recommend doing

u, _ := url.Parse(fmt.Sprintf("http://%s:%d/", svc, port))
u.Path = path.Join(u.Path, probePath)
return u.String()

perhaps with error handling, but we kind of know it won't fail here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But why "u.Path = path.Join(u.Path, probePath)" since we already know u.Path should be empty by definition in above line

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it empty? Or is it "/"? Your path does it have "/" prefix or not. This takes care of all the cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, makes sense

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

@@ -46,4 +46,6 @@ spec:
- excludedPaths:
- prefix: /metrics
- prefix: /_internal/knative/activator/probe
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there value in having different paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually have no idea, and was wondering too if everything will work with a common path. @tcnghia @vagababov ?

Copy link
Contributor

Choose a reason for hiding this comment

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

we don't check paths. But if we're going generic, then we should pick a generic name :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Having a single path probably makes more sense because it makes writing policies easier and it is more future proof (when we add or remove components).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Should the common path be something that we expect customer services won't have in their their application logic? Or can it be very short like "\probe". I had assumed that we had a complicated name with "_knative\internal..." to reduce chances of collision with customer service paths

Copy link
Contributor

Choose a reason for hiding this comment

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

@yolocs do you have a recommendation here?

May be something like /healthz would work. Also, if we allow this to be customized then our customers can avoid a collision even for shorter paths.

Copy link
Contributor

Choose a reason for hiding this comment

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

Given we intercept the request it is of less importance if it matches (still a problem if the network rule matches).
But having something like /__probe__ should mostly work.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer /healthz as it seems like pretty common path for health check. My thinking is for something default, it's better to meet most common path. If a user runs into a conflict, the config is there for them to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

As @vagababov said, the path can be anything, so let's use something simple and if possible that is somewhat "standard" in the Kubernetes world. /healthz seems appropriate.

return dialContext(ctx, network, net.JoinHostPort(item.podIP, item.podPort))
}}

probeUrl, _ := url.Parse(item.url.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment that it's safe to ignore the error because this is a "deepCopy" of the URL. Maybe even put it into it's own deepCopy(in *url.URL) *url.URL function for clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made changes in new commit

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)


Unable to apply comments to the following files:

  • pkg/network/status/status.go

@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 1, 2020
Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)

Co-Authored-By: Matt Moore <mattmoor@vmware.com>
@vagababov
Copy link
Contributor

you can avoid those errors by installing autoformat on save for whatever editor you're using, unless it's pico or something :)

@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 2, 2020
@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-knative-serving-unit-tests 0/3

Failed non-flaky tests preventing automatic retry of pull-knative-serving-unit-tests:

_go_tests.DataRaceAnalysis
pkg/reconciler/route.TestGlobalResyncOnUpdateDomainConfigMap

Copy link
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.

Just one nit.

@shreejad shreejad changed the title Changed probe path in autoscaler and networking in compliance with activator path Add common probe path in autoscaler, networking and activator Apr 2, 2020
Co-Authored-By: Victor Agababov <vagababov@gmail.com>
Copy link
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
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shreejad, vagababov

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

The pull request process is described 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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2020
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/activator/net/revision_backends.go 92.5% 93.1% 0.6
pkg/network/status/status.go 98.3% 98.4% 0.1

@knative-prow-robot knative-prow-robot merged commit 33e843e into knative:master Apr 2, 2020
nak3 added a commit to nak3/serving that referenced this pull request Jun 15, 2020
Autoscaler, activator and KIngres Prober commonly use the probe path
`/healthz`, but they defined it in each package.

This patch adds const value for ProbePath and use it from them.

Related to knative#7445
knative-prow-robot pushed a commit that referenced this pull request Jun 15, 2020
* Use common const value for probe path

Autoscaler, activator and KIngres Prober commonly use the probe path
`/healthz`, but they defined it in each package.

This patch adds const value for ProbePath and use it from them.

Related to #7445

* Fix lint error
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/autoscale area/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.