Skip to content

Commit

Permalink
checkup: Run VMI Setups in parallel
Browse files Browse the repository at this point in the history
Currently the setup is performed on the VMIs in serial order.
In order to reduce the wait time, run the waitForVMIReady in parallel.

Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Jan 24, 2024
1 parent 39903ab commit fdf2ded
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions pkg/internal/checkup/checkup.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
"log"
"strings"
"sync"
"time"

k8scorev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -125,19 +126,34 @@ func (c *Checkup) Setup(ctx context.Context) (setupErr error) {
}
}()

var wg sync.WaitGroup

wg.Add(1)
var updatedVMIUnderTest *kvcorev1.VirtualMachineInstance
updatedVMIUnderTest, err = c.setupVMIWaitReady(setupCtx, c.vmiUnderTest.Name)
if err != nil {
return err
}
var vmiUnderTestErr error
go func() {
defer wg.Done()
updatedVMIUnderTest, vmiUnderTestErr = c.setupVMIWaitReady(setupCtx, c.vmiUnderTest.Name)
}()

c.vmiUnderTest = updatedVMIUnderTest
wg.Add(1)
var updatedTrafficGen *kvcorev1.VirtualMachineInstance
updatedTrafficGen, err = c.setupVMIWaitReady(setupCtx, c.trafficGen.Name)
if err != nil {
return err
var trafficGenErr error
go func() {
defer wg.Done()
updatedTrafficGen, trafficGenErr = c.setupVMIWaitReady(setupCtx, c.trafficGen.Name)
}()

wg.Wait()

if vmiUnderTestErr != nil {
return vmiUnderTestErr
}
c.vmiUnderTest = updatedVMIUnderTest

if trafficGenErr != nil {
return trafficGenErr
}
c.trafficGen = updatedTrafficGen

return nil
Expand Down

0 comments on commit fdf2ded

Please sign in to comment.