diff --git a/components/operator/controller/component_mgr.go b/components/operator/controller/component_mgr.go index da1efea..15d0f72 100644 --- a/components/operator/controller/component_mgr.go +++ b/components/operator/controller/component_mgr.go @@ -156,7 +156,6 @@ func (cm *ComponentManager) ReconcileApps(ctx context.Context, namespace string) Name: compName, Commit: comp.Commit, App: appDep.Spec.App.Name, - AppCommit: appDep.Spec.App.Commit, Image: image, ImagePullPolicy: appDep.Spec.App.ImagePullSecretName, }, diff --git a/k8s/client.go b/k8s/client.go index 67b7a15..bbbb3db 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -70,7 +70,11 @@ func (c *Client) Upsert(ctx context.Context, obj client.Object, dryRun bool) err if dryRun { opts = append(opts, client.DryRunAll) } - err = c.Update(ctx, obj, opts...) + if err = c.Update(ctx, obj, opts...); IsConflict(err) { + // Perform single retry on conflict. + err = c.Update(ctx, obj, opts...) + } + } // Restore TypeMeta. obj.GetObjectKind().SetGroupVersionKind(orig.GetObjectKind().GroupVersionKind()) diff --git a/k8s/utils.go b/k8s/utils.go index 5b28216..c999a68 100644 --- a/k8s/utils.go +++ b/k8s/utils.go @@ -103,6 +103,13 @@ func IsAlreadyExists(err error) bool { return apierrors.IsAlreadyExists(err) } +func IsConflict(err error) bool { + if err == nil { + return false + } + return apierrors.IsConflict(err) +} + func ToString(obj client.Object) string { gvk := obj.GetObjectKind().GroupVersionKind() grp := gvk.Group