Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-505: Added changes for Avoiding 2 Restarts when Both Version and cm changes are done at the same time #506

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions pkg/controller/pravegacluster/pravegacluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions pkg/controller/pravegacluster/pravegacluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down