Skip to content

Commit 8f50908

Browse files
committed
Use default node startup timeout when the MHC value is nil
1 parent d0e1d89 commit 8f50908

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

api/v1alpha4/common_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const (
9696

9797
var (
9898
// ZeroDuration is a zero value of the metav1.Duration type.
99-
ZeroDuration = metav1.Duration{Duration: 0}
99+
ZeroDuration = metav1.Duration{}
100100
)
101101

102102
// MachineAddressType describes a valid MachineAddress type.

api/v1alpha4/machinehealthcheck_webhook.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import (
3030
)
3131

3232
var (
33-
// Default time allowed for a node to start up. Can be made longer as part of
34-
// spec if required for particular provider.
33+
// DefaultNodeStartupTimeout is the time allowed for a node to start up.
34+
// Can be made longer as part of spec if required for particular provider.
3535
// 10 minutes should allow the instance to start and the node to join the
3636
// cluster on most providers.
37-
defaultNodeStartupTimeout = metav1.Duration{Duration: 10 * time.Minute}
37+
DefaultNodeStartupTimeout = metav1.Duration{Duration: 10 * time.Minute}
3838
// Minimum time allowed for a node to start up.
3939
minNodeStartupTimeout = metav1.Duration{Duration: 30 * time.Second}
4040
// We allow users to disable the nodeStartupTimeout by setting the duration to 0.
@@ -75,7 +75,7 @@ func (m *MachineHealthCheck) Default() {
7575
}
7676

7777
if m.Spec.NodeStartupTimeout == nil {
78-
m.Spec.NodeStartupTimeout = &defaultNodeStartupTimeout
78+
m.Spec.NodeStartupTimeout = &DefaultNodeStartupTimeout
7979
}
8080
}
8181

controllers/machinehealthcheck_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,13 @@ func (r *MachineHealthCheckReconciler) reconcile(ctx context.Context, logger log
209209
// do sort to avoid keep changing m.Status as the returned machines are not in order
210210
sort.Strings(m.Status.Targets)
211211

212+
nodeStartupTimeout := m.Spec.NodeStartupTimeout
213+
if nodeStartupTimeout == nil {
214+
nodeStartupTimeout = &clusterv1.DefaultNodeStartupTimeout
215+
}
216+
212217
// health check all targets and reconcile mhc status
213-
healthy, unhealthy, nextCheckTimes := r.healthCheckTargets(targets, logger, *m.Spec.NodeStartupTimeout)
218+
healthy, unhealthy, nextCheckTimes := r.healthCheckTargets(targets, logger, *nodeStartupTimeout)
214219
m.Status.CurrentHealthy = int32(len(healthy))
215220

216221
var unhealthyLimitKey, unhealthyLimitValue interface{}

0 commit comments

Comments
 (0)