Skip to content

Commit

Permalink
Merge pull request #357 from jlarriba/watch_keystone
Browse files Browse the repository at this point in the history
[OSPRH-5732] ceilometer-central-agent must reboot when Keystone has a…
  • Loading branch information
openshift-merge-bot[bot] authored Apr 4, 2024
2 parents 22be6cf + fb9a8ce commit ab779da
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions controllers/ceilometer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,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
Expand Down Expand Up @@ -840,6 +854,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)
}

Expand Down

0 comments on commit ab779da

Please sign in to comment.