Skip to content

Commit 3aa08f8

Browse files
controller: add comments to the tricky parts
Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 7ef3712 commit 3aa08f8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pkg/controller/operators/catalog/operator.go

+8
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
387387
if canFilter {
388388
return nil
389389
}
390+
391+
// for each GVR, we may have more than one labelling controller active; each of which detects
392+
// when it is done; we allocate a space in complete[gvr][idx] to hold that outcome and track it
390393
var idx int
391394
if _, exists := complete[gvr]; exists {
392395
idx = len(complete[gvr])
@@ -405,6 +408,11 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
405408
queueinformer.WithLogger(op.logger),
406409
queueinformer.WithInformer(informer),
407410
queueinformer.WithSyncer(sync(func() bool {
411+
// this function is called by the processor when it detects that it's work is done - so, for that
412+
// particular labelling action on that particular GVR, all objects are in the correct state. when
413+
// that action is done, we need to further know if that was the last action to be completed, as
414+
// when every action we know about has been completed, we re-start the process to allow the future
415+
// invocation of this process to filter informers (canFilter = true) and elide all this logic
408416
completeLock.Lock()
409417
complete[gvr][idx] = true
410418
allDone := true

pkg/controller/operators/olm/operator.go

+8
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
504504
if canFilter {
505505
return nil
506506
}
507+
508+
// for each GVR, we may have more than one labelling controller active; each of which detects
509+
// when it is done; we allocate a space in complete[gvr][idx] to hold that outcome and track it
507510
var idx int
508511
if _, exists := complete[gvr]; exists {
509512
idx = len(complete[gvr])
@@ -521,6 +524,11 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
521524
queueinformer.WithLogger(op.logger),
522525
queueinformer.WithInformer(informer),
523526
queueinformer.WithSyncer(sync(func() bool {
527+
// this function is called by the processor when it detects that it's work is done - so, for that
528+
// particular labelling action on that particular GVR, all objects are in the correct state. when
529+
// that action is done, we need to further know if that was the last action to be completed, as
530+
// when every action we know about has been completed, we re-start the process to allow the future
531+
// invocation of this process to filter informers (canFilter = true) and elide all this logic
524532
completeLock.Lock()
525533
complete[gvr][idx] = true
526534
allDone := true

0 commit comments

Comments
 (0)