@@ -58,6 +58,8 @@ type Driver struct {
58
58
AdditionalKeys []string
59
59
AdditionalKeyIDs []int
60
60
cachedAdditionalKeys []* hcloud.SSHKey
61
+
62
+ WaitOnError int
61
63
}
62
64
63
65
const (
@@ -99,6 +101,9 @@ const (
99
101
100
102
defaultSSHPort = 22
101
103
defaultSSHUser = "root"
104
+
105
+ flagWaitOnError = "wait-on-error"
106
+ defaultWaitOnError = 0
102
107
)
103
108
104
109
// NewDriver initializes a new driver instance; see [drivers.Driver.NewDriver]
@@ -261,6 +266,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
261
266
Usage : "SSH port" ,
262
267
Value : defaultSSHPort ,
263
268
},
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
+ },
264
275
}
265
276
}
266
277
@@ -295,6 +306,8 @@ func (d *Driver) setConfigFromFlagsImpl(opts drivers.DriverOptions) error {
295
306
d .SSHUser = opts .String (flagSshUser )
296
307
d .SSHPort = opts .Int (flagSshPort )
297
308
309
+ d .WaitOnError = opts .Int (flagWaitOnError )
310
+
298
311
d .placementGroup = opts .String (flagPlacementGroup )
299
312
if opts .Bool (flagAutoSpread ) {
300
313
if d .placementGroup != "" {
@@ -450,6 +463,7 @@ func (d *Driver) Create() error {
450
463
451
464
srv , _ , err := d .getClient ().Server .Create (context .Background (), instrumented (* srvopts ))
452
465
if err != nil {
466
+ time .Sleep (time .Duration (d .WaitOnError ) * time .Second )
453
467
return errors .Wrap (err , "could not create server" )
454
468
}
455
469
0 commit comments