Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions test/extended-priv/machineset.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,16 @@ func (ms MachineSet) GetMachines() ([]*Machine, error) {

// GetMachinesByPhase get machine by phase e.g. Running, Provisioning, Provisioned, Deleting etc.
func (ms MachineSet) GetMachinesByPhase(phase string) ([]*Machine, error) {
// add poller to check machine phase periodically.
machines := []*Machine{}
pollerr := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) {
ml, err := ms.GetMachines()
pollerr := wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) {
ml := NewMachineList(ms.oc, ms.GetNamespace())
ml.ByLabel("machine.openshift.io/cluster-api-machineset=" + ms.GetName())
ml.SetItemsFilter(fmt.Sprintf(`?(@.status.phase=="%s")`, phase))
allMachines, err := ml.GetAll()
if err != nil {
return false, err
}
for _, m := range ml {
mPhase, err := m.GetPhase()
if err != nil {
return false, err
}
if mPhase == phase {
machines = append(machines, m)
}
}
machines = allMachines
return len(machines) > 0, nil
})

Expand Down