@@ -87,6 +87,51 @@ var _ = Describe("SetDriverContainerAsDesired", func() {
87
87
Expect (ds .Spec .Template .Spec .Volumes ).To (HaveLen (1 ))
88
88
})
89
89
90
+ It ("should add volume and volume mount if module ordering is set" , func () {
91
+ mld := api.ModuleLoaderData {
92
+ Name : moduleName ,
93
+ Namespace : namespace ,
94
+ Modprobe : kmmv1beta1.ModprobeSpec {
95
+ ModulesLoadingOrder : []string {"ModuleA" , "ModuleB" , "ModuleC" },
96
+ },
97
+ Owner : & kmmv1beta1.Module {},
98
+ ContainerImage : "some image" ,
99
+ KernelVersion : kernelVersion ,
100
+ ModuleVersion : "some version" ,
101
+ }
102
+
103
+ orderedVol := v1.Volume {
104
+ Name : "modules-order" ,
105
+ VolumeSource : v1.VolumeSource {
106
+ DownwardAPI : & v1.DownwardAPIVolumeSource {
107
+ Items : []v1.DownwardAPIVolumeFile {
108
+ {
109
+ Path : "softdep.conf" ,
110
+ FieldRef : & v1.ObjectFieldSelector {FieldPath : "metadata.annotations['modules-order']" },
111
+ },
112
+ },
113
+ },
114
+ },
115
+ }
116
+ orderedVolMount := v1.VolumeMount {
117
+ Name : "modules-order" ,
118
+ ReadOnly : true ,
119
+ MountPath : "/etc/modprobe.d" ,
120
+ }
121
+
122
+ annotations := map [string ]string {"modules-order" : "softdep ModuleA pre: ModuleB\n softdep ModuleB pre: ModuleC\n " }
123
+
124
+ ds := appsv1.DaemonSet {}
125
+
126
+ err := dc .SetDriverContainerAsDesired (context .Background (), & ds , & mld )
127
+ Expect (err ).NotTo (HaveOccurred ())
128
+ Expect (ds .Spec .Template .Spec .Volumes ).To (HaveLen (2 ))
129
+ Expect (ds .Spec .Template .Spec .Volumes [1 ]).To (Equal (orderedVol ))
130
+ Expect (ds .Spec .Template .Spec .Containers [0 ].VolumeMounts ).To (HaveLen (2 ))
131
+ Expect (ds .Spec .Template .Spec .Containers [0 ].VolumeMounts [1 ]).To (Equal (orderedVolMount ))
132
+ Expect (ds .Spec .Template .Annotations ).To (Equal (annotations ))
133
+ })
134
+
90
135
It ("should add the volume and volume mount for firmware if FirmwarePath is set" , func () {
91
136
hostPathDirectoryOrCreate := v1 .HostPathDirectoryOrCreate
92
137
vol := v1.Volume {
@@ -224,12 +269,12 @@ var _ = Describe("SetDriverContainerAsDesired", func() {
224
269
Lifecycle : & v1.Lifecycle {
225
270
PostStart : & v1.LifecycleHandler {
226
271
Exec : & v1.ExecAction {
227
- Command : MakeLoadCommand (mld .InTreeRemoval , mld .Modprobe , moduleName ),
272
+ Command : makeLoadCommand (mld .InTreeRemoval , mld .Modprobe , moduleName ),
228
273
},
229
274
},
230
275
PreStop : & v1.LifecycleHandler {
231
276
Exec : & v1.ExecAction {
232
- Command : MakeUnloadCommand (mld .Modprobe , moduleName ),
277
+ Command : makeUnloadCommand (mld .Modprobe , moduleName ),
233
278
},
234
279
},
235
280
},
@@ -803,7 +848,7 @@ var _ = Describe("GetNodeLabelFromPod", func() {
803
848
})
804
849
})
805
850
806
- var _ = Describe ("MakeLoadCommand " , func () {
851
+ var _ = Describe ("makeLoadCommand " , func () {
807
852
const (
808
853
kernelModuleName = "some-kmod"
809
854
moduleName = "module-name"
@@ -818,7 +863,7 @@ var _ = Describe("MakeLoadCommand", func() {
818
863
}
819
864
820
865
Expect (
821
- MakeLoadCommand (false , spec , moduleName ),
866
+ makeLoadCommand (false , spec , moduleName ),
822
867
).To (
823
868
Equal ([]string {
824
869
"/bin/sh" ,
@@ -842,7 +887,7 @@ var _ = Describe("MakeLoadCommand", func() {
842
887
}
843
888
844
889
Expect (
845
- MakeLoadCommand (true , spec , moduleName ),
890
+ makeLoadCommand (true , spec , moduleName ),
846
891
).To (
847
892
Equal ([]string {
848
893
"/bin/sh" ,
@@ -861,7 +906,7 @@ var _ = Describe("MakeLoadCommand", func() {
861
906
}
862
907
863
908
Expect (
864
- MakeLoadCommand (false , spec , moduleName ),
909
+ makeLoadCommand (false , spec , moduleName ),
865
910
).To (
866
911
Equal ([]string {
867
912
"/bin/sh" ,
@@ -878,7 +923,7 @@ var _ = Describe("MakeLoadCommand", func() {
878
923
}
879
924
880
925
Expect (
881
- MakeLoadCommand (false , spec , moduleName ),
926
+ makeLoadCommand (false , spec , moduleName ),
882
927
).To (
883
928
Equal ([]string {
884
929
"/bin/sh" ,
@@ -889,7 +934,7 @@ var _ = Describe("MakeLoadCommand", func() {
889
934
})
890
935
})
891
936
892
- var _ = Describe ("MakeUnloadCommand " , func () {
937
+ var _ = Describe ("makeUnloadCommand " , func () {
893
938
const (
894
939
kernelModuleName = "some-kmod"
895
940
moduleName = "module-name"
@@ -904,7 +949,7 @@ var _ = Describe("MakeUnloadCommand", func() {
904
949
}
905
950
906
951
Expect (
907
- MakeUnloadCommand (spec , moduleName ),
952
+ makeUnloadCommand (spec , moduleName ),
908
953
).To (
909
954
Equal ([]string {
910
955
"/bin/sh" ,
@@ -923,7 +968,7 @@ var _ = Describe("MakeUnloadCommand", func() {
923
968
}
924
969
925
970
Expect (
926
- MakeUnloadCommand (spec , moduleName ),
971
+ makeUnloadCommand (spec , moduleName ),
927
972
).To (
928
973
Equal ([]string {
929
974
"/bin/sh" ,
@@ -942,7 +987,7 @@ var _ = Describe("MakeUnloadCommand", func() {
942
987
}
943
988
944
989
Expect (
945
- MakeUnloadCommand (spec , moduleName ),
990
+ makeUnloadCommand (spec , moduleName ),
946
991
).To (
947
992
Equal ([]string {
948
993
"/bin/sh" ,
@@ -959,7 +1004,7 @@ var _ = Describe("MakeUnloadCommand", func() {
959
1004
}
960
1005
961
1006
Expect (
962
- MakeUnloadCommand (spec , moduleName ),
1007
+ makeUnloadCommand (spec , moduleName ),
963
1008
).To (
964
1009
Equal ([]string {
965
1010
"/bin/sh" ,
0 commit comments