Skip to content

Commit

Permalink
controller: add comments to the tricky parts
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <[email protected]>
  • Loading branch information
stevekuznetsov committed Sep 27, 2023
1 parent 6bb58e6 commit ead44da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
if canFilter {
return nil
}

// for each GVR, we may have more than one labelling controller active; each of which detects
// when it is done; we allocate a space in complete[gvr][idx] to hold that outcome and track it
var idx int
if _, exists := complete[gvr]; exists {
idx = len(complete[gvr])
Expand All @@ -405,6 +408,11 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
queueinformer.WithLogger(op.logger),
queueinformer.WithInformer(informer),
queueinformer.WithSyncer(sync(func() bool {
// this function is called by the processor when it detects that it's work is done - so, for that
// particular labelling action on that particular GVR, all objects are in the correct state. when
// that action is done, we need to further know if that was the last action to be completed, as
// when every action we know about has been completed, we re-start the process to allow the future
// invocation of this process to filter informers (canFilter = true) and elide all this logic
completeLock.Lock()
complete[gvr][idx] = true
allDone := true
Expand Down
8 changes: 8 additions & 0 deletions pkg/controller/operators/olm/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
if canFilter {
return nil
}

// for each GVR, we may have more than one labelling controller active; each of which detects
// when it is done; we allocate a space in complete[gvr][idx] to hold that outcome and track it
var idx int
if _, exists := complete[gvr]; exists {
idx = len(complete[gvr])
Expand All @@ -521,6 +524,11 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
queueinformer.WithLogger(op.logger),
queueinformer.WithInformer(informer),
queueinformer.WithSyncer(sync(func() bool {
// this function is called by the processor when it detects that it's work is done - so, for that
// particular labelling action on that particular GVR, all objects are in the correct state. when
// that action is done, we need to further know if that was the last action to be completed, as
// when every action we know about has been completed, we re-start the process to allow the future
// invocation of this process to filter informers (canFilter = true) and elide all this logic
completeLock.Lock()
complete[gvr][idx] = true
allDone := true
Expand Down

0 comments on commit ead44da

Please sign in to comment.