Skip to content

Commit 9cb2a9b

Browse files
committed
Update to use c.clock.Now() instead of time.Now()
1 parent a5f71ad commit 9cb2a9b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pkg/controllers/state/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ func (c *Cluster) UpdatePodHealthyNodePoolScheduledTime(ctx context.Context, nod
397397
// If the pod is scheduled to a nodePool and if the nodePool has NodeRegistrationHealthy=true
398398
// then mark the time when we thought it can schedule to now.
399399
if nodePool.StatusConditions().IsTrue(v1.ConditionTypeNodeRegistrationHealthy) {
400-
c.podHealthyNodePoolScheduledTime.LoadOrStore(nn, time.Now())
400+
c.podHealthyNodePoolScheduledTime.LoadOrStore(nn, c.clock.Now())
401401
} else {
402402
// If the pod was scheduled to a healthy nodePool earlier but is now getting scheduled to an
403403
// unhealthy one then we need to delete its entry from the map because it will not schedule successfully

pkg/controllers/state/suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ var _ = Describe("Pod Healthy NodePool", func() {
127127
setTime := cluster.PodSchedulingSuccessTimeRegistrationHealthyCheck(client.ObjectKeyFromObject(pod))
128128
Expect(setTime.IsZero()).To(BeFalse())
129129

130+
fakeClock.Step(time.Minute)
130131
// We try to update pod schedulable time, but it should not change as we have already stored it
131132
cluster.UpdatePodHealthyNodePoolScheduledTime(ctx, nodePool.Name, []*corev1.Pod{pod}...)
132133
Expect(cluster.PodSchedulingSuccessTimeRegistrationHealthyCheck(client.ObjectKeyFromObject(pod))).To(Equal(setTime))

0 commit comments

Comments
 (0)