Skip to content

Commit

Permalink
Use HEAD requests instead of GET in probes
Browse files Browse the repository at this point in the history
Also expand curl arguments for readability.

Signed-off-by: Dmitry Tantsur <[email protected]>
  • Loading branch information
dtantsur committed Mar 7, 2025
1 parent fb78d2c commit 755f10f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/ironic/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,26 @@ func newURLProbeHandler(ironic *metal3api.Ironic, https bool, port int, path str
proto = "https"
}

curlArgs := "-sSkL"
curlCmd := []string{
"curl",
"--head",
"--insecure",
// NOTE(dtantsur): prevent redirects from being treated as success
"--location",
"--silent",
"--show-error",
// NOTE(dtantsur): --head outputs headers even with --silent
"--output", "/dev/null",
}
if requiresOk {
curlArgs += "f"
curlCmd = append(curlCmd, "--fail")
}

// NOTE(dtantsur): we could use HTTP GET probe but we cannot pass the certificate there.
url := fmt.Sprintf("%s://127.0.0.1:%d%s", proto, port, path)
return corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{"curl", curlArgs, url},
Command: append(curlCmd, url),
},
}
}
Expand Down

0 comments on commit 755f10f

Please sign in to comment.