remove TODOs from http package and prober
This commit is contained in:
parent
537941765f
commit
1df526b3f7
@ -49,16 +49,11 @@ const maxProbeRetries = 3
|
|||||||
|
|
||||||
// Prober helps to check the liveness/readiness/startup of a container.
|
// Prober helps to check the liveness/readiness/startup of a container.
|
||||||
type prober struct {
|
type prober struct {
|
||||||
exec execprobe.Prober
|
exec execprobe.Prober
|
||||||
// probe types needs different httpprobe instances so they don't
|
http httpprobe.Prober
|
||||||
// share a connection pool which can cause collisions to the
|
tcp tcpprobe.Prober
|
||||||
// same host:port and transient failures. See #49740.
|
grpc grpcprobe.Prober
|
||||||
readinessHTTP httpprobe.Prober
|
runner kubecontainer.CommandRunner
|
||||||
livenessHTTP httpprobe.Prober
|
|
||||||
startupHTTP httpprobe.Prober
|
|
||||||
tcp tcpprobe.Prober
|
|
||||||
grpc grpcprobe.Prober
|
|
||||||
runner kubecontainer.CommandRunner
|
|
||||||
|
|
||||||
recorder record.EventRecorder
|
recorder record.EventRecorder
|
||||||
}
|
}
|
||||||
@ -71,14 +66,12 @@ func newProber(
|
|||||||
|
|
||||||
const followNonLocalRedirects = false
|
const followNonLocalRedirects = false
|
||||||
return &prober{
|
return &prober{
|
||||||
exec: execprobe.New(),
|
exec: execprobe.New(),
|
||||||
readinessHTTP: httpprobe.New(followNonLocalRedirects),
|
http: httpprobe.New(followNonLocalRedirects),
|
||||||
livenessHTTP: httpprobe.New(followNonLocalRedirects),
|
tcp: tcpprobe.New(),
|
||||||
startupHTTP: httpprobe.New(followNonLocalRedirects),
|
grpc: grpcprobe.New(),
|
||||||
tcp: tcpprobe.New(),
|
runner: runner,
|
||||||
grpc: grpcprobe.New(),
|
recorder: recorder,
|
||||||
runner: runner,
|
|
||||||
recorder: recorder,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,14 +172,7 @@ func (pb *prober) runProbe(probeType probeType, p *v1.Probe, pod *v1.Pod, status
|
|||||||
url := formatURL(scheme, host, port, path)
|
url := formatURL(scheme, host, port, path)
|
||||||
headers := buildHeader(p.HTTPGet.HTTPHeaders)
|
headers := buildHeader(p.HTTPGet.HTTPHeaders)
|
||||||
klog.V(4).InfoS("HTTP-Probe Headers", "headers", headers)
|
klog.V(4).InfoS("HTTP-Probe Headers", "headers", headers)
|
||||||
switch probeType {
|
return pb.http.Probe(url, headers, timeout)
|
||||||
case liveness:
|
|
||||||
return pb.livenessHTTP.Probe(url, headers, timeout)
|
|
||||||
case startup:
|
|
||||||
return pb.startupHTTP.Probe(url, headers, timeout)
|
|
||||||
default:
|
|
||||||
return pb.readinessHTTP.Probe(url, headers, timeout)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if p.TCPSocket != nil {
|
if p.TCPSocket != nil {
|
||||||
port, err := extractPort(p.TCPSocket.Port, container)
|
port, err := extractPort(p.TCPSocket.Port, container)
|
||||||
|
@ -52,7 +52,6 @@ var ProberResults = metrics.NewCounterVec(
|
|||||||
// probe (AddPod). The worker periodically probes its assigned container and caches the results. The
|
// probe (AddPod). The worker periodically probes its assigned container and caches the results. The
|
||||||
// manager use the cached probe results to set the appropriate Ready state in the PodStatus when
|
// manager use the cached probe results to set the appropriate Ready state in the PodStatus when
|
||||||
// requested (UpdatePodStatus). Updating probe parameters is not currently supported.
|
// requested (UpdatePodStatus). Updating probe parameters is not currently supported.
|
||||||
// TODO: Move liveness probing out of the runtime, to here.
|
|
||||||
type Manager interface {
|
type Manager interface {
|
||||||
// AddPod creates new probe workers for every container probe. This should be called for every
|
// AddPod creates new probe workers for every container probe. This should be called for every
|
||||||
// pod created.
|
// pod created.
|
||||||
|
@ -261,9 +261,7 @@ func (w *worker) doProbe() (keepGoing bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: in order for exec probes to correctly handle downward API env, we must be able to reconstruct
|
// Note, exec probe does NOT have access to pod environment variables or downward API
|
||||||
// the full container environment here, OR we must make a call to the CRI in order to get those environment
|
|
||||||
// values from the running container.
|
|
||||||
result, err := w.probeManager.prober.probe(w.probeType, w.pod, status, w.container, w.containerID)
|
result, err := w.probeManager.prober.probe(w.probeType, w.pod, status, w.container, w.containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Prober error, throw away the result.
|
// Prober error, throw away the result.
|
||||||
|
@ -51,9 +51,10 @@ func NewWithTLSConfig(config *tls.Config, followNonLocalRedirects bool) Prober {
|
|||||||
// We do not want the probe use node's local proxy set.
|
// We do not want the probe use node's local proxy set.
|
||||||
transport := utilnet.SetTransportDefaults(
|
transport := utilnet.SetTransportDefaults(
|
||||||
&http.Transport{
|
&http.Transport{
|
||||||
TLSClientConfig: config,
|
TLSClientConfig: config,
|
||||||
DisableKeepAlives: true,
|
DisableKeepAlives: true,
|
||||||
Proxy: http.ProxyURL(nil),
|
Proxy: http.ProxyURL(nil),
|
||||||
|
DisableCompression: true, // removes Accept-Encoding header
|
||||||
})
|
})
|
||||||
return httpProber{transport, followNonLocalRedirects}
|
return httpProber{transport, followNonLocalRedirects}
|
||||||
}
|
}
|
||||||
@ -68,9 +69,8 @@ type httpProber struct {
|
|||||||
followNonLocalRedirects bool
|
followNonLocalRedirects bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Probe returns a ProbeRunner capable of running an HTTP check.
|
// Probe returns a probing result. The only case the err will not be nil is when there is a problem reading the response body.
|
||||||
func (pr httpProber) Probe(url *url.URL, headers http.Header, timeout time.Duration) (probe.Result, string, error) {
|
func (pr httpProber) Probe(url *url.URL, headers http.Header, timeout time.Duration) (probe.Result, string, error) {
|
||||||
pr.transport.DisableCompression = true // removes Accept-Encoding header
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
Transport: pr.transport,
|
Transport: pr.transport,
|
||||||
|
Loading…
Reference in New Issue
Block a user