@@ -33,6 +33,14 @@ func resourceCloudProjectKube() *schema.Resource {
33
33
State : resourceCloudProjectKubeImportState ,
34
34
},
35
35
36
+ Timeouts : & schema.ResourceTimeout {
37
+ Create : schema .DefaultTimeout (15 * time .Minute ),
38
+ Update : schema .DefaultTimeout (10 * time .Minute ),
39
+ Delete : schema .DefaultTimeout (10 * time .Minute ),
40
+ Read : schema .DefaultTimeout (5 * time .Minute ),
41
+ Default : schema .DefaultTimeout (10 * time .Minute ),
42
+ },
43
+
36
44
Schema : map [string ]* schema.Schema {
37
45
"service_name" : {
38
46
Type : schema .TypeString ,
@@ -216,7 +224,7 @@ func resourceCloudProjectKubeCreate(d *schema.ResourceData, meta interface{}) er
216
224
}
217
225
218
226
log .Printf ("[DEBUG] Waiting for kube %s to be READY" , res .Id )
219
- err = waitForCloudProjectKubeReady (config .OVHClient , serviceName , res .Id , []string {"INSTALLING" }, []string {"READY" })
227
+ err = waitForCloudProjectKubeReady (config .OVHClient , serviceName , res .Id , []string {"INSTALLING" }, []string {"READY" }, d . Timeout ( schema . TimeoutCreate ) )
220
228
if err != nil {
221
229
return fmt .Errorf ("timeout while waiting kube %s to be READY: %w" , res .Id , err )
222
230
}
@@ -271,7 +279,7 @@ func resourceCloudProjectKubeDelete(d *schema.ResourceData, meta interface{}) er
271
279
}
272
280
273
281
log .Printf ("[DEBUG] Waiting for kube %s to be DELETED" , d .Id ())
274
- err = waitForCloudProjectKubeDeleted (config .OVHClient , serviceName , d .Id ())
282
+ err = waitForCloudProjectKubeDeleted (d , config .OVHClient , serviceName , d .Id ())
275
283
if err != nil {
276
284
return fmt .Errorf ("timeout while waiting kube %s to be DELETED: %w" , d .Id (), err )
277
285
}
@@ -299,7 +307,7 @@ func resourceCloudProjectKubeUpdate(d *schema.ResourceData, meta interface{}) er
299
307
}
300
308
301
309
log .Printf ("[DEBUG] Waiting for kube %s to be READY" , d .Id ())
302
- err = waitForCloudProjectKubeReady (config .OVHClient , serviceName , d .Id (), []string {"REDEPLOYING" , "RESETTING" }, []string {"READY" })
310
+ err = waitForCloudProjectKubeReady (config .OVHClient , serviceName , d .Id (), []string {"REDEPLOYING" , "RESETTING" }, []string {"READY" }, d . Timeout ( schema . TimeoutUpdate ) )
303
311
if err != nil {
304
312
return fmt .Errorf ("timeout while waiting kube %s to be READY: %w" , d .Id (), err )
305
313
}
@@ -351,7 +359,7 @@ func resourceCloudProjectKubeUpdate(d *schema.ResourceData, meta interface{}) er
351
359
}
352
360
353
361
log .Printf ("[DEBUG] Waiting for kube %s to be READY" , d .Id ())
354
- err = waitForCloudProjectKubeReady (config .OVHClient , serviceName , d .Id (), []string {"UPDATING" , "REDEPLOYING" , "RESETTING" }, []string {"READY" })
362
+ err = waitForCloudProjectKubeReady (config .OVHClient , serviceName , d .Id (), []string {"UPDATING" , "REDEPLOYING" , "RESETTING" }, []string {"READY" }, d . Timeout ( schema . TimeoutUpdate ) )
355
363
if err != nil {
356
364
return fmt .Errorf ("timeout while waiting kube %s to be READY: %w" , d .Id (), err )
357
365
}
@@ -405,7 +413,7 @@ func resourceCloudProjectKubeUpdate(d *schema.ResourceData, meta interface{}) er
405
413
}
406
414
407
415
log .Printf ("[DEBUG] Waiting for kube %s to be READY" , d .Id ())
408
- err = waitForCloudProjectKubeReady (config .OVHClient , serviceName , d .Id (), []string {"REDEPLOYING" , "RESETTING" }, []string {"READY" })
416
+ err = waitForCloudProjectKubeReady (config .OVHClient , serviceName , d .Id (), []string {"REDEPLOYING" , "RESETTING" }, []string {"READY" }, d . Timeout ( schema . TimeoutUpdate ) )
409
417
if err != nil {
410
418
return fmt .Errorf ("timeout while waiting kube %s to be READY: %w" , d .Id (), err )
411
419
}
@@ -422,7 +430,7 @@ func cloudProjectKubeExists(serviceName, id string, client *ovh.Client) error {
422
430
return client .Get (endpoint , res )
423
431
}
424
432
425
- func waitForCloudProjectKubeReady (client * ovh.Client , serviceName , kubeId string , pending []string , target []string ) error {
433
+ func waitForCloudProjectKubeReady (client * ovh.Client , serviceName , kubeId string , pending []string , target []string , timeout time. Duration ) error {
426
434
stateConf := & resource.StateChangeConf {
427
435
Pending : pending ,
428
436
Target : target ,
@@ -436,7 +444,7 @@ func waitForCloudProjectKubeReady(client *ovh.Client, serviceName, kubeId string
436
444
437
445
return res , res .Status , nil
438
446
},
439
- Timeout : 20 * time . Minute ,
447
+ Timeout : timeout ,
440
448
Delay : 5 * time .Second ,
441
449
MinTimeout : 3 * time .Second ,
442
450
}
@@ -445,7 +453,7 @@ func waitForCloudProjectKubeReady(client *ovh.Client, serviceName, kubeId string
445
453
return err
446
454
}
447
455
448
- func waitForCloudProjectKubeDeleted (client * ovh.Client , serviceName , kubeId string ) error {
456
+ func waitForCloudProjectKubeDeleted (d * schema. ResourceData , client * ovh.Client , serviceName , kubeId string ) error {
449
457
stateConf := & resource.StateChangeConf {
450
458
Pending : []string {"DELETING" },
451
459
Target : []string {"DELETED" },
@@ -463,7 +471,7 @@ func waitForCloudProjectKubeDeleted(client *ovh.Client, serviceName, kubeId stri
463
471
464
472
return res , res .Status , nil
465
473
},
466
- Timeout : 20 * time . Minute ,
474
+ Timeout : d . Timeout ( schema . TimeoutDelete ) ,
467
475
Delay : 5 * time .Second ,
468
476
MinTimeout : 3 * time .Second ,
469
477
}
0 commit comments