Skip to content
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

Code cleanup for for probe/http #78031

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/kubelet/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/probe"
execprobe "k8s.io/kubernetes/pkg/probe/exec"
httprobe "k8s.io/kubernetes/pkg/probe/http"
httpprobe "k8s.io/kubernetes/pkg/probe/http"
tcprobe "k8s.io/kubernetes/pkg/probe/tcp"
"k8s.io/utils/exec"

Expand All @@ -50,8 +50,8 @@ type prober struct {
// probe types needs different httprobe instances so they don't
// share a connection pool which can cause collsions to the
// same host:port and transient failures. See #49740.
readinessHTTP httprobe.Prober
livenessHTTP httprobe.Prober
readinessHTTP httpprobe.Prober
livenessHTTP httpprobe.Prober
tcp tcprobe.Prober
runner kubecontainer.ContainerCommandRunner

Expand All @@ -69,8 +69,8 @@ func newProber(
const followNonLocalRedirects = false
return &prober{
exec: execprobe.New(),
readinessHTTP: httprobe.New(followNonLocalRedirects),
livenessHTTP: httprobe.New(followNonLocalRedirects),
readinessHTTP: httpprobe.New(followNonLocalRedirects),
livenessHTTP: httpprobe.New(followNonLocalRedirects),
tcp: tcprobe.New(),
runner: runner,
refManager: refManager,
Expand Down
12 changes: 8 additions & 4 deletions pkg/probe/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func TestHTTPProbeProxy(t *testing.T) {
defer unsetEnv("no_proxy")()
defer unsetEnv("NO_PROXY")()

prober := New(true)
followNonLocalRedirects := true
prober := New(followNonLocalRedirects)

go func() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -122,7 +123,8 @@ func TestHTTPProbeChecker(t *testing.T) {
}
}

prober := New(true)
followNonLocalRedirects := true
prober := New(followNonLocalRedirects)
testCases := []struct {
handler func(w http.ResponseWriter, r *http.Request)
reqHeaders http.Header
Expand Down Expand Up @@ -299,14 +301,16 @@ func TestHTTPProbeChecker_NonLocalRedirects(t *testing.T) {
}
for desc, test := range testCases {
t.Run(desc+"-local", func(t *testing.T) {
prober := New(false)
followNonLocalRedirects := false
prober := New(followNonLocalRedirects)
target, err := url.Parse(server.URL + "/redirect?loc=" + url.QueryEscape(test.redirect))
require.NoError(t, err)
result, _, _ := prober.Probe(target, nil, wait.ForeverTestTimeout)
assert.Equal(t, test.expectLocalResult, result)
})
t.Run(desc+"-nonlocal", func(t *testing.T) {
prober := New(true)
followNonLocalRedirects := true
prober := New(followNonLocalRedirects)
target, err := url.Parse(server.URL + "/redirect?loc=" + url.QueryEscape(test.redirect))
require.NoError(t, err)
result, _, _ := prober.Probe(target, nil, wait.ForeverTestTimeout)
Expand Down