Skip to content

Commit

Permalink
resolve feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon committed Apr 27, 2023
1 parent 478a2ac commit 57cc098
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/controllertest/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/internal/source/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pkg/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions pkg/source/source_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit 57cc098

Please sign in to comment.