diff --git a/pkg/controller/pravegacluster/pravegacluster_controller.go b/pkg/controller/pravegacluster/pravegacluster_controller.go index 2547e8cee..7822e3c8e 100644 --- a/pkg/controller/pravegacluster/pravegacluster_controller.go +++ b/pkg/controller/pravegacluster/pravegacluster_controller.go @@ -242,9 +242,11 @@ func (r *ReconcilePravegaCluster) reconcileControllerConfigMap(p *pravegav1beta1 return err } //restarting controller pods - err = r.restartDeploymentPod(p) - if err != nil { - return err + if !r.checkVersionUpgradeTriggered(p) { + err = r.restartDeploymentPod(p) + if err != nil { + return err + } } } } @@ -274,15 +276,26 @@ func (r *ReconcilePravegaCluster) reconcileSegmentStoreConfigMap(p *pravegav1bet return err } //restarting sts pods - err = r.restartStsPod(p) - if err != nil { - return err + if !r.checkVersionUpgradeTriggered(p) { + err = r.restartStsPod(p) + if err != nil { + return err + } } } } return nil } +func (r *ReconcilePravegaCluster) checkVersionUpgradeTriggered(p *pravegav1beta1.PravegaCluster) bool { + currentPravegaCluster := &pravegav1beta1.PravegaCluster{} + err := r.client.Get(context.TODO(), types.NamespacedName{Name: p.Name, Namespace: p.Namespace}, currentPravegaCluster) + if err == nil && currentPravegaCluster.Status.CurrentVersion != p.Spec.Version { + return true + } + return false +} + func (r *ReconcilePravegaCluster) reconcilePdb(p *pravegav1beta1.PravegaCluster) (err error) { err = r.reconcileControllerPdb(p) diff --git a/pkg/controller/pravegacluster/pravegacluster_controller_test.go b/pkg/controller/pravegacluster/pravegacluster_controller_test.go index c8eb62d82..841439ff2 100644 --- a/pkg/controller/pravegacluster/pravegacluster_controller_test.go +++ b/pkg/controller/pravegacluster/pravegacluster_controller_test.go @@ -393,6 +393,28 @@ var _ = Describe("PravegaCluster Controller", func() { }) }) + Context("checking checkVersionUpgradeTriggered function", func() { + var ( + ans1, ans2 bool + ) + BeforeEach(func() { + client = fake.NewFakeClient(p) + r = &ReconcilePravegaCluster{client: client, scheme: s} + res, err = r.Reconcile(req) + + ans1 = r.checkVersionUpgradeTriggered(p) + p.Spec.Version = "0.8.0" + ans2 = r.checkVersionUpgradeTriggered(p) + }) + It("ans1 should be false", func() { + Ω(ans1).To(Equal(false)) + }) + It("ans2 should be true", func() { + Ω(ans2).To(Equal(true)) + }) + + }) + Context("reconcileFinalizers", func() { BeforeEach(func() { p.WithDefaults()