diff --git a/e2e/dragonfly_controller_test.go b/e2e/dragonfly_controller_test.go index a191d81..9a64117 100644 --- a/e2e/dragonfly_controller_test.go +++ b/e2e/dragonfly_controller_test.go @@ -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 @@ -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 @@ -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()) diff --git a/internal/controller/dragonfly_controller.go b/internal/controller/dragonfly_controller.go index 9d2f00a..b640ac9 100644 --- a/internal/controller/dragonfly_controller.go +++ b/internal/controller/dragonfly_controller.go @@ -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 { @@ -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 { @@ -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 } diff --git a/internal/controller/dragonfly_pod_lifecycle_controller.go b/internal/controller/dragonfly_pod_lifecycle_controller.go index 22c5caa..a598238 100644 --- a/internal/controller/dragonfly_pod_lifecycle_controller.go +++ b/internal/controller/dragonfly_pod_lifecycle_controller.go @@ -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") diff --git a/internal/controller/util.go b/internal/controller/util.go index eb91857..5a017d1 100644 --- a/internal/controller/util.go +++ b/internal/controller/util.go @@ -34,8 +34,6 @@ import ( const ( PhaseResourcesCreated string = "resources-created" - PhaseResourcesUpdated string = "resources-updated" - PhaseReady string = "ready" )