Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
izabelacg committed Mar 26, 2024
1 parent 3210a05 commit 6174bf9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
9 changes: 1 addition & 8 deletions pkg/deprecated_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,7 @@ const (
// different user-agent. So we augment the probes with this header.
//
// Deprecated: use knative.dev/networking/pkg/http/header.UserAgentKey
KubeletProbeHeaderName = header.UserAgentKey

// KubeletProbeKey is the name of the header supplied by kubelet
// probes. Istio with mTLS rewrites probes, but their probes pass a
// different user-agent. So we augment the probes with this header.
//
// Deprecated: use knative.dev/networking/pkg/http/header.UserAgentKey
KubeletProbeKey = header.UserAgentKey
KubeletProbeHeaderName = header.KubeletProbeKey

// UserAgentKey is the constant for header "User-Agent".
//
Expand Down
14 changes: 9 additions & 5 deletions pkg/http/header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ const (
// at the Queue proxy level back to be a host header.
OriginalHostKey = "K-Original-Host"

// KubeletProbeKey is the name of the header supplied by kubelet
// probes. Istio with mTLS rewrites probes, but their probes pass a
// different user-agent. So we augment the probes with this header.
// KubeletProbeKey is the name of the header supplied by kubelet probes.
// Prior to this deprecation, Istio with mTLS rewrote probes and their probes passed a
// different user-agent. Therefore, this header was added to augment the probes.
//
// Deprecated: use knative.dev/networking/pkg/http/header.UserAgentKey
// Deprecated: this custom request header is no longer necessary since Istio now propagates the
// original request header `User-Agent` sent by the kubelet (e.g., User-Agent: kube-probe/1.29).
// For updated usage, please utilize knative.dev/networking/pkg/http/header.UserAgentKey and
// knative.dev/networking/pkg/http/header.KubeProbeUAPrefix
KubeletProbeKey = "K-Kubelet-Probe"

// RouteTagKey is the name of the header entry which has a tag name as value.
Expand Down Expand Up @@ -128,7 +131,8 @@ func IsProbe(r *http.Request) bool {

// IsKubeletProbe returns true if the request is a Kubernetes probe.
func IsKubeletProbe(r *http.Request) bool {
return strings.HasPrefix(r.Header.Get("User-Agent"), KubeProbeUAPrefix)
return strings.HasPrefix(r.Header.Get("User-Agent"), KubeProbeUAPrefix) ||
r.Header.Get(KubeletProbeKey) != ""
}

// RewriteHostIn removes the `Host` header from the inbound (server) request
Expand Down
4 changes: 4 additions & 0 deletions pkg/http/header/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func TestIsKubeletProbe(t *testing.T) {
if IsKubeletProbe(req) {
t.Error("Not a kubelet probe but counted as such")
}
req.Header.Set(KubeletProbeKey, "no matter")
if !IsKubeletProbe(req) {
t.Error("kubelet probe but not counted as such")
}
}

func TestKnativeProbeHeader(t *testing.T) {
Expand Down

0 comments on commit 6174bf9

Please sign in to comment.