Change:
pull-kubernetes-unit TestController2updateCronJob/spec.schedulechanged TestController2_updateCronJob /sig apps /assign
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the label and provide further guidance. The label can be by org members by writing in a comment. <detailsInstructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
This is important to resolve before promotion to v1
looks like the cause was
This function should be related.
Another one:
When the flake happen, there are messages like When the system is overloaded, it would happen. is trying to replace the current queue in tests with a mock.
Yeah, I spoke with to make sure we use a mock of the queue so we only get the most important bit of information ignoring the remaining parts

Discussion:
"fmt" "reflect" "strings" <del> "sync" </del> "testing" "time"

} <ins> type fakeQueue struct { workqueue.RateLimitingInterface t   time.Duration key interface{} } func (f *fakeQueue) AddAfter(key interface{}, t time.Duration) { f.t = t f.key = key } </ins> // this test will take around 61 seconds to complete func TestController2_updateCronJob(t *testing.T) { cjc := &fakeCJControl{} jc := &fakeJobControl{} type fields struct { <del> queue          workqueue.RateLimitingInterface </del> <ins> queue          *fakeQueue </ins> recorder       record.EventRecorder jobControl     jobControlInterface cronJobControl cjControlInterface

newJobSchedule string } tests := []struct { <del> name                 string fields               fields args                 args deltaTimeForQueue    time.Duration roundOffTimeDuration time.Duration </del> <ins> name              string fields            fields args              args deltaTimeForQueue time.Duration </ins> }{ { name: "spec.template changed", fields: fields{ <del> queue:          workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-update-cronjob"), </del> <ins> queue:          &fakeQueue{RateLimitingInterface: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-update-cronjob")}, </ins> recorder:       record.NewFakeRecorder(10), jobControl:     jc, cronJobControl: cjc,

Spec: jobSpec(), }, }, <del> deltaTimeForQueue:    0 * time.Second, roundOffTimeDuration: 500*time.Millisecond + nextScheduleDelta, </del> <ins> deltaTimeForQueue: 0 * time.Second, </ins> }, { name: "spec.schedule changed", fields: fields{ <del> queue:          workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-update-cronjob"), </del> <ins> queue:          &fakeQueue{RateLimitingInterface: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-update-cronjob")}, </ins> recorder:       record.NewFakeRecorder(10), jobControl:     jc, cronJobControl: cjc,

oldJobSchedule: "30 * * * *", newJobSchedule: "*/1 * * * *", }, <del> deltaTimeForQueue:    1*time.Second + nextScheduleDelta, roundOffTimeDuration: 750 * time.Millisecond, </del> <ins> deltaTimeForQueue: 1*time.Second + nextScheduleDelta, </ins> }, // TODO: Add more test cases for updating scheduling. }

cronJobControl: tt.fields.cronJobControl, } jm.now = justASecondBeforeTheHour <del> now := time.Now() then := time.Now() wg := sync.WaitGroup{} wg.Add(1) go func() { now = time.Now() jm.queue.Get() then = time.Now() wg.Done() return }() </del> jm.updateCronJob(&cj, &newCj) <del> wg.Wait() d := then.Sub(now) if d.Round(tt.roundOffTimeDuration).Seconds() != tt.deltaTimeForQueue.Round(tt.roundOffTimeDuration).Seconds() { t.Errorf("Expected %#v got %#v", tt.deltaTimeForQueue.Round(tt.roundOffTimeDuration).String(), d.Round(tt.roundOffTimeDuration).String()) </del> <ins> if tt.fields.queue.t.Seconds() != tt.deltaTimeForQueue.Seconds() { t.Errorf("Expected %#v got %#v", tt.deltaTimeForQueue.Seconds(), tt.fields.queue.t.Seconds()) </ins> } }) }