@@ -3,12 +3,14 @@ package reconciler
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "k8s.io/apiserver/pkg/registry/generic/registry"
6
7
7
8
"github.com/operator-framework/api/pkg/operators/v1alpha1"
8
9
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
9
10
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
10
11
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
11
12
"github.com/pkg/errors"
13
+ apierrors "k8s.io/apimachinery/pkg/api/errors"
12
14
"github.com/sirupsen/logrus"
13
15
corev1 "k8s.io/api/core/v1"
14
16
v1 "k8s.io/api/core/v1"
@@ -199,11 +201,24 @@ func (c *GrpcRegistryReconciler) ensureUpdatePod(source grpcCatalogSourceDecorat
199
201
200
202
// Update the update pod to promote it to serving pod
201
203
_ , err := c .OpClient .KubernetesInterface ().CoreV1 ().Pods (source .GetNamespace ()).Update (context .TODO (), updatePod , metav1.UpdateOptions {})
202
- if err ! = nil {
203
- return errors . Wrapf ( err , "error creating new pod: %s" , source . Pod (). GetName ())
204
+ if err = = nil {
205
+ break
204
206
}
207
+ if ! (apierrors .IsConflict (err ) && err .Error () == registry .OptimisticLockErrorMsg ) {
208
+ return errors .Wrapf (err , "error updating catalog source pod labels: %s" , source .Pod ().GetName ())
209
+ }
210
+
211
+ // stale pod, fetch and try again
212
+ updatePod , err = c .Lister .CoreV1 ().PodLister ().Pods (source .GetNamespace ()).Get (updatePod .Name )
213
+ updatePod .Labels [CatalogSourceLabelKey ] = source .GetName ()
214
+ updatePod .Labels [CatalogSourceUpdateKey ] = ""
205
215
206
- break
216
+ // Update the update pod to promote it to serving pod
217
+ _ , err = c .OpClient .KubernetesInterface ().CoreV1 ().Pods (source .GetNamespace ()).Update (context .TODO (), updatePod , metav1.UpdateOptions {})
218
+ if err == nil {
219
+ break
220
+ }
221
+ return errors .Wrapf (err , "error updating catalog source pod labels: %s" , source .Pod ().GetName ())
207
222
}
208
223
}
209
224
0 commit comments