Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests for NEG DualStack Migrator #2116

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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