diff --git a/pkg/activator/net/revision_backends.go b/pkg/activator/net/revision_backends.go index 72ebcdf83308..8dcf3bc897f8 100644 --- a/pkg/activator/net/revision_backends.go +++ b/pkg/activator/net/revision_backends.go @@ -69,7 +69,7 @@ type dests struct { const ( probeTimeout time.Duration = 300 * time.Millisecond defaultProbeFrequency time.Duration = 200 * time.Millisecond - probePath = "/_internal/knative/activator/probe" + probePath = "/healthz" ) // revisionWatcher watches the podIPs and ClusterIP of the service for a revision. It implements the logic diff --git a/pkg/network/status/status.go b/pkg/network/status/status.go index 1a7ba0431a32..739294eae4e2 100644 --- a/pkg/network/status/status.go +++ b/pkg/network/status/status.go @@ -23,6 +23,7 @@ import ( "net" "net/http" "net/url" + "path" "reflect" "sync" "sync/atomic" @@ -43,8 +44,9 @@ import ( 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 defines the maximum amount of time a request will wait probeTimeout = 1 * time.Second + probePath = "/healthz" ) var dialContext = (&net.Dialer{Timeout: probeTimeout}).DialContext @@ -356,10 +358,13 @@ func (m *Prober) processWorkItem() bool { return dialContext(ctx, network, net.JoinHostPort(item.podIP, item.podPort)) }} + probeURL := deepCopy(item.url) + probeURL.Path = path.Join(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)) @@ -427,3 +432,10 @@ func (m *Prober) probeVerifier(item *workItem) prober.Verifier { } } } + +// deepCopy copies a URL into a new one +func deepCopy(in *url.URL) *url.URL { + // Safe to ignore the error since this is a deep copy + newURL, _ := url.Parse(in.String()) + return newURL +} diff --git a/pkg/reconciler/autoscaling/kpa/scaler.go b/pkg/reconciler/autoscaling/kpa/scaler.go index c684ddd2469f..97f8d89bdcfe 100644 --- a/pkg/reconciler/autoscaling/kpa/scaler.go +++ b/pkg/reconciler/autoscaling/kpa/scaler.go @@ -47,6 +47,7 @@ const ( scaleUnknown = -1 probePeriod = 1 * time.Second probeTimeout = 45 * time.Second + // 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. @@ -112,11 +113,12 @@ func newScaler(ctx context.Context, psInformerFactory duck.InformerFactory, enqu return ks } -// Resolves the pa to hostname:port. +// Resolves the pa to the probing endpoint Eg. http://hostname:port/healthz 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) + + return fmt.Sprintf("http://%s:%d/healthz", svc, port) } // activatorProbe returns true if via probe it determines that the diff --git a/test/config/security/policy.yaml b/test/config/security/policy.yaml index 533399c82d6c..36a7b60ffea0 100644 --- a/test/config/security/policy.yaml +++ b/test/config/security/policy.yaml @@ -45,5 +45,5 @@ spec: triggerRules: - excludedPaths: - prefix: /metrics - - prefix: /_internal/knative/activator/probe + - prefix: /healthz principalBinding: USE_ORIGIN