Skip to content

Commit 68d9943

Browse files
author
Ankita Thomas
committed
Retry conflicting update after fetching latest pod spec
1 parent e72d31a commit 68d9943

File tree

1 file changed

+14
-5
lines changed
  • pkg/controller/registry/reconciler

1 file changed

+14
-5
lines changed

pkg/controller/registry/reconciler/grpc.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package reconciler
33
import (
44
"context"
55
"fmt"
6-
76
"github.com/operator-framework/api/pkg/operators/v1alpha1"
87
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
98
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
@@ -14,7 +13,9 @@ import (
1413
v1 "k8s.io/api/core/v1"
1514
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1615
"k8s.io/apimachinery/pkg/labels"
16+
"k8s.io/apimachinery/pkg/types"
1717
"k8s.io/apimachinery/pkg/util/intstr"
18+
"sigs.k8s.io/controller-runtime/pkg/client"
1819
)
1920

2021
const CatalogSourceUpdateKey = "catalogsource.operators.coreos.com/update"
@@ -198,12 +199,20 @@ func (c *GrpcRegistryReconciler) ensureUpdatePod(source grpcCatalogSourceDecorat
198199
updatePod.Labels[CatalogSourceUpdateKey] = ""
199200

200201
// Update the update pod to promote it to serving pod
201-
_, 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())
202+
forceApply := true
203+
opts := metav1.PatchOptions{
204+
Force: &forceApply,
205+
FieldManager: "operator-lifecycle-manager-registry-reconciler",
204206
}
205207

206-
break
208+
updatePodBytes, err := client.Apply.Data(updatePod)
209+
if err != nil {
210+
return errors.Wrapf(err, "error serializing updated catalog source pod to bytes: %s", source.Pod().GetName())
211+
}
212+
_, err = c.OpClient.KubernetesInterface().CoreV1().Pods(source.GetNamespace()).Patch(context.TODO(), updatePod.Name, types.ApplyPatchType, updatePodBytes, opts)
213+
if err != nil {
214+
return errors.Wrapf(err, "error updating catalog source pod: %s", source.Pod().GetName())
215+
}
207216
}
208217
}
209218

0 commit comments

Comments
 (0)