-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add common probe path in autoscaler, networking and activator #7445
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
Changes from 2 commits
3965c61
a623b87
bedc563
94ef72c
00f85ba
07de7c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,8 @@ const ( | |
| // probeConcurrency defines how many probing calls can be issued simultaneously | ||
| probeConcurrency = 15 | ||
| //probeTimeout defines the maximum amount of time a request will wait | ||
| probeTimeout = 1 * time.Second | ||
| probeTimeout = 1 * time.Second | ||
| probePath = "/_internal/knative/networking/probe" | ||
| ) | ||
|
|
||
| var dialContext = (&net.Dialer{Timeout: probeTimeout}).DialContext | ||
|
|
@@ -356,10 +357,13 @@ func (m *Prober) processWorkItem() bool { | |
| return dialContext(ctx, network, net.JoinHostPort(item.podIP, item.podPort)) | ||
| }} | ||
|
|
||
| probeUrl, _ := url.Parse(item.url.String()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made changes in new commit |
||
| probeUrl.Path = probePath | ||
|
|
||
| ok, err := prober.Do( | ||
| item.context, | ||
| transport, | ||
| item.url.String(), | ||
| probeUrl.String(), | ||
| prober.WithHeader(network.UserAgentKey, network.IngressReadinessUserAgent), | ||
| prober.WithHeader(network.ProbeHeaderName, network.ProbeHeaderValue), | ||
| m.probeVerifier(item)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ import ( | |||||
| "context" | ||||||
| "fmt" | ||||||
| "net/http" | ||||||
| "net/url" | ||||||
| "time" | ||||||
|
|
||||||
| "knative.dev/pkg/apis/duck" | ||||||
|
|
@@ -47,6 +48,8 @@ const ( | |||||
| scaleUnknown = -1 | ||||||
| probePeriod = 1 * time.Second | ||||||
| probeTimeout = 45 * time.Second | ||||||
| probePath = "/_internal/knative/autoscaler/probe" | ||||||
|
shreejad marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| // The time after which the PA will be re-enqueued. | ||||||
| // This number is small, since `handleScaleToZero` below will | ||||||
| // re-enqueue for the configured grace period. | ||||||
|
|
@@ -116,7 +119,14 @@ func newScaler(ctx context.Context, psInformerFactory duck.InformerFactory, enqu | |||||
| func paToProbeTarget(pa *pav1alpha1.PodAutoscaler) string { | ||||||
| svc := pkgnet.GetServiceHostname(pa.Status.ServiceName, pa.Namespace) | ||||||
| port := networking.ServicePort(pa.Spec.ProtocolType) | ||||||
| return fmt.Sprintf("http://%s:%d/", svc, port) | ||||||
|
|
||||||
| httpDest := url.URL{ | ||||||
| Scheme: "http", | ||||||
| Host: fmt.Sprintf("%s:%d", svc, port), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also recommend doing perhaps with error handling, but we kind of know it won't fail here...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, makes sense |
||||||
| Path: probePath, | ||||||
| } | ||||||
|
|
||||||
| return httpDest.String() | ||||||
| } | ||||||
|
|
||||||
| // activatorProbe returns true if via probe it determines that the | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,4 +46,6 @@ spec: | |
| - excludedPaths: | ||
| - prefix: /metrics | ||
| - prefix: /_internal/knative/activator/probe | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there value in having different paths?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| - prefix: /_internal/knative/autoscaler/probe | ||
| - prefix: /_internal/knative/networking/probe | ||
| principalBinding: USE_ORIGIN | ||
Uh oh!
There was an error while loading. Please reload this page.