f-79: agent: section times, renvoi de system_powerdown, attentes #79
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
8429dfd7e1
commit
8e89865418
13 changed files with 602 additions and 80 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package dispatcher
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
|
|
@ -151,24 +152,23 @@ func allocateMetadataPort(db *badger.DB) (int, error) {
|
|||
}
|
||||
|
||||
func (c StartVMCommand) Execute(db *badger.DB, cfg *configuration.Config) error {
|
||||
timeout := time.After(time.Duration(cfg.Dispatcher.TimeoutSeconds) * time.Second)
|
||||
timeout := time.Now().Add(cfg.Times.VMsStart())
|
||||
for _, n := range c.NICs {
|
||||
for {
|
||||
err := waitUntil(time.Until(timeout), cfg.Times.Poll(), func() (bool, error) {
|
||||
subnetState, err := state.Get(db, "subnet/"+n.Subnet)
|
||||
if err != nil {
|
||||
return fmt.Errorf("subnet %q not found while waiting", n.Subnet)
|
||||
return false, fmt.Errorf("subnet %q not found while waiting", n.Subnet)
|
||||
}
|
||||
if subnetState == state.Running {
|
||||
break
|
||||
}
|
||||
if subnetState != state.Creating {
|
||||
return fmt.Errorf("subnet %q is %s, cannot start vm %q", n.Subnet, subnetState, c.Name)
|
||||
}
|
||||
select {
|
||||
case <-timeout:
|
||||
return fmt.Errorf("timed out waiting for subnet %q to be running", n.Subnet)
|
||||
case <-time.After(time.Duration(cfg.Dispatcher.PollSeconds) * time.Second):
|
||||
if subnetState != state.Running && subnetState != state.Creating {
|
||||
return false, fmt.Errorf("subnet %q is %s, cannot start vm %q", n.Subnet, subnetState, c.Name)
|
||||
}
|
||||
return subnetState == state.Running, nil
|
||||
})
|
||||
if errors.Is(err, errWaitTimeout) {
|
||||
return fmt.Errorf("timed out waiting for subnet %q to be running", n.Subnet)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return vm.StartVM(db, c.Name, cfg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue