mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
Add sleep to give orbit a chance to win the id 1 for the host (#2723)
* Add sleep to give orbit a chance to win the id 1 for the host * Wait until we have the current host
This commit is contained in:
parent
a37024e3b1
commit
21153e9400
1 changed files with 30 additions and 0 deletions
|
|
@ -250,6 +250,12 @@ Use the stop and reset subcommands to manage the server and dependencies once st
|
|||
return errors.Wrap(err, "downloading orbit and osqueryd")
|
||||
}
|
||||
|
||||
// Give it a bit of time so the current device is the one with id 1
|
||||
fmt.Println("Waiting for current host to enroll...")
|
||||
if err := waitFirstHost(client); err != nil {
|
||||
return errors.Wrap(err, "wait for current host")
|
||||
}
|
||||
|
||||
fmt.Println("Starting simulated hosts...")
|
||||
cmd = exec.Command("docker-compose", "up", "-d", "--remove-orphans")
|
||||
cmd.Dir = filepath.Join(previewDir, "osquery")
|
||||
|
|
@ -409,6 +415,30 @@ func waitStartup() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func waitFirstHost(client *service.Client) error {
|
||||
retryStrategy := backoff.NewExponentialBackOff()
|
||||
retryStrategy.MaxInterval = 1 * time.Second
|
||||
|
||||
if err := backoff.Retry(
|
||||
func() error {
|
||||
hosts, err := client.GetHosts("")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(hosts) == 0 {
|
||||
return errors.New("no hosts yet")
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
retryStrategy,
|
||||
); err != nil {
|
||||
return errors.Wrap(err, "checking host count")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkDocker() error {
|
||||
// Check installed
|
||||
if _, err := exec.LookPath("docker"); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue