Skip to content

Commit bc669b1

Browse files
committed
Log the syncing source when WaitForSync fails
A controller may watch several sources. This change makes it easier to debug which source fails to be synced.
1 parent e3347b5 commit bc669b1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/internal/controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (c *Controller[request]) Start(ctx context.Context) error {
197197
}
198198
didStartSyncingSource.Store(true)
199199
if err := syncingSource.WaitForSync(sourceStartCtx); err != nil {
200-
err := fmt.Errorf("failed to wait for %s caches to sync: %w", c.Name, err)
200+
err := fmt.Errorf("failed to wait for %s caches to sync %v: %w", c.Name, syncingSource, err)
201201
log.Error(err, "Could not wait for Cache to sync")
202202
sourceStartErrChan <- err
203203
}

pkg/internal/controller/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ var _ = Describe("controller", func() {
171171

172172
err = ctrl.Start(context.TODO())
173173
Expect(err).To(HaveOccurred())
174-
Expect(err.Error()).To(ContainSubstring("failed to wait for testcontroller caches to sync: timed out waiting for cache to be synced"))
174+
Expect(err.Error()).To(ContainSubstring("failed to wait for testcontroller caches to sync kind source: *v1.Deployment: timed out waiting for cache to be synced"))
175175
})
176176

177177
It("should not error when controller Start context is cancelled during Sources WaitForSync", func() {

0 commit comments

Comments
 (0)