Skip to content

Commit

Permalink
review: explicitly remove source
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pana <[email protected]>
  • Loading branch information
acpana committed Oct 11, 2023
1 parent 7296196 commit 6a260a3
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pkg/controller/syncset/syncset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,28 @@ func (r *ReconcileSyncSet) Reconcile(ctx context.Context, request reconcile.Requ
return reconcile.Result{}, err
}
}
sk := aggregator.Key{Source: "syncset", ID: request.NamespacedName.String()}

if !exists || !syncset.GetDeletionTimestamp().IsZero() {
log.V(logging.DebugLevel).Info("handling SyncSet delete", "instance", syncset)

gvks := make([]schema.GroupVersionKind, 0)
if exists && syncset.GetDeletionTimestamp().IsZero() {
log.V(logging.DebugLevel).Info("handling SyncSet update", "instance", syncset)
if err := r.cacheManager.RemoveSource(ctx, sk); err != nil {
syncsetTr.TryCancelExpect(syncset)

for _, entry := range syncset.Spec.GVKs {
gvks = append(gvks, schema.GroupVersionKind{Group: entry.Group, Version: entry.Version, Kind: entry.Kind})
return reconcile.Result{}, fmt.Errorf("synceset-controller: error removing source: %w", err)
}

syncsetTr.CancelExpect(syncset)

return reconcile.Result{}, nil
}

log.V(logging.DebugLevel).Info("handling SyncSet update", "instance", syncset)
gvks := []schema.GroupVersionKind{}
for _, entry := range syncset.Spec.GVKs {
gvks = append(gvks, schema.GroupVersionKind{Group: entry.Group, Version: entry.Version, Kind: entry.Kind})
}

sk := aggregator.Key{Source: "syncset", ID: request.NamespacedName.String()}
if err := r.cacheManager.UpsertSource(ctx, sk, gvks); err != nil {
syncsetTr.TryCancelExpect(syncset)

Expand Down

0 comments on commit 6a260a3

Please sign in to comment.