(ctx context.Context, inst *limatype.Instance)
| 84 | } |
| 85 | |
| 86 | func waitForInstanceShutdown(ctx context.Context, inst *limatype.Instance) error { |
| 87 | ctx, cancel := context.WithTimeout(ctx, 3*time.Minute) |
| 88 | defer cancel() |
| 89 | |
| 90 | ticker := time.NewTicker(500 * time.Millisecond) |
| 91 | defer ticker.Stop() |
| 92 | |
| 93 | for { |
| 94 | select { |
| 95 | case <-ticker.C: |
| 96 | updatedInst, err := store.Inspect(ctx, inst.Name) |
| 97 | if err != nil { |
| 98 | return fmt.Errorf("failed to inspect instance status: %w", err) |
| 99 | } |
| 100 | |
| 101 | if updatedInst.Status == limatype.StatusStopped { |
| 102 | logrus.Infof("The instance %s has shut down", updatedInst.Name) |
| 103 | return nil |
| 104 | } |
| 105 | case <-ctx.Done(): |
| 106 | return errors.New("timed out waiting for instance to shut down after 3 minutes") |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | func StopForcibly(inst *limatype.Instance) { |
| 112 | if inst.DriverPID > 0 { |
no test coverage detected