Skip to content

Commit 1212847

Browse files
controller: add comments to the tricky parts
Signed-off-by: Steve Kuznetsov <[email protected]> Upstream-repository: operator-lifecycle-manager Upstream-commit: 3aa08f8693ab6f1bb2a39f3dae8d5d5e54207dd2
1 parent 5ad4987 commit 1212847

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

staging/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

Lines changed: 8 additions & 0 deletions
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

staging/operator-lifecycle-manager/pkg/controller/operators/olm/operator.go

Lines changed: 8 additions & 0 deletions
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

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/operator.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)