@@ -80,6 +80,10 @@ const (
8080// When a ConfigMap's data changes, it automatically triggers reconciliation of the referencing
8181// LlamaStackDistribution, which recalculates a content-based hash and updates the deployment's
8282// pod template annotations. This causes Kubernetes to restart the pods with the updated configuration.
83+ //
84+ // Operator ConfigMap Watching Feature:
85+ // This reconciler also watches for changes to the operator configuration ConfigMap. When the operator
86+ // config changes, it triggers reconciliation of all LlamaStackDistribution resources.
8387type LlamaStackDistributionReconciler struct {
8488 client.Client
8589 Scheme * runtime.Scheme
@@ -458,6 +462,21 @@ func (r *LlamaStackDistributionReconciler) configMapUpdatePredicate(e event.Upda
458462 return false
459463 }
460464
465+ // Parse the feature flags if the operator config ConfigMap has changed
466+ operatorNamespace , err := deploy .GetOperatorNamespace ()
467+ if err != nil {
468+ return false
469+ }
470+ if newConfigMap .Name == operatorConfigData && newConfigMap .Namespace == operatorNamespace {
471+ EnableNetworkPolicy , err := parseFeatureFlags (newConfigMap .Data )
472+ if err != nil {
473+ log .FromContext (context .Background ()).Error (err , "Failed to parse feature flags" )
474+ } else {
475+ r .EnableNetworkPolicy = EnableNetworkPolicy
476+ }
477+ return true
478+ }
479+
461480 // Only proceed if this ConfigMap is referenced by any LlamaStackDistribution
462481 if ! r .isConfigMapReferenced (newConfigMap ) {
463482 return false
@@ -623,6 +642,27 @@ func (r *LlamaStackDistributionReconciler) manuallyCheckConfigMapReference(confi
623642
624643// findLlamaStackDistributionsForConfigMap maps ConfigMap changes to LlamaStackDistribution reconcile requests.
625644func (r * LlamaStackDistributionReconciler ) findLlamaStackDistributionsForConfigMap (ctx context.Context , configMap client.Object ) []reconcile.Request {
645+ logger := log .FromContext (ctx ).WithValues (
646+ "configMapName" , configMap .GetName (),
647+ "configMapNamespace" , configMap .GetNamespace ())
648+
649+ operatorNamespace , err := deploy .GetOperatorNamespace ()
650+ if err != nil {
651+ log .FromContext (context .Background ()).Error (err , "Failed to get operator namespace for config map event processing" )
652+ return nil
653+ }
654+ // If the operator config was changed, we reconcile all LlamaStackDistributions
655+ if configMap .GetName () == operatorConfigData && configMap .GetNamespace () == operatorNamespace {
656+ // List all LlamaStackDistribution resources across all namespaces
657+ allLlamaStacks := llamav1alpha1.LlamaStackDistributionList {}
658+ err = r .List (ctx , & allLlamaStacks )
659+ if err != nil {
660+ logger .Error (err , "Failed to list all LlamaStackDistributions for operator config change" )
661+ return nil
662+ }
663+ return r .convertToReconcileRequests (allLlamaStacks )
664+ }
665+
626666 // Try field indexer lookup first
627667 attachedLlamaStacks , found := r .tryFieldIndexerLookup (ctx , configMap )
628668 if ! found {
0 commit comments