From 256b9c4244af71af4edbc6e68208b5b8789049f8 Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Wed, 27 Mar 2024 17:16:51 +0100 Subject: [PATCH] Add Status.ObservedGeneration to Manila CR This field is used by minor updates to make sure we know, when a CR changes, if the requested generation matches with the last observed state, then we can check the IsReady because we're sure we're not looking at an outdated CR. Signed-off-by: Francesco Pantano --- api/bases/manila.openstack.org_manilas.yaml | 3 +++ api/v1beta1/manila_types.go | 6 ++++++ config/crd/bases/manila.openstack.org_manilas.yaml | 3 +++ controllers/manila_controller.go | 1 + 4 files changed, 13 insertions(+) diff --git a/api/bases/manila.openstack.org_manilas.yaml b/api/bases/manila.openstack.org_manilas.yaml index d670612a..a806a2ca 100644 --- a/api/bases/manila.openstack.org_manilas.yaml +++ b/api/bases/manila.openstack.org_manilas.yaml @@ -1137,6 +1137,9 @@ spec: format: int32 type: integer type: object + observedGeneration: + format: int64 + type: integer transportURLSecret: type: string type: object diff --git a/api/v1beta1/manila_types.go b/api/v1beta1/manila_types.go index e56f861f..8b4eb939 100644 --- a/api/v1beta1/manila_types.go +++ b/api/v1beta1/manila_types.go @@ -139,6 +139,12 @@ type ManilaStatus struct { // ReadyCounts of Manila Share instances ManilaSharesReadyCounts map[string]int32 `json:"manilaSharesReadyCounts,omitempty"` + + // ObservedGeneration - the most recent generation observed for this + // service. If the observed generation is less than the spec generation, + // then the controller has not processed the latest changes injected by + // the opentack-operator in the top-level CR (e.g. the ContainerImage) + ObservedGeneration int64 `json:"observedGeneration,omitempty"` } //+kubebuilder:object:root=true diff --git a/config/crd/bases/manila.openstack.org_manilas.yaml b/config/crd/bases/manila.openstack.org_manilas.yaml index d670612a..a806a2ca 100644 --- a/config/crd/bases/manila.openstack.org_manilas.yaml +++ b/config/crd/bases/manila.openstack.org_manilas.yaml @@ -1137,6 +1137,9 @@ spec: format: int32 type: integer type: object + observedGeneration: + format: int64 + type: integer transportURLSecret: type: string type: object diff --git a/controllers/manila_controller.go b/controllers/manila_controller.go index 1ce40d7d..c1597ddc 100644 --- a/controllers/manila_controller.go +++ b/controllers/manila_controller.go @@ -780,6 +780,7 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila r.Log.Info(fmt.Sprintf("Reconciled Service '%s' successfully", instance.Name)) // update the overall status condition if service is ready + instance.Status.ObservedGeneration = instance.Generation if instance.IsReady() { instance.Status.Conditions.MarkTrue(condition.ReadyCondition, condition.ReadyMessage) }