From d97bd3baac3a3d09b0384829b7a05f00e0e7784d Mon Sep 17 00:00:00 2001 From: JonasS Date: Fri, 15 Dec 2023 16:21:01 +0100 Subject: [PATCH] bugfix: Wait on serve.NextActions to reduce poll count on initial startup (closes #119) --- driver/driver.go | 2 +- driver/setup.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index 5003188..b1e3616 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -505,7 +505,7 @@ func (d *Driver) Create() error { d.ServerID = srv.Server.ID log.Infof(" -> Server %s[%d]: Waiting to come up...", srv.Server.Name, srv.Server.ID) - err = d.waitForRunningServer() + err = d.waitForInitialStartup(srv) if err != nil { return err } diff --git a/driver/setup.go b/driver/setup.go index d24710e..13a5af9 100644 --- a/driver/setup.go +++ b/driver/setup.go @@ -32,6 +32,16 @@ func (d *Driver) waitForRunningServer() error { return nil } +func (d *Driver) waitForInitialStartup(srv hcloud.ServerCreateResult) error { + if srv.NextActions != nil && len(srv.NextActions) != 0 { + if err := d.waitForMultipleActions("server.NextActions", srv.NextActions); err != nil { + return fmt.Errorf("could not wait for NextActions: %w", err) + } + } + + return d.waitForRunningServer() +} + func (d *Driver) makeCreateServerOptions() (*hcloud.ServerCreateOpts, error) { pgrp, err := d.getPlacementGroup() if err != nil {