Skip to content

Commit

Permalink
Merge pull request #2116 from gauravkghildiyal/migrator-integration-test
Browse files Browse the repository at this point in the history
Integration tests for NEG DualStack Migrator
  • Loading branch information
k8s-ci-robot authored May 16, 2023
2 parents 6032fad + 5fdee99 commit a97609e
Show file tree
Hide file tree
Showing 7 changed files with 1,140 additions and 52 deletions.
9 changes: 6 additions & 3 deletions pkg/neg/syncers/dualstack/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"k8s.io/ingress-gce/pkg/neg/types"
"k8s.io/klog/v2"
"k8s.io/utils/clock"
)

const (
Expand Down Expand Up @@ -90,6 +91,7 @@ type Migrator struct {
// attach operations.
fractionForPendingAttachmentThreshold float64

clock clock.Clock
logger klog.Logger
}

Expand All @@ -116,6 +118,7 @@ func NewMigrator(enableDualStackNEG bool, syncer syncable, syncerKey types.NegSy
previousDetachThreshold: defaultPreviousDetachThreshold,
fractionOfMigratingEndpoints: defaultFractionOfMigratingEndpoints,
fractionForPendingAttachmentThreshold: defaultFractionForPendingAttachmentThreshold,
clock: clock.RealClock{},
logger: logger.WithName("DualStackMigrator"),
}
}
Expand Down Expand Up @@ -202,9 +205,9 @@ func (d *Migrator) Continue(err error) {
// NEG Detach succeeded; unpause after migrationWaitDuration and trigger
// resync.
d.continueInProgress = true
d.previousDetach = time.Now()
d.previousDetach = d.clock.Now()
go func() {
time.Sleep(d.migrationWaitDuration)
d.clock.Sleep(d.migrationWaitDuration)

d.mu.Lock()
d.paused = false
Expand Down Expand Up @@ -303,7 +306,7 @@ func (d *Migrator) manyEndpointsWaitingToBeAttached(addCount, committedCount, mi
func (d *Migrator) tooLongSincePreviousDetach() bool {
d.mu.Lock()
defer d.mu.Unlock()
return time.Since(d.previousDetach) >= d.previousDetachThreshold
return d.clock.Since(d.previousDetach) >= d.previousDetachThreshold
}

// findAndFilterMigrationEndpoints will filter out the migration endpoints from
Expand Down
Loading

0 comments on commit a97609e

Please sign in to comment.