Provisioning: Gracefully handle AlreadyExists errors (#102758)

* Provisioning: Gracefully handle AlreadyExists errors

When this occurs, the job is already in the store. The vast majority of use-cases (which currently is all of them!) will
be fine with just accepting that as an OK.

* chore: make update-workspace

* fix: return error, but expect it in tests
This commit is contained in:
Mariell Hoversholm
2025-03-25 10:41:38 +01:00
committed by GitHub
parent 3aa3371f58
commit 0536aa2d52
4 changed files with 45 additions and 50 deletions
@@ -371,6 +371,10 @@ func (rc *RepositoryController) addSyncJob(ctx context.Context, obj *provisionin
Pull: syncOptions,
},
})
if apierrors.IsAlreadyExists(err) {
logging.FromContext(ctx).Info("sync job already exists, nothing triggered")
return nil
}
if err != nil {
// FIXME: should we update the status of the repository if we fail to add the job?
return fmt.Errorf("error adding sync job: %w", err)