From fb9a8ced003ce6035c6d5a3ab2e1b4b70f86aec9 Mon Sep 17 00:00:00 2001 From: jlarriba Date: Tue, 2 Apr 2024 13:39:37 +0200 Subject: [PATCH] [OSPRH-5732] ceilometer-central-agent must reboot when Keystone has all the endpoints to trigger a token renew --- controllers/ceilometer_controller.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/controllers/ceilometer_controller.go b/controllers/ceilometer_controller.go index db92e660..94effc2f 100644 --- a/controllers/ceilometer_controller.go +++ b/controllers/ceilometer_controller.go @@ -765,6 +765,20 @@ func (r *CeilometerReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma } return nil } + + // Force restart of Ceilometer every time a keystoneendpoint is modified + keystoneEndpointsWatchFn := func(ctx context.Context, o client.Object) []reconcile.Request { + pod := &corev1.Pod{} + // Ceilometer can never have replicas so it will always be pod 0 + err := r.Client.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("%v-0", ceilometer.ServiceName), Namespace: o.GetNamespace()}, pod) + if err != nil { + return nil + } + // Delete the pod so the statefulset re-creates it + r.Client.Delete(ctx, pod) + return nil + } + // index ceilometerPasswordSecretField if err := mgr.GetFieldIndexer().IndexField(context.Background(), &telemetryv1.Ceilometer{}, ceilometerPasswordSecretField, func(rawObj client.Object) []string { // Extract the secret name from the spec, if one is provided @@ -819,6 +833,10 @@ func (r *CeilometerReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc), builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}), ). + Watches( + &keystonev1.KeystoneEndpoint{}, + handler.EnqueueRequestsFromMapFunc(keystoneEndpointsWatchFn), + ). Complete(r) }