Skip to content

Commit

Permalink
fix race
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Zhang committed Oct 12, 2023
1 parent 5bb835f commit f9bf622
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/controllers/workgenerator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,23 +272,25 @@ func (r *Reconciler) syncAllWork(ctx context.Context, resourceBinding *fleetv1be
if err != nil {
return false, err
}
activeWork[work.Name] = work
newWork = append(newWork, work)
} else {
simpleManifests = append(simpleManifests, fleetv1beta1.Manifest(selectedResource))
}
}
if len(simpleManifests) != 0 {
// generate a work object for the manifests if there are still any non enveloped resources
newWork = append(newWork, generateSnapshotWorkObj(workNamePrefix, resourceBinding, snapshot, simpleManifests))
work := generateSnapshotWorkObj(workNamePrefix, resourceBinding, snapshot, simpleManifests)
activeWork[work.Name] = work
newWork = append(newWork, work)
} else {
klog.V(2).InfoS("the snapshot contains enveloped resource only", "snapshot", klog.KObj(snapshot))
}
// issue all the create/update requests for the corresponding works for each snapshot in parallel
for i := range newWork {
work := newWork[i]
activeWork[work.Name] = work
errs.Go(func() error {
updated, err := r.upsertWork(cctx, work, existingWorks[work.Name], snapshot)
updated, err := r.upsertWork(cctx, work, existingWorks[work.Name].DeepCopy(), snapshot)
if err != nil {
return err
}
Expand Down

0 comments on commit f9bf622

Please sign in to comment.