Skip to content

Commit

Permalink
drop special logic when handling kubelet probe header for istio mTLS (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
izabelacg authored May 29, 2024
1 parent ff4756a commit 7d52a43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ const (
// KubeletProbeHeaderName is the header name to augment the probes, because
// Istio with mTLS rewrites probes, but their probes pass a different
// user-agent.
//
// Deprecated: use knative.dev/networking/pkg/http/header.UserAgentKey
KubeletProbeHeaderName = "K-Kubelet-Probe"
)

// IsKubeletProbe returns true if the request is a Kubernetes probe.
func IsKubeletProbe(r *http.Request) bool {
return strings.HasPrefix(r.Header.Get(UserAgentKey), KubeProbeUAPrefix) ||
r.Header.Get(KubeletProbeHeaderName) != ""
return strings.HasPrefix(r.Header.Get(UserAgentKey), KubeProbeUAPrefix)
}
6 changes: 3 additions & 3 deletions network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func TestIsKubeletProbe(t *testing.T) {
if IsKubeletProbe(req) {
t.Error("Not a kubelet probe but counted as such")
}
req.Header.Set(KubeletProbeHeaderName, "no matter")
if !IsKubeletProbe(req) {
t.Error("kubelet probe but not counted as such")
req.Header.Set(KubeletProbeHeaderName, "custom header no longer used")
if IsKubeletProbe(req) {
t.Error("custom kubelet probe header should no longer be used")
}
}

0 comments on commit 7d52a43

Please sign in to comment.