From ddb3df972a91c271eaa04de33d5d41e64f97b7cd Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 27 Jul 2023 15:16:24 +0900 Subject: [PATCH 1/2] Replace RabbitMqTransportURLReady by common condition We have added the common RabbitMqTransportURLReady to lib-common to reduce duplicate implementations. Depends-on: https://github.com/openstack-k8s-operators/lib-common/pull/300 --- api/v1beta1/conditions.go | 18 ------------------ controllers/ceilometercentral_controller.go | 10 +++++----- controllers/ceilometercompute_controller.go | 10 +++++----- controllers/telemetry_controller.go | 2 +- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/api/v1beta1/conditions.go b/api/v1beta1/conditions.go index fdaf8134..a4038ff2 100644 --- a/api/v1beta1/conditions.go +++ b/api/v1beta1/conditions.go @@ -21,9 +21,6 @@ import ( // Telemetry Condition Types used by API objects. const ( - // TelemetryRabbitMqTransportURLReadyCondition Status=True condition which indicates if the RabbitMQ TransportURLUrl is ready - TelemetryRabbitMqTransportURLReadyCondition condition.Type = "TelemetryRabbitMqTransportURLReady" - // CeilometerCentralReadyCondition Status=True condition which indicates if the CeilometerCentral is configured and operational CeilometerCentralReadyCondition condition.Type = "CeilometerCentralReady" @@ -39,21 +36,6 @@ const () // Common Messages used by API objects. const ( - // - // TelemetryRabbitMqTransportURLReady condition messages - // - // TelemetryRabbitMqTransportURLReadyInitMessage - TelemetryRabbitMqTransportURLReadyInitMessage = "TelemetryRabbitMqTransportURL not started" - - // TelemetryRabbitMqTransportURLReadyRunningMessage - TelemetryRabbitMqTransportURLReadyRunningMessage = "TelemetryRabbitMqTransportURL creation in progress" - - // TelemetryRabbitMqTransportURLReadyMessage - TelemetryRabbitMqTransportURLReadyMessage = "TelemetryRabbitMqTransportURL successfully created" - - // TelemetryRabbitMqTransportURLReadyErrorMessage - TelemetryRabbitMqTransportURLReadyErrorMessage = "TelemetryRabbitMqTransportURL error occured %s" - // // CeilometerCentralReady condition messages // diff --git a/controllers/ceilometercentral_controller.go b/controllers/ceilometercentral_controller.go index 3e89e738..3212d054 100644 --- a/controllers/ceilometercentral_controller.go +++ b/controllers/ceilometercentral_controller.go @@ -282,10 +282,10 @@ func (r *CeilometerCentralReconciler) reconcileNormal(ctx context.Context, insta if err != nil { r.Log.Info("Error getting transportURL. Setting error condition on status and returning") instance.Status.Conditions.Set(condition.FalseCondition( - telemetryv1.TelemetryRabbitMqTransportURLReadyCondition, + condition.RabbitMqTransportURLReadyCondition, condition.ErrorReason, condition.SeverityWarning, - telemetryv1.TelemetryRabbitMqTransportURLReadyErrorMessage, + condition.RabbitMqTransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err } @@ -299,14 +299,14 @@ func (r *CeilometerCentralReconciler) reconcileNormal(ctx context.Context, insta if instance.Spec.TransportURLSecret == "" { r.Log.Info(fmt.Sprintf("Waiting for TransportURL %s secret to be created", transportURL.Name)) instance.Status.Conditions.Set(condition.FalseCondition( - telemetryv1.TelemetryRabbitMqTransportURLReadyCondition, + condition.RabbitMqTransportURLReadyCondition, condition.RequestedReason, condition.SeverityInfo, - telemetryv1.TelemetryRabbitMqTransportURLReadyRunningMessage)) + condition.RabbitMqTransportURLReadyRunningMessage)) return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } - instance.Status.Conditions.MarkTrue(telemetryv1.TelemetryRabbitMqTransportURLReadyCondition, telemetryv1.TelemetryRabbitMqTransportURLReadyMessage) + instance.Status.Conditions.MarkTrue(condition.RabbitMqTransportURLReadyCondition, condition.RabbitMqTransportURLReadyMessage) // end transportURL // ConfigMap diff --git a/controllers/ceilometercompute_controller.go b/controllers/ceilometercompute_controller.go index 72cc8c03..3f376545 100644 --- a/controllers/ceilometercompute_controller.go +++ b/controllers/ceilometercompute_controller.go @@ -229,10 +229,10 @@ func (r *CeilometerComputeReconciler) reconcileNormal(ctx context.Context, insta if err != nil { r.Log.Info("Error getting transportURL. Setting error condition on status and returning") instance.Status.Conditions.Set(condition.FalseCondition( - telemetryv1.TelemetryRabbitMqTransportURLReadyCondition, + condition.RabbitMqTransportURLReadyCondition, condition.ErrorReason, condition.SeverityWarning, - telemetryv1.TelemetryRabbitMqTransportURLReadyErrorMessage, + condition.RabbitMqTransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err } @@ -246,14 +246,14 @@ func (r *CeilometerComputeReconciler) reconcileNormal(ctx context.Context, insta if instance.Spec.TransportURLSecret == "" { r.Log.Info(fmt.Sprintf("Waiting for TransportURL %s secret to be created", transportURL.Name)) instance.Status.Conditions.Set(condition.FalseCondition( - telemetryv1.TelemetryRabbitMqTransportURLReadyCondition, + condition.RabbitMqTransportURLReadyCondition, condition.RequestedReason, condition.SeverityInfo, - telemetryv1.TelemetryRabbitMqTransportURLReadyRunningMessage)) + condition.RabbitMqTransportURLReadyRunningMessage)) return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } - instance.Status.Conditions.MarkTrue(telemetryv1.TelemetryRabbitMqTransportURLReadyCondition, telemetryv1.TelemetryRabbitMqTransportURLReadyMessage) + instance.Status.Conditions.MarkTrue(condition.RabbitMqTransportURLReadyCondition, condition.RabbitMqTransportURLReadyMessage) // end transportURL // ConfigMap diff --git a/controllers/telemetry_controller.go b/controllers/telemetry_controller.go index ebcaf49e..59f79c3b 100644 --- a/controllers/telemetry_controller.go +++ b/controllers/telemetry_controller.go @@ -126,7 +126,7 @@ func (r *TelemetryReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( instance.Status.Conditions = condition.Conditions{} // initialize conditions used later as Status=Unknown cl := condition.CreateList( - condition.UnknownCondition(telemetryv1.TelemetryRabbitMqTransportURLReadyCondition, condition.InitReason, telemetryv1.TelemetryRabbitMqTransportURLReadyInitMessage), + condition.UnknownCondition(condition.RabbitMqTransportURLReadyCondition, condition.InitReason, condition.RabbitMqTransportURLReadyInitMessage), condition.UnknownCondition(telemetryv1.CeilometerCentralReadyCondition, condition.InitReason, telemetryv1.CeilometerCentralReadyInitMessage), condition.UnknownCondition(telemetryv1.CeilometerComputeReadyCondition, condition.InitReason, telemetryv1.CeilometerComputeReadyInitMessage), // service account, role, rolebinding conditions From 35e4a65163d1dffc0705bfe455630ef88cba31b2 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 27 Jul 2023 15:19:05 +0900 Subject: [PATCH 2/2] Drop unused conditions from Telemetry CR --- controllers/telemetry_controller.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/controllers/telemetry_controller.go b/controllers/telemetry_controller.go index 59f79c3b..84bc6d8d 100644 --- a/controllers/telemetry_controller.go +++ b/controllers/telemetry_controller.go @@ -126,13 +126,8 @@ func (r *TelemetryReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( instance.Status.Conditions = condition.Conditions{} // initialize conditions used later as Status=Unknown cl := condition.CreateList( - condition.UnknownCondition(condition.RabbitMqTransportURLReadyCondition, condition.InitReason, condition.RabbitMqTransportURLReadyInitMessage), condition.UnknownCondition(telemetryv1.CeilometerCentralReadyCondition, condition.InitReason, telemetryv1.CeilometerCentralReadyInitMessage), condition.UnknownCondition(telemetryv1.CeilometerComputeReadyCondition, condition.InitReason, telemetryv1.CeilometerComputeReadyInitMessage), - // service account, role, rolebinding conditions - condition.UnknownCondition(condition.ServiceAccountReadyCondition, condition.InitReason, condition.ServiceAccountReadyInitMessage), - condition.UnknownCondition(condition.RoleReadyCondition, condition.InitReason, condition.RoleReadyInitMessage), - condition.UnknownCondition(condition.RoleBindingReadyCondition, condition.InitReason, condition.RoleBindingReadyInitMessage), ) instance.Status.Conditions.Init(&cl)