Skip to content

Commit 6386ed1

Browse files
committed
Make timeout comparison more obvious
1 parent 78c46b7 commit 6386ed1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

controllers/machinehealthcheck_targets.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ const (
4444
EventDetectedUnhealthy string = "DetectedUnhealthy"
4545
)
4646

47+
var (
48+
// We allow users to disable the nodeStartupTimeout by setting the duration to 0.
49+
disabledNodeStartupTimeout = metav1.Duration{Duration: 0}
50+
)
51+
4752
// healthCheckTarget contains the information required to perform a health check
4853
// on the node to determine if any remediation is required.
4954
type healthCheckTarget struct {
@@ -120,7 +125,7 @@ func (t *healthCheckTarget) needsRemediation(logger logr.Logger, timeoutForMachi
120125

121126
// the node has not been set yet
122127
if t.Node == nil {
123-
if isZero(timeoutForMachineToHaveNode) {
128+
if timeoutForMachineToHaveNode.Seconds() == disabledNodeStartupTimeout.Seconds() {
124129
// Startup timeout is disabled so no need to go any further.
125130
// No node yet to check conditions, can return early here.
126131
return false, 0
@@ -342,7 +347,3 @@ func shouldSkipRemediation(m *clusterv1.Machine) (bool, string) {
342347

343348
return false, ""
344349
}
345-
346-
func isZero(d time.Duration) bool {
347-
return d == time.Duration(0)
348-
}

0 commit comments

Comments
 (0)