From 9163550b780f03352973dde5954a2177356793e1 Mon Sep 17 00:00:00 2001 From: Marvin Cai Date: Wed, 23 Jun 2021 12:44:43 +0800 Subject: [PATCH 1/4] Update sink/source component observation logic. Update sink/source component observation so it can properly update status when sub-source is gone and allow recreation of the resource. --- controllers/sink.go | 94 ++++++++++++++++++------------------------- controllers/source.go | 94 ++++++++++++++++++------------------------- 2 files changed, 80 insertions(+), 108 deletions(-) diff --git a/controllers/sink.go b/controllers/sink.go index ae96b217f..3edc35748 100644 --- a/controllers/sink.go +++ b/controllers/sink.go @@ -32,14 +32,10 @@ import ( ) func (r *SinkReconciler) ObserveSinkStatefulSet(ctx context.Context, req ctrl.Request, sink *v1alpha1.Sink) error { - condition, ok := sink.Status.Conditions[v1alpha1.StatefulSet] - if !ok { - sink.Status.Conditions[v1alpha1.StatefulSet] = v1alpha1.ResourceCondition{ - Condition: v1alpha1.StatefulSetReady, - Status: metav1.ConditionFalse, - Action: v1alpha1.Create, - } - return nil + condition := v1alpha1.ResourceCondition{ + Condition: v1alpha1.StatefulSetReady, + Status: metav1.ConditionFalse, + Action: v1alpha1.Create, } statefulSet := &appsv1.StatefulSet{} @@ -49,33 +45,33 @@ func (r *SinkReconciler) ObserveSinkStatefulSet(ctx context.Context, req ctrl.Re }, statefulSet) if err != nil { if errors.IsNotFound(err) { - r.Log.Info("sink is not ready yet...") - return nil + r.Log.Info("sink statefulset is not found...") + } else { + sink.Status.Conditions[v1alpha1.StatefulSet] = condition + return err } - return err + } else { + // statefulset created, waiting it to be ready + condition.Action = v1alpha1.Wait } selector, err := metav1.LabelSelectorAsSelector(statefulSet.Spec.Selector) if err != nil { r.Log.Error(err, "error retrieving statefulSet selector") - return err + } else { + sink.Status.Selector = selector.String() } - sink.Status.Selector = selector.String() if *statefulSet.Spec.Replicas != *sink.Spec.Replicas { - condition.Status = metav1.ConditionFalse condition.Action = v1alpha1.Update - sink.Status.Conditions[v1alpha1.StatefulSet] = condition - return nil } if statefulSet.Status.ReadyReplicas == *sink.Spec.Replicas { condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue - } else { - condition.Action = v1alpha1.Wait } - sink.Status.Replicas = *statefulSet.Spec.Replicas + + sink.Status.Replicas = statefulSet.Status.ReadyReplicas sink.Status.Conditions[v1alpha1.StatefulSet] = condition return nil @@ -101,7 +97,7 @@ func (r *SinkReconciler) ApplySinkStatefulSet(ctx context.Context, req ctrl.Requ r.Log.Error(err, "failed to update the sink statefulSet") return err } - case v1alpha1.Wait: + case v1alpha1.Wait, v1alpha1.NoAction: // do nothing } @@ -109,18 +105,10 @@ func (r *SinkReconciler) ApplySinkStatefulSet(ctx context.Context, req ctrl.Requ } func (r *SinkReconciler) ObserveSinkService(ctx context.Context, req ctrl.Request, sink *v1alpha1.Sink) error { - condition, ok := sink.Status.Conditions[v1alpha1.Service] - if !ok { - sink.Status.Conditions[v1alpha1.Service] = v1alpha1.ResourceCondition{ - Condition: v1alpha1.ServiceReady, - Status: metav1.ConditionFalse, - Action: v1alpha1.Create, - } - return nil - } - - if condition.Status == metav1.ConditionTrue { - return nil + condition := v1alpha1.ResourceCondition{ + Condition: v1alpha1.ServiceReady, + Status: metav1.ConditionFalse, + Action: v1alpha1.Create, } svc := &corev1.Service{} @@ -129,13 +117,16 @@ func (r *SinkReconciler) ObserveSinkService(ctx context.Context, req ctrl.Reques if err != nil { if errors.IsNotFound(err) { r.Log.Info("service is not created...", "Name", sink.Name) - return nil + } else { + sink.Status.Conditions[v1alpha1.Service] = condition + return err } - return err + } else { + // service object doesn't have status, so once it's created just consider it's ready + condition.Action = v1alpha1.NoAction + condition.Status = metav1.ConditionTrue } - condition.Action = v1alpha1.NoAction - condition.Status = metav1.ConditionTrue sink.Status.Conditions[v1alpha1.Service] = condition return nil } @@ -154,7 +145,7 @@ func (r *SinkReconciler) ApplySinkService(ctx context.Context, req ctrl.Request, r.Log.Error(err, "failed to expose service for sink", "name", sink.Name) return err } - case v1alpha1.Wait: + case v1alpha1.Wait, v1alpha1.NoAction: // do nothing } @@ -167,18 +158,10 @@ func (r *SinkReconciler) ObserveSinkHPA(ctx context.Context, req ctrl.Request, s return nil } - condition, ok := sink.Status.Conditions[v1alpha1.HPA] - if !ok { - sink.Status.Conditions[v1alpha1.HPA] = v1alpha1.ResourceCondition{ - Condition: v1alpha1.HPAReady, - Status: metav1.ConditionFalse, - Action: v1alpha1.Create, - } - return nil - } - - if condition.Status == metav1.ConditionTrue { - return nil + condition := v1alpha1.ResourceCondition{ + Condition: v1alpha1.HPAReady, + Status: metav1.ConditionFalse, + Action: v1alpha1.Create, } hpa := &autov1.HorizontalPodAutoscaler{} @@ -187,13 +170,16 @@ func (r *SinkReconciler) ObserveSinkHPA(ctx context.Context, req ctrl.Request, s if err != nil { if errors.IsNotFound(err) { r.Log.Info("hpa is not created for sink...", "name", sink.Name) - return nil + } else { + sink.Status.Conditions[v1alpha1.HPA] = condition + return err } - return err + } else { + // HPA's status doesn't show its readiness, , so once it's created just consider it's ready + condition.Action = v1alpha1.NoAction + condition.Status = metav1.ConditionTrue } - condition.Action = v1alpha1.NoAction - condition.Status = metav1.ConditionTrue sink.Status.Conditions[v1alpha1.HPA] = condition return nil } @@ -217,7 +203,7 @@ func (r *SinkReconciler) ApplySinkHPA(ctx context.Context, req ctrl.Request, sin r.Log.Error(err, "failed to create pod autoscaler for sink", "name", sink.Name) return err } - case v1alpha1.Wait: + case v1alpha1.Wait, v1alpha1.NoAction: // do nothing } diff --git a/controllers/source.go b/controllers/source.go index e5447b9ce..0212b8c34 100644 --- a/controllers/source.go +++ b/controllers/source.go @@ -33,14 +33,10 @@ import ( func (r *SourceReconciler) ObserveSourceStatefulSet(ctx context.Context, req ctrl.Request, source *v1alpha1.Source) error { - condition, ok := source.Status.Conditions[v1alpha1.StatefulSet] - if !ok { - source.Status.Conditions[v1alpha1.StatefulSet] = v1alpha1.ResourceCondition{ - Condition: v1alpha1.StatefulSetReady, - Status: metav1.ConditionFalse, - Action: v1alpha1.Create, - } - return nil + condition := v1alpha1.ResourceCondition{ + Condition: v1alpha1.StatefulSetReady, + Status: metav1.ConditionFalse, + Action: v1alpha1.Create, } statefulSet := &appsv1.StatefulSet{} @@ -50,33 +46,33 @@ func (r *SourceReconciler) ObserveSourceStatefulSet(ctx context.Context, req ctr }, statefulSet) if err != nil { if errors.IsNotFound(err) { - r.Log.Info("source is not ready yet...") - return nil + r.Log.Info("sink statefulset is not found...") + } else { + source.Status.Conditions[v1alpha1.StatefulSet] = condition + return err } - return err + } else { + // statefulset created, waiting it to be ready + condition.Action = v1alpha1.Wait } selector, err := metav1.LabelSelectorAsSelector(statefulSet.Spec.Selector) if err != nil { r.Log.Error(err, "error retrieving statefulSet selector") - return err + } else { + source.Status.Selector = selector.String() } - source.Status.Selector = selector.String() if *statefulSet.Spec.Replicas != *source.Spec.Replicas { - condition.Status = metav1.ConditionFalse condition.Action = v1alpha1.Update - source.Status.Conditions[v1alpha1.StatefulSet] = condition - return nil } if statefulSet.Status.ReadyReplicas == *source.Spec.Replicas { condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue - } else { - condition.Action = v1alpha1.Wait } - source.Status.Replicas = *statefulSet.Spec.Replicas + + source.Status.Replicas = statefulSet.Status.ReadyReplicas source.Status.Conditions[v1alpha1.StatefulSet] = condition return nil @@ -103,7 +99,7 @@ func (r *SourceReconciler) ApplySourceStatefulSet(ctx context.Context, req ctrl. r.Log.Error(err, "failed to update the source statefulSet") return err } - case v1alpha1.Wait: + case v1alpha1.Wait, v1alpha1.NoAction: // do nothing } @@ -111,18 +107,10 @@ func (r *SourceReconciler) ApplySourceStatefulSet(ctx context.Context, req ctrl. } func (r *SourceReconciler) ObserveSourceService(ctx context.Context, req ctrl.Request, source *v1alpha1.Source) error { - condition, ok := source.Status.Conditions[v1alpha1.Service] - if !ok { - source.Status.Conditions[v1alpha1.Service] = v1alpha1.ResourceCondition{ - Condition: v1alpha1.ServiceReady, - Status: metav1.ConditionFalse, - Action: v1alpha1.Create, - } - return nil - } - - if condition.Status == metav1.ConditionTrue { - return nil + condition := v1alpha1.ResourceCondition{ + Condition: v1alpha1.ServiceReady, + Status: metav1.ConditionFalse, + Action: v1alpha1.Create, } svc := &corev1.Service{} @@ -131,13 +119,16 @@ func (r *SourceReconciler) ObserveSourceService(ctx context.Context, req ctrl.Re if err != nil { if errors.IsNotFound(err) { r.Log.Info("service is not created...", "Name", source.Name) - return nil + } else { + source.Status.Conditions[v1alpha1.Service] = condition + return err } - return err + } else { + // service object doesn't have status, so once it's created just consider it's ready + condition.Action = v1alpha1.NoAction + condition.Status = metav1.ConditionTrue } - condition.Action = v1alpha1.NoAction - condition.Status = metav1.ConditionTrue source.Status.Conditions[v1alpha1.Service] = condition return nil } @@ -156,7 +147,7 @@ func (r *SourceReconciler) ApplySourceService(ctx context.Context, req ctrl.Requ r.Log.Error(err, "failed to expose service for source", "name", source.Name) return err } - case v1alpha1.Wait: + case v1alpha1.Wait, v1alpha1.NoAction: // do nothing } @@ -169,18 +160,10 @@ func (r *SourceReconciler) ObserveSourceHPA(ctx context.Context, req ctrl.Reques return nil } - condition, ok := source.Status.Conditions[v1alpha1.HPA] - if !ok { - source.Status.Conditions[v1alpha1.HPA] = v1alpha1.ResourceCondition{ - Condition: v1alpha1.HPAReady, - Status: metav1.ConditionFalse, - Action: v1alpha1.Create, - } - return nil - } - - if condition.Status == metav1.ConditionTrue { - return nil + condition := v1alpha1.ResourceCondition{ + Condition: v1alpha1.HPAReady, + Status: metav1.ConditionFalse, + Action: v1alpha1.Create, } hpa := &autov1.HorizontalPodAutoscaler{} @@ -189,13 +172,16 @@ func (r *SourceReconciler) ObserveSourceHPA(ctx context.Context, req ctrl.Reques if err != nil { if errors.IsNotFound(err) { r.Log.Info("hpa is not created for source...", "name", source.Name) - return nil + } else { + source.Status.Conditions[v1alpha1.HPA] = condition + return err } - return err + } else { + // HPA's status doesn't show its readiness, , so once it's created just consider it's ready + condition.Action = v1alpha1.NoAction + condition.Status = metav1.ConditionTrue } - condition.Action = v1alpha1.NoAction - condition.Status = metav1.ConditionTrue source.Status.Conditions[v1alpha1.HPA] = condition return nil } @@ -219,7 +205,7 @@ func (r *SourceReconciler) ApplySourceHPA(ctx context.Context, req ctrl.Request, r.Log.Error(err, "failed to create pod autoscaler for source", "name", source.Name) return err } - case v1alpha1.Wait: + case v1alpha1.Wait, v1alpha1.NoAction: // do nothing } From 18b7e1e9db9ce629ac4d5020f8654de947db84be Mon Sep 17 00:00:00 2001 From: Marvin Cai Date: Fri, 25 Jun 2021 10:55:22 +0800 Subject: [PATCH 2/4] Address comments. Make default action Noaction and change according to observed status. --- controllers/sink.go | 29 +++++++++++++++-------------- controllers/source.go | 29 +++++++++++++++-------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/controllers/sink.go b/controllers/sink.go index 3edc35748..152b93015 100644 --- a/controllers/sink.go +++ b/controllers/sink.go @@ -35,7 +35,7 @@ func (r *SinkReconciler) ObserveSinkStatefulSet(ctx context.Context, req ctrl.Re condition := v1alpha1.ResourceCondition{ Condition: v1alpha1.StatefulSetReady, Status: metav1.ConditionFalse, - Action: v1alpha1.Create, + Action: v1alpha1.NoAction, } statefulSet := &appsv1.StatefulSet{} @@ -46,6 +46,9 @@ func (r *SinkReconciler) ObserveSinkStatefulSet(ctx context.Context, req ctrl.Re if err != nil { if errors.IsNotFound(err) { r.Log.Info("sink statefulset is not found...") + condition.Action = v1alpha1.Create + sink.Status.Conditions[v1alpha1.StatefulSet] = condition + return nil } else { sink.Status.Conditions[v1alpha1.StatefulSet] = condition return err @@ -55,25 +58,23 @@ func (r *SinkReconciler) ObserveSinkStatefulSet(ctx context.Context, req ctrl.Re condition.Action = v1alpha1.Wait } - selector, err := metav1.LabelSelectorAsSelector(statefulSet.Spec.Selector) - if err != nil { - r.Log.Error(err, "error retrieving statefulSet selector") - } else { - sink.Status.Selector = selector.String() - } - if *statefulSet.Spec.Replicas != *sink.Spec.Replicas { condition.Action = v1alpha1.Update } if statefulSet.Status.ReadyReplicas == *sink.Spec.Replicas { - condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue } - sink.Status.Replicas = statefulSet.Status.ReadyReplicas + sink.Status.Replicas = statefulSet.Status.Replicas sink.Status.Conditions[v1alpha1.StatefulSet] = condition + selector, err := metav1.LabelSelectorAsSelector(statefulSet.Spec.Selector) + if err != nil { + r.Log.Error(err, "error retrieving statefulSet selector") + return err + } + sink.Status.Selector = selector.String() return nil } @@ -108,7 +109,7 @@ func (r *SinkReconciler) ObserveSinkService(ctx context.Context, req ctrl.Reques condition := v1alpha1.ResourceCondition{ Condition: v1alpha1.ServiceReady, Status: metav1.ConditionFalse, - Action: v1alpha1.Create, + Action: v1alpha1.NoAction, } svc := &corev1.Service{} @@ -116,6 +117,7 @@ func (r *SinkReconciler) ObserveSinkService(ctx context.Context, req ctrl.Reques Name: spec.MakeSinkObjectMeta(sink).Name}, svc) if err != nil { if errors.IsNotFound(err) { + condition.Action = v1alpha1.Create r.Log.Info("service is not created...", "Name", sink.Name) } else { sink.Status.Conditions[v1alpha1.Service] = condition @@ -123,7 +125,6 @@ func (r *SinkReconciler) ObserveSinkService(ctx context.Context, req ctrl.Reques } } else { // service object doesn't have status, so once it's created just consider it's ready - condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue } @@ -161,7 +162,7 @@ func (r *SinkReconciler) ObserveSinkHPA(ctx context.Context, req ctrl.Request, s condition := v1alpha1.ResourceCondition{ Condition: v1alpha1.HPAReady, Status: metav1.ConditionFalse, - Action: v1alpha1.Create, + Action: v1alpha1.NoAction, } hpa := &autov1.HorizontalPodAutoscaler{} @@ -169,6 +170,7 @@ func (r *SinkReconciler) ObserveSinkHPA(ctx context.Context, req ctrl.Request, s Name: spec.MakeSinkObjectMeta(sink).Name}, hpa) if err != nil { if errors.IsNotFound(err) { + condition.Action = v1alpha1.Create r.Log.Info("hpa is not created for sink...", "name", sink.Name) } else { sink.Status.Conditions[v1alpha1.HPA] = condition @@ -176,7 +178,6 @@ func (r *SinkReconciler) ObserveSinkHPA(ctx context.Context, req ctrl.Request, s } } else { // HPA's status doesn't show its readiness, , so once it's created just consider it's ready - condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue } diff --git a/controllers/source.go b/controllers/source.go index 0212b8c34..cec3dd08e 100644 --- a/controllers/source.go +++ b/controllers/source.go @@ -36,7 +36,7 @@ func (r *SourceReconciler) ObserveSourceStatefulSet(ctx context.Context, req ctr condition := v1alpha1.ResourceCondition{ Condition: v1alpha1.StatefulSetReady, Status: metav1.ConditionFalse, - Action: v1alpha1.Create, + Action: v1alpha1.NoAction, } statefulSet := &appsv1.StatefulSet{} @@ -47,6 +47,9 @@ func (r *SourceReconciler) ObserveSourceStatefulSet(ctx context.Context, req ctr if err != nil { if errors.IsNotFound(err) { r.Log.Info("sink statefulset is not found...") + condition.Action = v1alpha1.Create + source.Status.Conditions[v1alpha1.StatefulSet] = condition + return nil } else { source.Status.Conditions[v1alpha1.StatefulSet] = condition return err @@ -56,25 +59,23 @@ func (r *SourceReconciler) ObserveSourceStatefulSet(ctx context.Context, req ctr condition.Action = v1alpha1.Wait } - selector, err := metav1.LabelSelectorAsSelector(statefulSet.Spec.Selector) - if err != nil { - r.Log.Error(err, "error retrieving statefulSet selector") - } else { - source.Status.Selector = selector.String() - } - if *statefulSet.Spec.Replicas != *source.Spec.Replicas { condition.Action = v1alpha1.Update } if statefulSet.Status.ReadyReplicas == *source.Spec.Replicas { - condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue } - source.Status.Replicas = statefulSet.Status.ReadyReplicas + source.Status.Replicas = statefulSet.Status.Replicas source.Status.Conditions[v1alpha1.StatefulSet] = condition + selector, err := metav1.LabelSelectorAsSelector(statefulSet.Spec.Selector) + if err != nil { + r.Log.Error(err, "error retrieving statefulSet selector") + return err + } + source.Status.Selector = selector.String() return nil } @@ -110,7 +111,7 @@ func (r *SourceReconciler) ObserveSourceService(ctx context.Context, req ctrl.Re condition := v1alpha1.ResourceCondition{ Condition: v1alpha1.ServiceReady, Status: metav1.ConditionFalse, - Action: v1alpha1.Create, + Action: v1alpha1.NoAction, } svc := &corev1.Service{} @@ -118,6 +119,7 @@ func (r *SourceReconciler) ObserveSourceService(ctx context.Context, req ctrl.Re Name: spec.MakeSourceObjectMeta(source).Name}, svc) if err != nil { if errors.IsNotFound(err) { + condition.Action = v1alpha1.Create r.Log.Info("service is not created...", "Name", source.Name) } else { source.Status.Conditions[v1alpha1.Service] = condition @@ -125,7 +127,6 @@ func (r *SourceReconciler) ObserveSourceService(ctx context.Context, req ctrl.Re } } else { // service object doesn't have status, so once it's created just consider it's ready - condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue } @@ -163,7 +164,7 @@ func (r *SourceReconciler) ObserveSourceHPA(ctx context.Context, req ctrl.Reques condition := v1alpha1.ResourceCondition{ Condition: v1alpha1.HPAReady, Status: metav1.ConditionFalse, - Action: v1alpha1.Create, + Action: v1alpha1.NoAction, } hpa := &autov1.HorizontalPodAutoscaler{} @@ -171,6 +172,7 @@ func (r *SourceReconciler) ObserveSourceHPA(ctx context.Context, req ctrl.Reques Name: spec.MakeSourceObjectMeta(source).Name}, hpa) if err != nil { if errors.IsNotFound(err) { + condition.Action = v1alpha1.Create r.Log.Info("hpa is not created for source...", "name", source.Name) } else { source.Status.Conditions[v1alpha1.HPA] = condition @@ -178,7 +180,6 @@ func (r *SourceReconciler) ObserveSourceHPA(ctx context.Context, req ctrl.Reques } } else { // HPA's status doesn't show its readiness, , so once it's created just consider it's ready - condition.Action = v1alpha1.NoAction condition.Status = metav1.ConditionTrue } From 32e48a43d67dadf6e6286030859c58cf5b43d609 Mon Sep 17 00:00:00 2001 From: Marvin Cai Date: Fri, 25 Jun 2021 11:56:54 +0800 Subject: [PATCH 3/4] Fix checkstyle violation. --- controllers/sink.go | 6 +++--- controllers/source.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controllers/sink.go b/controllers/sink.go index 152b93015..9ede9566d 100644 --- a/controllers/sink.go +++ b/controllers/sink.go @@ -49,10 +49,10 @@ func (r *SinkReconciler) ObserveSinkStatefulSet(ctx context.Context, req ctrl.Re condition.Action = v1alpha1.Create sink.Status.Conditions[v1alpha1.StatefulSet] = condition return nil - } else { - sink.Status.Conditions[v1alpha1.StatefulSet] = condition - return err } + + sink.Status.Conditions[v1alpha1.StatefulSet] = condition + return err } else { // statefulset created, waiting it to be ready condition.Action = v1alpha1.Wait diff --git a/controllers/source.go b/controllers/source.go index cec3dd08e..ac867c189 100644 --- a/controllers/source.go +++ b/controllers/source.go @@ -50,10 +50,10 @@ func (r *SourceReconciler) ObserveSourceStatefulSet(ctx context.Context, req ctr condition.Action = v1alpha1.Create source.Status.Conditions[v1alpha1.StatefulSet] = condition return nil - } else { - source.Status.Conditions[v1alpha1.StatefulSet] = condition - return err } + + source.Status.Conditions[v1alpha1.StatefulSet] = condition + return err } else { // statefulset created, waiting it to be ready condition.Action = v1alpha1.Wait From 046411a88009fbb956690765df0f724876b657dc Mon Sep 17 00:00:00 2001 From: Marvin Cai Date: Mon, 28 Jun 2021 14:11:03 +0800 Subject: [PATCH 4/4] Fix golint error. --- controllers/sink.go | 8 ++++---- controllers/source.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/controllers/sink.go b/controllers/sink.go index 9ede9566d..110286a55 100644 --- a/controllers/sink.go +++ b/controllers/sink.go @@ -53,11 +53,11 @@ func (r *SinkReconciler) ObserveSinkStatefulSet(ctx context.Context, req ctrl.Re sink.Status.Conditions[v1alpha1.StatefulSet] = condition return err - } else { - // statefulset created, waiting it to be ready - condition.Action = v1alpha1.Wait } + // statefulset created, waiting it to be ready + condition.Action = v1alpha1.Wait + if *statefulSet.Spec.Replicas != *sink.Spec.Replicas { condition.Action = v1alpha1.Update } @@ -177,7 +177,7 @@ func (r *SinkReconciler) ObserveSinkHPA(ctx context.Context, req ctrl.Request, s return err } } else { - // HPA's status doesn't show its readiness, , so once it's created just consider it's ready + // HPA's status doesn't show its readiness, so once it's created just consider it's ready condition.Status = metav1.ConditionTrue } diff --git a/controllers/source.go b/controllers/source.go index ac867c189..eb9176a81 100644 --- a/controllers/source.go +++ b/controllers/source.go @@ -54,11 +54,11 @@ func (r *SourceReconciler) ObserveSourceStatefulSet(ctx context.Context, req ctr source.Status.Conditions[v1alpha1.StatefulSet] = condition return err - } else { - // statefulset created, waiting it to be ready - condition.Action = v1alpha1.Wait } + // statefulset created, waiting it to be ready + condition.Action = v1alpha1.Wait + if *statefulSet.Spec.Replicas != *source.Spec.Replicas { condition.Action = v1alpha1.Update } @@ -179,7 +179,7 @@ func (r *SourceReconciler) ObserveSourceHPA(ctx context.Context, req ctrl.Reques return err } } else { - // HPA's status doesn't show its readiness, , so once it's created just consider it's ready + // HPA's status doesn't show its readiness, so once it's created just consider it's ready condition.Status = metav1.ConditionTrue }