Skip to content

Commit f2ef580

Browse files
Merge pull request #29625 from djoshy/add-wait-status
NO-ISSUE: Wait for MachineConfiguration status to be upto date
2 parents 3313032 + c251ae3 commit f2ef580

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

test/extended/machine_config/boot_image_update_agnostic.go

+9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func PartialMachineSetTest(oc *exutil.CLI, fixture string) {
3838
err := oc.Run("apply").Args("-f", fixture).Execute()
3939
o.Expect(err).NotTo(o.HaveOccurred())
4040

41+
// Ensure status accounts for the fixture that was applied
42+
WaitForMachineConfigurationStatusUpdate(oc)
43+
4144
// Pick a random machineset to test
4245
machineClient, err := machineclient.NewForConfig(oc.KubeFramework().ClientConfig())
4346
o.Expect(err).NotTo(o.HaveOccurred())
@@ -66,6 +69,9 @@ func NoneMachineSetTest(oc *exutil.CLI, fixture string) {
6669
err := oc.Run("apply").Args("-f", fixture).Execute()
6770
o.Expect(err).NotTo(o.HaveOccurred())
6871

72+
// Ensure status accounts for the fixture that was applied
73+
WaitForMachineConfigurationStatusUpdate(oc)
74+
6975
// Step through all machinesets and verify boot images are reconciled correctly.
7076
machineClient, err := machineclient.NewForConfig(oc.KubeFramework().ClientConfig())
7177
o.Expect(err).NotTo(o.HaveOccurred())
@@ -83,6 +89,9 @@ func DegradeOnOwnerRefTest(oc *exutil.CLI, fixture string) {
8389
err := oc.Run("apply").Args("-f", fixture).Execute()
8490
o.Expect(err).NotTo(o.HaveOccurred())
8591

92+
// Ensure status accounts for the fixture that was applied
93+
WaitForMachineConfigurationStatusUpdate(oc)
94+
8695
// Pick a random machineset to test
8796
machineClient, err := machineclient.NewForConfig(oc.KubeFramework().ClientConfig())
8897
o.Expect(err).NotTo(o.HaveOccurred())

test/extended/machine_config/boot_image_update_aws.go

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:ManagedBootImagesAWS][Serial]", fun
3636
// Clear out boot image configuration between tests
3737
err := oc.Run("apply").Args("-f", emptyMachineSetFixture).Execute()
3838
o.Expect(err).NotTo(o.HaveOccurred())
39+
40+
// Ensure status accounts for the fixture that was applied
41+
WaitForMachineConfigurationStatusUpdate(oc)
3942
})
4043

4144
g.It("Should update boot images only on MachineSets that are opted in [apigroup:machineconfiguration.openshift.io]", func() {

test/extended/machine_config/helpers.go

+16
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,22 @@ func WaitForBootImageControllerToComplete(oc *exutil.CLI) {
220220
}, 3*time.Minute, 5*time.Second).MustPassRepeatedly(3).Should(o.BeTrue())
221221
}
222222

223+
// WaitForMachineConfigurationStatus waits until the MCO syncs the operator status to the latest spec
224+
func WaitForMachineConfigurationStatusUpdate(oc *exutil.CLI) {
225+
machineConfigurationClient, err := mcopclient.NewForConfig(oc.KubeFramework().ClientConfig())
226+
o.Expect(err).NotTo(o.HaveOccurred())
227+
// This has a MustPassRepeatedly(3) to ensure there isn't a false positive by checking the
228+
// status too quickly after applying the fixture.
229+
o.Eventually(func() bool {
230+
mcop, err := machineConfigurationClient.OperatorV1().MachineConfigurations().Get(context.TODO(), "cluster", metav1.GetOptions{})
231+
if err != nil {
232+
framework.Logf("Failed to grab machineconfiguration object, error :%v", err)
233+
return false
234+
}
235+
return mcop.Generation == mcop.Status.ObservedGeneration
236+
}, 3*time.Minute, 1*time.Second).MustPassRepeatedly(3).Should(o.BeTrue())
237+
}
238+
223239
// IsMachineConfigPoolConditionTrue returns true when the conditionType is present and set to `ConditionTrue`
224240
func IsMachineConfigPoolConditionTrue(conditions []mcfgv1.MachineConfigPoolCondition, conditionType mcfgv1.MachineConfigPoolConditionType) bool {
225241
for _, condition := range conditions {

0 commit comments

Comments
 (0)