@@ -58,6 +58,8 @@ type Driver struct {
5858 AdditionalKeys []string
5959 AdditionalKeyIDs []int
6060 cachedAdditionalKeys []* hcloud.SSHKey
61+
62+ WaitOnError int
6163}
6264
6365const (
@@ -99,6 +101,9 @@ const (
99101
100102 defaultSSHPort = 22
101103 defaultSSHUser = "root"
104+
105+ flagWaitOnError = "wait-on-error"
106+ defaultWaitOnError = 0
102107)
103108
104109// NewDriver initializes a new driver instance; see [drivers.Driver.NewDriver]
@@ -261,6 +266,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
261266 Usage : "SSH port" ,
262267 Value : defaultSSHPort ,
263268 },
269+ mcnflag.IntFlag {
270+ EnvVar : "WAIT_ON_ERROR" ,
271+ Name : flagWaitOnError ,
272+ Usage : "Wait if an error happens while creating the server" ,
273+ Value : defaultWaitOnError ,
274+ },
264275 }
265276}
266277
@@ -295,6 +306,8 @@ func (d *Driver) setConfigFromFlagsImpl(opts drivers.DriverOptions) error {
295306 d .SSHUser = opts .String (flagSshUser )
296307 d .SSHPort = opts .Int (flagSshPort )
297308
309+ d .WaitOnError = opts .Int (flagWaitOnError )
310+
298311 d .placementGroup = opts .String (flagPlacementGroup )
299312 if opts .Bool (flagAutoSpread ) {
300313 if d .placementGroup != "" {
@@ -450,6 +463,7 @@ func (d *Driver) Create() error {
450463
451464 srv , _ , err := d .getClient ().Server .Create (context .Background (), instrumented (* srvopts ))
452465 if err != nil {
466+ time .Sleep (time .Duration (d .WaitOnError ) * time .Second )
453467 return errors .Wrap (err , "could not create server" )
454468 }
455469
0 commit comments