Skip to content

Commit

Permalink
Update to use c.clock.Now() instead of time.Now()
Browse files Browse the repository at this point in the history
  • Loading branch information
jigisha620 committed Mar 5, 2025
1 parent a5f71ad commit 9cb2a9b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/controllers/state/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (c *Cluster) UpdatePodHealthyNodePoolScheduledTime(ctx context.Context, nod
// If the pod is scheduled to a nodePool and if the nodePool has NodeRegistrationHealthy=true
// then mark the time when we thought it can schedule to now.
if nodePool.StatusConditions().IsTrue(v1.ConditionTypeNodeRegistrationHealthy) {
c.podHealthyNodePoolScheduledTime.LoadOrStore(nn, time.Now())
c.podHealthyNodePoolScheduledTime.LoadOrStore(nn, c.clock.Now())
} else {
// If the pod was scheduled to a healthy nodePool earlier but is now getting scheduled to an
// unhealthy one then we need to delete its entry from the map because it will not schedule successfully
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/state/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ var _ = Describe("Pod Healthy NodePool", func() {
setTime := cluster.PodSchedulingSuccessTimeRegistrationHealthyCheck(client.ObjectKeyFromObject(pod))
Expect(setTime.IsZero()).To(BeFalse())

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

0 comments on commit 9cb2a9b

Please sign in to comment.