Skip to content

Commit 46d9b99

Browse files
Merge pull request #315 from leelavg/up-csi-op
controllers: update csi-op subscription based on provider version
2 parents e771af6 + c4bca5c commit 46d9b99

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

internal/controller/operatorconfigmap_controller.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ func (c *OperatorConfigMapReconciler) Reconcile(ctx context.Context, req ctrl.Re
266266
return ctrl.Result{}, err
267267
}
268268

269+
if err := c.reconcileCephCSIOperatorSubscription(); err != nil {
270+
c.log.Error(err, "unable to reconcile Ceph CSI Operator subscription")
271+
return ctrl.Result{}, err
272+
}
273+
269274
if err := c.ensureConsolePlugin(); err != nil {
270275
c.log.Error(err, "unable to deploy client console")
271276
return ctrl.Result{}, err
@@ -654,6 +659,23 @@ func (c *OperatorConfigMapReconciler) reconcileCSIAddonsOperatorSubscription() e
654659
return nil
655660
}
656661

662+
func (c *OperatorConfigMapReconciler) reconcileCephCSIOperatorSubscription() error {
663+
cephCsiOperatorSubscription, err := c.getSubscriptionByPackageName("cephcsi-operator")
664+
if kerrors.IsNotFound(err) {
665+
cephCsiOperatorSubscription, err = c.getSubscriptionByPackageName("ceph-csi-operator")
666+
}
667+
if err != nil {
668+
return err
669+
}
670+
if c.subscriptionChannel != "" && c.subscriptionChannel != cephCsiOperatorSubscription.Spec.Channel {
671+
cephCsiOperatorSubscription.Spec.Channel = c.subscriptionChannel
672+
if err := c.update(cephCsiOperatorSubscription); err != nil {
673+
return fmt.Errorf("failed to update subscription channel of 'cephcsi-operator' to %v: %v", c.subscriptionChannel, err)
674+
}
675+
}
676+
return nil
677+
}
678+
657679
func (c *OperatorConfigMapReconciler) reconcileWebhookService() error {
658680
svc := &corev1.Service{}
659681
svc.Name = templates.WebhookServiceName

0 commit comments

Comments
 (0)