From 50f8ad7136fb2572cb75f16e433f53732d524ae4 Mon Sep 17 00:00:00 2001 From: Andrew Bays Date: Mon, 20 Nov 2023 15:13:33 +0000 Subject: [PATCH] Properly set certain conditions to True when necessary --- controllers/barbican_controller.go | 25 ++++++++++++++++--- controllers/barbicanapi_controller.go | 3 ++- .../barbicankeystonelistener_controller.go | 2 ++ controllers/barbicanworker_controller.go | 2 ++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/controllers/barbican_controller.go b/controllers/barbican_controller.go index e455e19..7a7da67 100644 --- a/controllers/barbican_controller.go +++ b/controllers/barbican_controller.go @@ -164,7 +164,6 @@ func (r *BarbicanReconciler) Reconcile(ctx context.Context, req ctrl.Request) (r condition.UnknownCondition(barbicanv1beta1.BarbicanAPIReadyCondition, condition.InitReason, barbicanv1beta1.BarbicanAPIReadyInitMessage), condition.UnknownCondition(barbicanv1beta1.BarbicanWorkerReadyCondition, condition.InitReason, barbicanv1beta1.BarbicanWorkerReadyInitMessage), condition.UnknownCondition(barbicanv1beta1.BarbicanKeystoneListenerReadyCondition, condition.InitReason, barbicanv1beta1.BarbicanKeystoneListenerReadyInitMessage), - condition.UnknownCondition(condition.DeploymentReadyCondition, condition.InitReason, condition.DeploymentReadyInitMessage), condition.UnknownCondition(condition.NetworkAttachmentsReadyCondition, condition.InitReason, condition.NetworkAttachmentsReadyInitMessage), // service account, role, rolebinding conditions condition.UnknownCondition(condition.ServiceAccountReadyCondition, condition.InitReason, condition.ServiceAccountReadyInitMessage), @@ -318,7 +317,7 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb // TODO(dmendiza): Handle service upgrade // create or update Barbican API deployment - _, op, err = r.apiDeploymentCreateOrUpdate(ctx, instance, helper) + barbicanAPI, op, err := r.apiDeploymentCreateOrUpdate(ctx, instance, helper) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( barbicanv1beta1.BarbicanAPIReadyCondition, @@ -332,8 +331,14 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op))) } + // Mirror BarbicanAPI's condition status + c := barbicanAPI.Status.Conditions.Mirror(barbicanv1beta1.BarbicanAPIReadyCondition) + if c != nil { + instance.Status.Conditions.Set(c) + } + // create or update Barbican Worker deployment - _, op, err = r.workerDeploymentCreateOrUpdate(ctx, instance, helper) + barbicanWorker, op, err := r.workerDeploymentCreateOrUpdate(ctx, instance, helper) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( barbicanv1beta1.BarbicanWorkerReadyCondition, @@ -347,8 +352,14 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op))) } + // Mirror BarbicanWorker's condition status + c = barbicanWorker.Status.Conditions.Mirror(barbicanv1beta1.BarbicanWorkerReadyCondition) + if c != nil { + instance.Status.Conditions.Set(c) + } + // create or update Barbican KeystoneListener deployment - _, op, err = r.keystoneListenerDeploymentCreateOrUpdate(ctx, instance, helper) + barbicanKeystoneListener, op, err := r.keystoneListenerDeploymentCreateOrUpdate(ctx, instance, helper) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( barbicanv1beta1.BarbicanKeystoneListenerReadyCondition, @@ -362,6 +373,12 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op))) } + // Mirror BarbicanKeystoneListener's condition status + c = barbicanKeystoneListener.Status.Conditions.Mirror(barbicanv1beta1.BarbicanKeystoneListenerReadyCondition) + if c != nil { + instance.Status.Conditions.Set(c) + } + // TODO(dmendiza): Handle API endpoints // TODO(dmendiza): Understand what Glance is doing with the API conditions and maybe do it here too diff --git a/controllers/barbicanapi_controller.go b/controllers/barbicanapi_controller.go index 754372e..96c18e2 100644 --- a/controllers/barbicanapi_controller.go +++ b/controllers/barbicanapi_controller.go @@ -140,7 +140,6 @@ func (r *BarbicanAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) condition.UnknownCondition(condition.ServiceConfigReadyCondition, condition.InitReason, condition.ServiceConfigReadyInitMessage), condition.UnknownCondition(condition.DeploymentReadyCondition, condition.InitReason, condition.DeploymentReadyInitMessage), // right now we have no dedicated KeystoneServiceReadyInitMessage and KeystoneEndpointReadyInitMessage - condition.UnknownCondition(condition.KeystoneServiceReadyCondition, condition.InitReason, ""), condition.UnknownCondition(condition.KeystoneEndpointReadyCondition, condition.InitReason, ""), condition.UnknownCondition(condition.NetworkAttachmentsReadyCondition, condition.InitReason, condition.NetworkAttachmentsReadyInitMessage), ) @@ -271,6 +270,8 @@ func (r *BarbicanAPIReconciler) generateServiceConfigs( return err } + instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage) + templateParameters := map[string]interface{}{ "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s", instance.Spec.DatabaseUser, diff --git a/controllers/barbicankeystonelistener_controller.go b/controllers/barbicankeystonelistener_controller.go index 4663fd4..dea1f51 100644 --- a/controllers/barbicankeystonelistener_controller.go +++ b/controllers/barbicankeystonelistener_controller.go @@ -262,6 +262,8 @@ func (r *BarbicanKeystoneListenerReconciler) generateServiceConfigs( return err } + instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage) + templateParameters := map[string]interface{}{ "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s", instance.Spec.DatabaseUser, diff --git a/controllers/barbicanworker_controller.go b/controllers/barbicanworker_controller.go index ef9fcba..2069718 100644 --- a/controllers/barbicanworker_controller.go +++ b/controllers/barbicanworker_controller.go @@ -239,6 +239,8 @@ func (r *BarbicanWorkerReconciler) generateServiceConfigs( return err } + instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage) + templateParameters := map[string]interface{}{ "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s", instance.Spec.DatabaseUser,