Skip to content

Commit

Permalink
test: Fix ConsolidationState() test failure in state testing (#1957)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis authored and rschalo committed Feb 27, 2025
1 parent f23919e commit d112e1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/controllers/state/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,17 @@ func (c *Cluster) ConsolidationState() time.Time {
func (c *Cluster) Reset() {
c.mu.Lock()
defer c.mu.Unlock()
c.clusterState = time.Time{}
c.unsyncedStartTime = time.Time{}

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / Analyze Go

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)
c.nodes = map[string]*StateNode{}
c.nodeNameToProviderID = map[string]string{}
c.nodeClaimNameToProviderID = map[string]string{}
c.bindings = map[types.NamespacedName]string{}
c.antiAffinityPods = sync.Map{}
c.daemonSetPods = sync.Map{}
c.podAcks = sync.Map{}

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / Analyze Go

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)
c.podsSchedulingAttempted = sync.Map{}

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / Analyze Go

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)
c.podsSchedulableTimes = sync.Map{}

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / Analyze Go

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)
}

func (c *Cluster) GetDaemonSetPod(daemonset *appsv1.DaemonSet) *corev1.Pod {
Expand Down
11 changes: 10 additions & 1 deletion pkg/controllers/state/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"math/rand"
"net"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -1443,7 +1444,7 @@ var _ = Describe("Consolidated State", func() {
cluster.MarkUnconsolidated()
Expect(cluster.ConsolidationState()).ToNot(Equal(state))
})
It("should update the consolidated value when consolidation timeout (5m) has passed and state hasn't changed", func() {
It("should update the consolidated value when state timeout (5m) has passed and state hasn't changed", func() {
state := cluster.ConsolidationState()

fakeClock.Step(time.Minute)
Expand All @@ -1468,12 +1469,16 @@ var _ = Describe("Consolidated State", func() {
var _ = Describe("Data Races", func() {
It("should ensure that calling Synced() is valid while making updates to Nodes", func() {
cancelCtx, cancel := context.WithCancel(ctx)
var wg sync.WaitGroup
DeferCleanup(func() {
cancel()
wg.Wait()
})

// Keep calling Synced for the entirety of this test
wg.Add(1)
go func() {
defer wg.Done()
for {
_ = cluster.Synced(ctx)
if cancelCtx.Err() != nil {
Expand All @@ -1493,12 +1498,16 @@ var _ = Describe("Data Races", func() {
})
It("should ensure that calling Synced() is valid while making updates to NodeClaims", func() {
cancelCtx, cancel := context.WithCancel(ctx)
var wg sync.WaitGroup
DeferCleanup(func() {
cancel()
wg.Wait()
})

// Keep calling Synced for the entirety of this test
wg.Add(1)
go func() {
defer wg.Done()
for {
_ = cluster.Synced(ctx)
if cancelCtx.Err() != nil {
Expand Down

0 comments on commit d112e1b

Please sign in to comment.