diff --git a/controllers/resources/processor.go b/controllers/resources/processor.go index e5fdcc1b..bdfee2aa 100644 --- a/controllers/resources/processor.go +++ b/controllers/resources/processor.go @@ -125,10 +125,12 @@ func (r *Processor) HandleSection(ctx context.Context, tnt capsulev1beta2.Tenant objLabels[Label] = fmt.Sprintf("%d", resourceIndex) objLabels[tenantLabel] = tnt.GetName() - + // processedRaw is used to avoid concurrent map writes during iteration of namespaced items: + // the objects will be then added to processed variable. + // // processed will contain the sets of resources replicated, both for the raw and the Namespaced ones: // these are required to perform a final pruning once the replication has been occurred. - processed := sets.NewString() + processedRaw, processed := []string{}, sets.NewString() tntNamespaces := sets.NewString(tnt.Status.Namespaces...) @@ -204,7 +206,7 @@ func (r *Processor) HandleSection(ctx context.Context, tnt capsulev1beta2.Tenant replicatedItem.Namespace = ns.Name replicatedItem.APIVersion = obj.GetAPIVersion() - processed.Insert(replicatedItem.String()) + processedRaw = append(processedRaw, replicatedItem.String()) }(obj) } @@ -218,6 +220,8 @@ func (r *Processor) HandleSection(ctx context.Context, tnt capsulev1beta2.Tenant } } + processed.Insert(processedRaw...) + for rawIndex, item := range spec.RawItems { template := string(item.Raw)