Skip to content

Commit bc4cc07

Browse files
authored
Fix async probes missing localhost (#2407)
1 parent 90d000e commit bc4cc07

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/probe/probe.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,14 @@ func (p *Probe) probeContainer() bool {
175175
}
176176

177177
func (p *Probe) httpProbe() error {
178+
// to mimic k8s probe functionality
179+
targetHost := p.HTTPGet.Host
180+
if p.HTTPGet.Host == "" {
181+
targetHost = "localhost"
182+
}
183+
178184
targetURL := s.EnsurePrefix(
179-
net.JoinHostPort(p.HTTPGet.Host, p.HTTPGet.Port.String())+s.EnsurePrefix(p.HTTPGet.Path, "/"),
185+
net.JoinHostPort(targetHost, p.HTTPGet.Port.String())+s.EnsurePrefix(p.HTTPGet.Path, "/"),
180186
"http://",
181187
)
182188

@@ -215,8 +221,14 @@ func (p *Probe) httpProbe() error {
215221
}
216222

217223
func (p *Probe) tcpProbe() error {
224+
// to mimic k8s probe functionality
225+
targetHost := p.TCPSocket.Host
226+
if p.TCPSocket.Host == "" {
227+
targetHost = "localhost"
228+
}
229+
218230
timeout := time.Duration(p.TimeoutSeconds) * time.Second
219-
address := net.JoinHostPort(p.TCPSocket.Host, p.TCPSocket.Port.String())
231+
address := net.JoinHostPort(targetHost, p.TCPSocket.Port.String())
220232
conn, err := net.DialTimeout("tcp", address, timeout)
221233
if err != nil {
222234
return err

0 commit comments

Comments
 (0)