diff --git a/pkg/controller/controllertest/util.go b/pkg/controller/controllertest/util.go index f7d9dfbdcb..95b1318575 100644 --- a/pkg/controller/controllertest/util.go +++ b/pkg/controller/controllertest/util.go @@ -147,7 +147,7 @@ func (f *FakeInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEve return nil, nil } -// RemoveEventHandler does nothing. +// RemoveEventHandler removes an EventHandler to the fake Informers. func (f *FakeInformer) RemoveEventHandler(handle cache.ResourceEventHandlerRegistration) error { eh, ok := handle.(*eventHandlerWrapper) if !ok { diff --git a/pkg/internal/source/kind.go b/pkg/internal/source/kind.go index 910aa30ce1..a4f46c9f7d 100644 --- a/pkg/internal/source/kind.go +++ b/pkg/internal/source/kind.go @@ -92,7 +92,7 @@ func getInformer(ctx context.Context, informerCache cache.Cache, resourceType cl // Tries to get an informer until it returns true, // an error or the specified context is cancelled or expired. if err := wait.PollImmediateUntilWithContext(ctx, 10*time.Second, func(pollCtx context.Context) (bool, error) { - // Lookup the Informer from the Cache and add an EventHandler which populates the Queue + // Lookup the Informer from the Cache. i, lastErr = informerCache.GetInformer(pollCtx, resourceType) if lastErr != nil { kindMatchErr := &meta.NoKindMatchError{} @@ -155,7 +155,7 @@ func (ks *Kind) registerEventHandler(ctx context.Context, eventHandler toolscach return err } - // Wait for the cache to sync before adding the EventHandlers. + // Wait for the cache to sync. if !ks.Cache.WaitForCacheSync(ctx) { if ctx.Err() != nil { return fmt.Errorf("cache did not sync: %w", ctx.Err()) @@ -203,14 +203,14 @@ func (ks *Kind) WaitForSync(ctx context.Context) error { if errors.Is(ctx.Err(), context.Canceled) { return nil } - return errors.New("timed out waiting for cache to be synced") + return errors.New("timed out trying to get an informer from cache and waiting for cache to be synced") } } // Stop is internal and should be called only by the Controller to stop the Source. It should block until the // Source has stopped. // Stop can be called multiple times, and should be idempotent. If the Source is not running, Stop will prevent -// the Source from starting in the future without error. +// the Source from starting in the future. func (ks *Kind) Stop() error { ks.mu.Lock() defer ks.mu.Unlock() diff --git a/pkg/source/source.go b/pkg/source/source.go index 402a20fc4e..4d5c333578 100644 --- a/pkg/source/source.go +++ b/pkg/source/source.go @@ -211,7 +211,7 @@ func (cs *Channel) loop() error { // Stop is internal and should be called only by the Controller to stop the Source. It should block until the // Source has stopped. // Stop can be called multiple times, and should be idempotent. If the Source is not running, Stop will prevent -// the Source from starting in the future without error. +// the Source from starting in the future. func (cs *Channel) Stop() error { cs.mu.Lock() diff --git a/pkg/source/source_integration_test.go b/pkg/source/source_integration_test.go index 4c0de6d0b3..7c8ad6b310 100644 --- a/pkg/source/source_integration_test.go +++ b/pkg/source/source_integration_test.go @@ -264,7 +264,7 @@ var _ = Describe("Source", func() { err = instance2.Stop() Expect(err).NotTo(HaveOccurred()) - By("Updating a Deployment and expecting the UpdateEvent.") + By("Updating a Deployment and expecting the UpdateEvent only via first kind source.") updated = created.DeepCopy() updated.Labels = map[string]string{"biz": "buz"} updated, err = client.Update(ctx, updated, metav1.UpdateOptions{}) @@ -292,7 +292,7 @@ var _ = Describe("Source", func() { err = instance1.Stop() Expect(err).NotTo(HaveOccurred()) - By("Deleting a Deployment and expecting the Delete.") + By("Deleting a Deployment and expecting no DeleteEvent via the first kind source.") err = client.Delete(ctx, created.Name, metav1.DeleteOptions{}) Expect(err).NotTo(HaveOccurred())