@@ -22,6 +22,7 @@ import (
2222 "time"
2323
2424 corev1 "k8s.io/api/core/v1"
25+ apierrors "k8s.io/apimachinery/pkg/api/errors"
2526 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2627 corev1apply "k8s.io/client-go/applyconfigurations/core/v1"
2728 "sigs.k8s.io/controller-runtime/pkg/builder"
@@ -34,6 +35,7 @@ import (
3435 "sigs.k8s.io/yaml"
3536
3637 "github.com/crunchydata/postgres-operator/internal/controller/runtime"
38+ "github.com/crunchydata/postgres-operator/internal/logging"
3739 "github.com/crunchydata/postgres-operator/internal/naming"
3840)
3941
@@ -123,6 +125,12 @@ func (r *InstallationReconciler) Reconcile(
123125 // TODO: Check for corev1.NamespaceTerminatingCause after
124126 // k8s.io/apimachinery@v0.25; see https://issue.k8s.io/108528.
125127
128+ // Write conflicts are returned as errors; log and retry with backoff.
129+ if err != nil && apierrors .IsConflict (err ) {
130+ logging .FromContext (ctx ).Info ("Requeue" , "reason" , err )
131+ err , result .Requeue , result .RequeueAfter = nil , true , 0
132+ }
133+
126134 return result , err
127135}
128136
@@ -132,6 +140,12 @@ func (r *InstallationReconciler) reconcile(ctx context.Context, read *corev1.Sec
132140 return err
133141 }
134142
143+ // We GET-extract-PATCH the Secret and do not build it up from scratch.
144+ // Send the ResourceVersion from the GET in the body of every PATCH.
145+ if len (read .ResourceVersion ) != 0 {
146+ write .WithResourceVersion (read .ResourceVersion )
147+ }
148+
135149 // Read the Installation from the Secret, if any.
136150 var installation Installation
137151 if yaml .Unmarshal (read .Data [KeyBridgeToken ], & installation ) != nil {
0 commit comments