@@ -369,14 +369,23 @@ func (optr *Operator) Run(workers int, stopCh <-chan struct{}) {
369369 }
370370
371371 if isOCBEnabled {
372- klog .Infof ("On-cluster layering featuregate enabled, starting MachineOSConfig informer" )
373- moscInformer := optr .ctrlctx .InformerFactory .Machineconfiguration ().V1alpha1 ().MachineOSConfigs ()
374- optr .moscLister = moscInformer .Lister ()
375- optr .moscListerSynced = moscInformer .Informer ().HasSynced
376- moscInformer .Informer ().AddEventHandler (optr .eventHandler ())
377- // We have to start this inofrmer ourselves because the caller has started
378- // all of the other informers before calling Run().
379- go moscInformer .Informer ().Run (optr .ctrlctx .Stop )
372+ // Check if MachineOSConfig CRD exists before starting the informer
373+ _ , err := apiClient .CustomResourceDefinitions ().Get (context .TODO (), "machineosconfigs.machineconfiguration.openshift.io" , metav1.GetOptions {})
374+ if err != nil {
375+ if apierrors .IsNotFound (err ) {
376+ klog .Warningf ("On-cluster layering featuregate enabled, but MachineOSConfig CRD not found, skipping informer initialization" )
377+ } else {
378+ klog .Errorf ("Error checking for MachineOSConfig CRD: %v" , err )
379+ }
380+ } else {
381+ klog .Infof ("On-cluster layering featuregate enabled, starting MachineOSConfig informer" )
382+ moscInformer := optr .ctrlctx .InformerFactory .Machineconfiguration ().V1alpha1 ().MachineOSConfigs ()
383+ optr .moscLister = moscInformer .Lister ()
384+ optr .moscListerSynced = moscInformer .Informer ().HasSynced
385+ cacheSynced = append (cacheSynced , optr .moscListerSynced )
386+ moscInformer .Informer ().AddEventHandler (optr .eventHandler ())
387+ go moscInformer .Informer ().Run (optr .ctrlctx .Stop )
388+ }
380389 }
381390
382391 if ! cache .WaitForCacheSync (stopCh ,
0 commit comments