@@ -218,6 +218,52 @@ func (r *IronicReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
218218
219219// SetupWithManager sets up the controller with the Manager.
220220func (r * IronicReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
221+ // watch for configmap where the CM owner label AND the CR.Spec.ManagingCrName label matches
222+ configMapFn := func (ctx context.Context , o client.Object ) []reconcile.Request {
223+ Log := r .GetLogger (ctx )
224+
225+ result := []reconcile.Request {}
226+
227+ // get all API CRs
228+ apis := & ironicv1.IronicInspectorList {}
229+ listOpts := []client.ListOption {
230+ client .InNamespace (o .GetNamespace ()),
231+ }
232+ if err := r .Client .List (
233+ ctx ,
234+ apis ,
235+ listOpts ... ); err != nil {
236+
237+ Log .Error (err , "Unable to retrieve API CRs %v" )
238+ return nil
239+ }
240+
241+ label := o .GetLabels ()
242+ // TODO: Just trying to verify that the CM is owned by this CR's managing CR
243+ if l , ok := label [labels .GetOwnerNameLabelSelector (
244+ labels .GetGroupLabel (ironic .ServiceName ))]; ok {
245+ for _ , cr := range apis .Items {
246+ // return reconcil event for the CR where the CM owner label
247+ // AND the parentIronicName matches
248+ if l == ironicv1 .GetOwningIronicName (& cr ) {
249+ // return namespace and Name of CR
250+ name := client.ObjectKey {
251+ Namespace : o .GetNamespace (),
252+ Name : cr .Name ,
253+ }
254+ Log .Info (fmt .Sprintf (
255+ "ConfigMap object %s and CR %s marked with label: %s" ,
256+ o .GetName (), cr .Name , l ))
257+ result = append (
258+ result , reconcile.Request {NamespacedName : name })
259+ }
260+ }
261+ }
262+ if len (result ) > 0 {
263+ return result
264+ }
265+ return nil
266+ }
221267 return ctrl .NewControllerManagedBy (mgr ).
222268 For (& ironicv1.Ironic {}).
223269 Owns (& ironicv1.IronicConductor {}).
@@ -228,10 +274,12 @@ func (r *IronicReconciler) SetupWithManager(mgr ctrl.Manager) error {
228274 Owns (& mariadbv1.MariaDBAccount {}).
229275 Owns (& batchv1.Job {}).
230276 Owns (& corev1.Secret {}).
231- Owns (& corev1.ConfigMap {}).
232277 Owns (& corev1.ServiceAccount {}).
233278 Owns (& rbacv1.Role {}).
234279 Owns (& rbacv1.RoleBinding {}).
280+ Watches (
281+ & corev1.ConfigMap {},
282+ handler .EnqueueRequestsFromMapFunc (configMapFn )).
235283 Watches (& keystonev1.KeystoneAPI {},
236284 handler .EnqueueRequestsFromMapFunc (r .findObjectForSrc ),
237285 builder .WithPredicates (keystonev1 .KeystoneAPIStatusChangedPredicate )).
@@ -935,8 +983,8 @@ func (r *IronicReconciler) generateServiceConfigMaps(
935983 // all other files get placed into /etc/ironic to allow overwrite of e.g. policy.json
936984 // TODO: make sure custom.conf can not be overwritten
937985 customData := map [string ]string {
938- common . CustomServiceConfigFileName : instance .Spec .CustomServiceConfig ,
939- "my.cnf" : db .GetDatabaseClientConfig (tlsCfg ), //(mschuppert) for now just get the default my.cnf
986+ "01-ironic-custom.conf" : instance .Spec .CustomServiceConfig ,
987+ "my.cnf" : db .GetDatabaseClientConfig (tlsCfg ), //(mschuppert) for now just get the default my.cnf
940988
941989 }
942990 for key , data := range instance .Spec .DefaultConfigOverwrite {
0 commit comments