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 557: Many Pravega Spec parameters are still not updatable at runtime #561

Merged
merged 3 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
36 changes: 29 additions & 7 deletions pkg/controller/pravegacluster/pravegacluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ func (r *ReconcilePravegaCluster) reconcileSegmentStoreConfigMap(p *pravegav1bet
//restarting sts pods
if !r.checkVersionUpgradeTriggered(p) && !segmentStorePortUpdated {
err = r.restartStsPod(p)

if err != nil {
return err
}
Expand Down Expand Up @@ -625,6 +626,23 @@ func (r *ReconcilePravegaCluster) deployController(p *pravegav1beta1.PravegaClus
err = r.client.Create(context.TODO(), deployment)
if err != nil && !errors.IsAlreadyExists(err) {
return err
} else if errors.IsAlreadyExists(err) {
foundDeploy := &appsv1.Deployment{}
name := p.DeploymentNameForController()
err := r.client.Get(context.TODO(),
types.NamespacedName{Name: name, Namespace: p.Namespace}, foundDeploy)
if err != nil {
return err
}

if !r.checkVersionUpgradeTriggered(p) && !r.isRollbackTriggered(p) {
foundDeploy.Spec.Template = deployment.Spec.Template
err = r.client.Update(context.TODO(), foundDeploy)
if err != nil {
return fmt.Errorf("failed to update deployment set: %v", err)
}

}
}
return nil
}
Expand All @@ -650,19 +668,23 @@ func (r *ReconcilePravegaCluster) deploySegmentStore(p *pravegav1beta1.PravegaCl
if err != nil {
return err
}
if statefulSet.Spec.Template.Spec.Containers[0].Ports[0].ContainerPort != sts.Spec.Template.Spec.Containers[0].Ports[0].ContainerPort {
sts.Spec.Template.Spec.Containers[0].Ports[0].ContainerPort = statefulSet.Spec.Template.Spec.Containers[0].Ports[0].ContainerPort
sts.Spec.Template.Spec.Containers[0].ReadinessProbe = statefulSet.Spec.Template.Spec.Containers[0].ReadinessProbe
sts.Spec.Template.Spec.Containers[0].LivenessProbe = statefulSet.Spec.Template.Spec.Containers[0].LivenessProbe

if !r.checkVersionUpgradeTriggered(p) && !r.isRollbackTriggered(p) {
originalsts := sts.DeepCopy()
sts.Spec.Template = statefulSet.Spec.Template
err = r.client.Update(context.TODO(), sts)
if err != nil {
return fmt.Errorf("failed to update stateful set: %v", err)
}
err = r.restartStsPod(p)
if err != nil {
return err

if !reflect.DeepEqual(originalsts.Spec.Template, sts.Spec.Template) {
err = r.restartStsPod(p)
SrishT marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}
}
}

owRefs := sts.GetOwnerReferences()
if hasOldVersionOwnerReference(owRefs) {
log.Printf("Deleting SSS STS as it has old version owner ref.")
Expand Down
56 changes: 56 additions & 0 deletions pkg/controller/pravegacluster/pravegacluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,62 @@ var _ = Describe("PravegaCluster Controller", func() {
})
})

Context("checking updateStatefulset", func() {
var (
err1 error
str1 string
)
BeforeEach(func() {

p.WithDefaults()
sts := &appsv1.StatefulSet{}
name := p.StatefulSetNameForSegmentstore()
foundPravega := &v1beta1.PravegaCluster{}
_ = client.Get(context.TODO(), req.NamespacedName, foundPravega)
foundPravega.Spec.Pravega.SegmentStoreServiceAccountName = "testsa"
client.Update(context.TODO(), foundPravega)
_, _ = r.Reconcile(req)
err1 = r.client.Get(context.TODO(),
types.NamespacedName{Name: name, Namespace: p.Namespace}, sts)

str1 = fmt.Sprintf("%s", sts.Spec.Template.Spec.ServiceAccountName)
})
It("should not give error", func() {
Ω(err1).Should(BeNil())
})
It("service account name should get updated correctly", func() {
Ω(str1).To(Equal("testsa"))
})
})

Context("checking updateDeployment", func() {
var (
err1 error
str1 string
)
BeforeEach(func() {

p.WithDefaults()
deploy := &appsv1.Deployment{}
name := p.DeploymentNameForController()
foundPravega := &v1beta1.PravegaCluster{}
_ = client.Get(context.TODO(), req.NamespacedName, foundPravega)
foundPravega.Spec.Pravega.ControllerServiceAccountName = "testsa"
client.Update(context.TODO(), foundPravega)
_, _ = r.Reconcile(req)
err1 = r.client.Get(context.TODO(),
types.NamespacedName{Name: name, Namespace: p.Namespace}, deploy)

str1 = fmt.Sprintf("%s", deploy.Spec.Template.Spec.ServiceAccountName)
})
It("should not give error", func() {
Ω(err1).Should(BeNil())
})
It("service account name should get updated correctly", func() {
Ω(str1).To(Equal("testsa"))
})
})

Context("checking checkVersionUpgradeTriggered function", func() {
var (
ans1, ans2 bool
Expand Down