Hi, I'm writing a controller reconciled based on a CRD. I'd like to setup an IndexField() based on the Pod annotation. I found this function will block until the informer is synced, which delay the startup of the controller.
I dug into the cause, find that in IndexField(), it calls GetInformer() with default option blockUntilSync=true.
|
func (ic *informerCache) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error { |
|
informer, err := ic.GetInformer(ctx, obj) |
|
if err != nil { |
|
return err |
|
} |
|
return indexByField(informer, field, extractValue) |
|
} |
|
// GetOptions provides configuration to customize the behavior when |
|
// getting an informer. |
|
type GetOptions struct { |
|
// BlockUntilSynced controls if the informer retrieval will block until the informer is synced. Defaults to `true`. |
|
BlockUntilSynced *bool |
|
} |
I'd like to know
- Is this an expected behavior?
- Where should I put the
IndexField(), taking controller-runtime/examples/crd/main.go as an example?
It's NOT an urgent issue, as the delayed startup won't cause too much trouble. Thanks!
Hi, I'm writing a controller reconciled based on a CRD. I'd like to setup an
IndexField()based on the Pod annotation. I found this function will block until the informer is synced, which delay the startup of the controller.I dug into the cause, find that in
IndexField(), it callsGetInformer()with default optionblockUntilSync=true.controller-runtime/pkg/cache/informer_cache.go
Lines 215 to 221 in 129853d
controller-runtime/pkg/cache/internal/informers.go
Lines 123 to 128 in 129853d
I'd like to know
IndexField(), taking controller-runtime/examples/crd/main.go as an example?It's NOT an urgent issue, as the delayed startup won't cause too much trouble. Thanks!