Skip to content

Commit

Permalink
remove resources updated clause
Browse files Browse the repository at this point in the history
  • Loading branch information
Pothulapati committed Oct 10, 2023
1 parent 75567ed commit 2be307f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
12 changes: 3 additions & 9 deletions e2e/dragonfly_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,9 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, func() {
}, &df)
Expect(err).To(BeNil())

df.Spec.Env = []corev1.EnvVar{
{
Name: "DFLY_requirepass",
Value: "df-pass-2",
},
}
df.Spec.Image = fmt.Sprintf("%s:%s", resources.DragonflyImage, "v1.9.0")
err = k8sClient.Update(ctx, &df)
Expect(err).To(BeNil())

time.Sleep(30 * time.Second)

// Wait until Dragonfly object is marked resources-created
Expand All @@ -324,7 +318,7 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, func() {
Expect(err).To(BeNil())

// check for env
Expect(ss.Spec.Template.Spec.Containers[0].Env).To(Equal(df.Spec.Env))
Expect(ss.Spec.Template.Spec.Containers[0].Image).To(Equal(df.Spec.Image))

// Check if there are relevant pods with expected roles
var pods corev1.PodList
Expand All @@ -337,7 +331,7 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, func() {
// Get the pods along with their roles
podRoles := make(map[string][]string)
for _, pod := range pods.Items {
Expect(pod.Spec.Containers[0].Env).To(Equal(df.Spec.Env))
Expect(pod.Spec.Containers[0].Image).To(Equal(df.Spec.Image))
role, ok := pod.Labels[resources.Role]
// error if there is no label
Expect(ok).To(BeTrue())
Expand Down
14 changes: 4 additions & 10 deletions internal/controller/dragonfly_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (r *DragonflyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
}

return ctrl.Result{}, nil
} else if df.Status.Phase == PhaseResourcesUpdated {
} else {
// perform a rollout only if the pod spec has changed
var statefulSet appsv1.StatefulSet
if err := r.Get(ctx, client.ObjectKey{Namespace: df.Namespace, Name: df.Name}, &statefulSet); err != nil {
Expand All @@ -237,12 +237,12 @@ func (r *DragonflyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{Requeue: true}, err
}

r.EventRecorder.Event(&df, corev1.EventTypeNormal, "Resources", "Performing a rollout")
// requeue so that the rollout is processed
return ctrl.Result{Requeue: true}, nil
}
r.EventRecorder.Event(&df, corev1.EventTypeNormal, "Resources", "Performing a rollout")
} else {
// This is an Update

// Is this a Dragonfly object update?
log.Info("updating existing resources")
newResources, err := resources.GetDragonflyResources(ctx, &df)
if err != nil {
Expand All @@ -260,12 +260,6 @@ func (r *DragonflyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

log.Info("Updated resources for object")

df.Status.Phase = PhaseResourcesUpdated
if err := r.Status().Update(ctx, &df); err != nil {
log.Error(err, "could not update the Dragonfly object")
return ctrl.Result{Requeue: true}, err
}

// requeuing so that the statefulset is updated with the new config (if any)
return ctrl.Result{RequeueAfter: 5 * time.Second}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/dragonfly_pod_lifecycle_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *DfPodLifeCycleReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}

r.EventRecorder.Event(dfi.df, corev1.EventTypeNormal, "Replication", "configured replication for first time")
} else if dfi.df.Status.Phase == PhaseReady || dfi.df.Status.Phase == PhaseResourcesUpdated {
} else if dfi.df.Status.Phase == PhaseReady {
// Pod event either from a restart or a resource update (i.e less/more replicas)
log.Info("Pod restart from a ready Dragonfly instance")

Expand Down
2 changes: 0 additions & 2 deletions internal/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (
const (
PhaseResourcesCreated string = "resources-created"

PhaseResourcesUpdated string = "resources-updated"

PhaseReady string = "ready"
)

Expand Down

0 comments on commit 2be307f

Please sign in to comment.