@@ -266,7 +266,7 @@ func (w *workerHelperImpl) ProcessModuleSpec(
266
266
}
267
267
268
268
if readyCondition .Status == v1 .ConditionTrue && status .LastTransitionTime .Before (& readyCondition .LastTransitionTime ) {
269
- logger .Info ("Outdated last transition time status; creating unloader Pod" )
269
+ logger .Info ("Outdated last transition time status; creating loader Pod" )
270
270
271
271
return w .pm .CreateLoaderPod (ctx , nmc , spec )
272
272
}
@@ -496,6 +496,10 @@ func (p *podManagerImpl) CreateLoaderPod(ctx context.Context, nmc client.Object,
496
496
return fmt .Errorf ("could not set worker config: %v" , err )
497
497
}
498
498
499
+ if nms .Config .Modprobe .ModulesLoadingOrder != nil {
500
+ setWorkerSofdepConfig (pod , nms .Config .Modprobe .ModulesLoadingOrder )
501
+ }
502
+
499
503
setWorkerActionLabel (pod , WorkerActionLoad )
500
504
pod .Spec .RestartPolicy = v1 .RestartPolicyNever
501
505
@@ -516,6 +520,10 @@ func (p *podManagerImpl) CreateUnloaderPod(ctx context.Context, nmc client.Objec
516
520
return fmt .Errorf ("could not set worker config: %v" , err )
517
521
}
518
522
523
+ if nms .Config .Modprobe .ModulesLoadingOrder != nil {
524
+ setWorkerSofdepConfig (pod , nms .Config .Modprobe .ModulesLoadingOrder )
525
+ }
526
+
519
527
setWorkerActionLabel (pod , WorkerActionUnload )
520
528
521
529
return p .client .Create (ctx , pod )
@@ -724,16 +732,7 @@ func setWorkerConfigAnnotation(pod *v1.Pod, cfg kmmv1beta1.ModuleConfig) error {
724
732
if err != nil {
725
733
return fmt .Errorf ("could not marshal the ModuleConfig to YAML: %v" , err )
726
734
}
727
-
728
- annotations := pod .GetAnnotations ()
729
-
730
- if annotations == nil {
731
- annotations = make (map [string ]string )
732
- }
733
-
734
- annotations [configAnnotationKey ] = string (b )
735
-
736
- pod .SetAnnotations (annotations )
735
+ setWorkerPodAnnotation (pod , configAnnotationKey , string (b ))
737
736
738
737
return nil
739
738
}
@@ -749,6 +748,57 @@ func setWorkerContainerArgs(pod *v1.Pod, args []string) error {
749
748
return nil
750
749
}
751
750
751
+ func setWorkerSofdepConfig (pod * v1.Pod , modulesLoadingOrder []string ) {
752
+ softdepAnnotationValue := getModulesOrderAnnotationValue (modulesLoadingOrder )
753
+ setWorkerPodAnnotation (pod , "modules-order" , softdepAnnotationValue )
754
+
755
+ softdepVolume := v1.Volume {
756
+ Name : "modules-order" ,
757
+ VolumeSource : v1.VolumeSource {
758
+ DownwardAPI : & v1.DownwardAPIVolumeSource {
759
+ Items : []v1.DownwardAPIVolumeFile {
760
+ {
761
+ Path : "softdep.conf" ,
762
+ FieldRef : & v1.ObjectFieldSelector {FieldPath : "metadata.annotations['modules-order']" },
763
+ },
764
+ },
765
+ },
766
+ },
767
+ }
768
+ softDepVolumeMount := v1.VolumeMount {
769
+ Name : "modules-order" ,
770
+ ReadOnly : true ,
771
+ MountPath : "/etc/modprobe.d" ,
772
+ }
773
+ pod .Spec .Volumes = append (pod .Spec .Volumes , softdepVolume )
774
+ pod .Spec .Containers [0 ].VolumeMounts = append (pod .Spec .Containers [0 ].VolumeMounts , softDepVolumeMount )
775
+ }
776
+
777
+ func getModulesOrderAnnotationValue (modulesNames []string ) string {
778
+ softDepData := ""
779
+ for i := 0 ; i < len (modulesNames ); i ++ {
780
+ if i == len (modulesNames )- 1 {
781
+ break
782
+ }
783
+ line := prepareSoftDepLine (modulesNames [i ], modulesNames [i + 1 ])
784
+ softDepData = softDepData + line
785
+ }
786
+ return softDepData
787
+ }
788
+
789
+ func prepareSoftDepLine (dependendModuleName , moduleName string ) string {
790
+ return fmt .Sprintf ("softdep %s pre: %s\n " , dependendModuleName , moduleName )
791
+ }
792
+
793
+ func setWorkerPodAnnotation (pod * v1.Pod , key , value string ) {
794
+ annotations := pod .GetAnnotations ()
795
+ if annotations == nil {
796
+ annotations = make (map [string ]string )
797
+ }
798
+ annotations [key ] = value
799
+ pod .SetAnnotations (annotations )
800
+ }
801
+
752
802
//go:generate mockgen -source=nmc_reconciler.go -package=controllers -destination=mock_nmc_reconciler.go pullSecretHelper
753
803
754
804
type pullSecretHelper interface {
0 commit comments