MCPcopy Index your code
hub / github.com/codebench-dev/worker / waitForVMToBoot

Function waitForVMToBoot

vm.go:13–40  ·  view source on GitHub ↗
(ctx context.Context, ip net.IP)

Source from the content-addressed store, hash-verified

11)
12
13func waitForVMToBoot(ctx context.Context, ip net.IP) error {
14 // Query the agent until it provides a valid response
15 req.SetTimeout(500 * time.Millisecond)
16 for {
17 select {
18 case <-ctx.Done():
19 // Timeout
20 return ctx.Err()
21 default:
22 res, err := req.Get("http://" + ip.String() + ":8080/health")
23 if err != nil {
24 log.WithError(err).Info("VM not ready yet")
25 time.Sleep(time.Second)
26 continue
27 }
28
29 if res.Response().StatusCode != 200 {
30 time.Sleep(time.Second)
31 log.Info("VM not ready yet")
32 } else {
33 log.WithField("ip", ip).Info("VM agent ready")
34 return nil
35 }
36 time.Sleep(time.Second)
37 }
38
39 }
40}
41
42func (vm runningFirecracker) shutDown() {
43 log.WithField("ip", vm.ip).Info("stopping")

Callers 1

fillVMPoolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected