@@ -175,6 +175,68 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive
175175 o .Eventually (mcoCO , "1m" , "10s" ).Should (BeUpgradeable (), "co/machine-config should be upgradeable with restored machineset" )
176176 })
177177
178+ // AI-assisted: This test case validates that CPMS boot image config is permitted when skew enforcement is Automatic
179+ g .It ("Verify Automatic mode permits other machine managers [apigroup:machineconfiguration.openshift.io]" , g .Label ("Platform:aws" , "Platform:gce" ), func () {
180+ // Automatic skew mode is only supported on AWS and GCP
181+ skipTestIfSupportedPlatformNotMatched (oc , GCPPlatform , AWSPlatform )
182+
183+ var (
184+ expectedMachineSetError = "when skew enforcement is in Automatic mode, any MachineAPI MachineSet MachineManager must use selection mode 'All'"
185+
186+ testConfigs = []struct {
187+ description string
188+ patchConfig string
189+ shouldSucceed bool
190+ }{
191+ {
192+ description : "CPMS-only with All mode should succeed" ,
193+ patchConfig : `{"spec":{"managedBootImages":{"machineManagers":[{"resource":"controlplanemachinesets","apiGroup":"machine.openshift.io","selection":{"mode":"All"}}]}}}` ,
194+ shouldSucceed : true ,
195+ },
196+ {
197+ description : "CPMS-only with None mode should succeed" ,
198+ patchConfig : `{"spec":{"managedBootImages":{"machineManagers":[{"resource":"controlplanemachinesets","apiGroup":"machine.openshift.io","selection":{"mode":"None"}}]}}}` ,
199+ shouldSucceed : true ,
200+ },
201+ {
202+ description : "CPMS All + MachineSet All should succeed" ,
203+ patchConfig : `{"spec":{"managedBootImages":{"machineManagers":[{"resource":"controlplanemachinesets","apiGroup":"machine.openshift.io","selection":{"mode":"All"}},{"resource":"machinesets","apiGroup":"machine.openshift.io","selection":{"mode":"All"}}]}}}` ,
204+ shouldSucceed : true ,
205+ },
206+ {
207+ description : "CPMS All + MachineSet None should fail" ,
208+ patchConfig : `{"spec":{"managedBootImages":{"machineManagers":[{"resource":"controlplanemachinesets","apiGroup":"machine.openshift.io","selection":{"mode":"All"}},{"resource":"machinesets","apiGroup":"machine.openshift.io","selection":{"mode":"None"}}]}}}` ,
209+ shouldSucceed : false ,
210+ },
211+ {
212+ description : "CPMS None + MachineSet None should fail" ,
213+ patchConfig : `{"spec":{"managedBootImages":{"machineManagers":[{"resource":"controlplanemachinesets","apiGroup":"machine.openshift.io","selection":{"mode":"None"}},{"resource":"machinesets","apiGroup":"machine.openshift.io","selection":{"mode":"None"}}]}}}` ,
214+ shouldSucceed : false ,
215+ },
216+ }
217+ )
218+
219+ // No opinion on skew enforcement for these platforms will result in Automatic mode
220+ o .Expect (machineConfiguration .RemoveSkew ()).To (o .Succeed ())
221+
222+ // Wait for the controller to reflect Automatic mode in skew enforcement status
223+ machineConfiguration .WaitForBootImageSkewEnforcementStatusMode (SkewEnforcementAutomaticMode )
224+
225+ for _ , tc := range testConfigs {
226+ logger .Infof (tc .description )
227+ err := machineConfiguration .Patch ("merge" , tc .patchConfig )
228+ if tc .shouldSucceed {
229+ o .Expect (err ).NotTo (o .HaveOccurred (), "Config should be accepted when skew enforcement is Automatic: %s" , tc .description )
230+ } else {
231+ o .Expect (err ).To (o .HaveOccurred (), "Config should be rejected when skew enforcement is Automatic: %s" , tc .description )
232+ o .Expect (err ).To (o .BeAssignableToTypeOf (& exutil.ExitError {}), "Unexpected error type for: %s" , tc .description )
233+ o .Expect (err .(* exutil.ExitError ).StdErr ).To (o .ContainSubstring (expectedMachineSetError ),
234+ "Error message does not match expected for: %s" , tc .description )
235+ }
236+ logger .Infof ("OK!\n " )
237+ }
238+ })
239+
178240 g .It ("Verify None mode [apigroup:machineconfiguration.openshift.io]" , func () {
179241 // Set None mode, effectively disabling skew enforcement
180242 o .Expect (machineConfiguration .SetNoneSkew ()).To (o .Succeed ())
0 commit comments