Skip to content

Commit 3da3f65

Browse files
authored
enhance pod refresh (#89)
1 parent 4c3045d commit 3da3f65

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

controllers/namespacescope_controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,8 @@ func (r *NamespaceScopeReconciler) RestartPods(labels map[string]string, cm *cor
639639
continue
640640
}
641641
// Delete operator pod to refresh it
642-
podLabels := pod.GetLabels()
643-
_, ok := podLabels["olm.operatorGroup"]
642+
podAnno := pod.GetAnnotations()
643+
_, ok := podAnno["olm.operatorGroup"]
644644
if ok {
645645
if err := r.Client.Delete(ctx, &pod); err != nil {
646646
klog.Errorf("Failed to delete pods %s in namespace %s: %v", pod.Name, pod.Namespace, err)
@@ -678,12 +678,11 @@ func (r *NamespaceScopeReconciler) RestartPods(labels map[string]string, cm *cor
678678
klog.Errorf("Failed to get deployment %s in namespace %s: %v", deploymentName, namespace, err)
679679
return err
680680
}
681-
originalDeploy := deploy
682681
if deploy.Spec.Template.Annotations == nil {
683682
deploy.Spec.Template.Annotations = make(map[string]string)
684683
}
685684
deploy.Spec.Template.Annotations["nss.ibm.com/namespaceList"] = annotationValue
686-
if err := r.Patch(ctx, deploy, client.MergeFrom(originalDeploy)); err != nil {
685+
if err := r.Update(ctx, deploy); err != nil {
687686
klog.Errorf("Failed to update the annotation of the deployment %s in namespace %s: %v", deploymentName, namespace, err)
688687
return err
689688
}

0 commit comments

Comments
 (0)