@@ -894,6 +894,88 @@ func (f *Framework) restoreNodeLabelsForPool(n string) error {
894894 return nil
895895}
896896
897+ // WaitForMachineConfigPoolUpdated waits for a MachineConfigPool to complete an update cycle.
898+ // It first waits for the Updated condition to become False (indicating update/reboot started),
899+ // then waits for it to become True again (indicating update/reboot completed).
900+ func (f * Framework ) WaitForMachineConfigPoolUpdated (poolName string ) error {
901+ if f .Platform == "rosa" {
902+ log .Printf ("Bypassing MachineConfigPool update check on %s" , f .Platform )
903+ return nil
904+ }
905+
906+ // First, get the initial state
907+ pool := mcfgv1.MachineConfigPool {}
908+ err := f .Client .Get (context .TODO (), types.NamespacedName {Name : poolName }, & pool )
909+ if err != nil {
910+ return fmt .Errorf ("failed to find Machine Config Pool %s: %w" , poolName , err )
911+ }
912+
913+ // Check initial state of MachineConfigPoolUpdated condition
914+ initialUpdated := false
915+ for _ , c := range pool .Status .Conditions {
916+ if c .Type == mcfgv1 .MachineConfigPoolUpdated {
917+ initialUpdated = (c .Status == core .ConditionTrue )
918+ break
919+ }
920+ }
921+
922+ // If the pool is already updated (True), wait for it to start updating (False)
923+ if initialUpdated {
924+ log .Printf ("Machine Config Pool %s is currently updated. Waiting for update to start...\n " , poolName )
925+ err = wait .PollImmediate (machineOperationRetryInterval , machineOperationTimeout , func () (bool , error ) {
926+ pool := mcfgv1.MachineConfigPool {}
927+ err := f .Client .Get (context .TODO (), types.NamespacedName {Name : poolName }, & pool )
928+ if err != nil {
929+ log .Printf ("failed to find Machine Config Pool %s\n " , poolName )
930+ return false , err
931+ }
932+
933+ for _ , c := range pool .Status .Conditions {
934+ if c .Type == mcfgv1 .MachineConfigPoolUpdated {
935+ if c .Status == core .ConditionFalse {
936+ log .Printf ("Machine Config Pool %s update started (Updated=False)\n " , poolName )
937+ return true , nil
938+ }
939+ break
940+ }
941+ }
942+
943+ log .Printf ("Machine Config Pool %s still updated, waiting for update to start...\n " , poolName )
944+ return false , nil
945+ })
946+ if err != nil {
947+ return fmt .Errorf ("failed waiting for Machine Config Pool %s to start updating: %w" , poolName , err )
948+ }
949+ } else {
950+ log .Printf ("Machine Config Pool %s is already updating (Updated=False). Waiting for update to complete...\n " , poolName )
951+ }
952+
953+ // Now wait for the update to complete (Updated=True)
954+ err = wait .PollImmediate (machineOperationRetryInterval , machineOperationTimeout , func () (bool , error ) {
955+ pool := mcfgv1.MachineConfigPool {}
956+ err := f .Client .Get (context .TODO (), types.NamespacedName {Name : poolName }, & pool )
957+ if err != nil {
958+ log .Printf ("failed to find Machine Config Pool %s\n " , poolName )
959+ return false , err
960+ }
961+
962+ for _ , c := range pool .Status .Conditions {
963+ if c .Type == mcfgv1 .MachineConfigPoolUpdated && c .Status == core .ConditionTrue {
964+ return true , nil
965+ }
966+ }
967+
968+ log .Printf ("Machine Config Pool %s has not finished updating yet... retrying\n " , poolName )
969+ return false , nil
970+ })
971+ if err != nil {
972+ return fmt .Errorf ("failed waiting for Machine Config Pool %s to be updated: %w" , poolName , err )
973+ }
974+
975+ log .Printf ("Machine Config Pool %s is updated\n " , poolName )
976+ return nil
977+ }
978+
897979func (f * Framework ) getNodesForPool (p * mcfgv1.MachineConfigPool ) (core.NodeList , error ) {
898980 var nodeList core.NodeList
899981 opts := & dynclient.ListOptions {
@@ -1048,6 +1130,25 @@ func (f *Framework) WaitForScanSettingBindingStatus(namespace, name string, targ
10481130 return nil
10491131}
10501132
1133+ func (f * Framework ) WaitForComplianceSuiteDeletion (name , namespace string ) error {
1134+ suiteKey := types.NamespacedName {Name : name , Namespace : namespace }
1135+ suite := & compv1alpha1.ComplianceSuite {}
1136+ err := wait .Poll (RetryInterval , 30 * time .Second , func () (bool , error ) {
1137+ err := f .Client .Get (context .TODO (), suiteKey , suite )
1138+ if apierrors .IsNotFound (err ) {
1139+ return true , nil
1140+ }
1141+ if err != nil {
1142+ return false , err
1143+ }
1144+ return false , nil
1145+ })
1146+ if err != nil {
1147+ return fmt .Errorf ("ComplianceSuite %s may not have been fully cleaned up: %w" , name , err )
1148+ }
1149+ return nil
1150+ }
1151+
10511152func (f * Framework ) AssertProfileInRuleAnnotation (r * compv1alpha1.Rule , expectedProfileId string ) bool {
10521153 if r .Annotations == nil {
10531154 return false
0 commit comments