@@ -345,7 +345,7 @@ func resourceServiceInstanceUpdate(ctx context.Context, d *schema.ResourceData,
345
345
}
346
346
347
347
serviceInstanceUpdate := resources.ServiceInstance {
348
- Name : name ,
348
+ Name : name ,
349
349
}
350
350
// Only add in the request body what has changed, because some services don't support updating multiple attributes at the same time
351
351
if d .HasChange ("service_plan" ) {
@@ -367,38 +367,42 @@ func resourceServiceInstanceUpdate(ctx context.Context, d *schema.ResourceData,
367
367
return diag .FromErr (err )
368
368
}
369
369
370
- // Poll the state of the async job
371
- err = common .PollingWithTimeout (func () (bool , error ) {
372
- job , _ , err := session .ClientV3 .GetJob (jobURL )
373
- if err != nil {
374
- return true , err
375
- }
376
-
377
- // Stop polling and return error if job failed
378
- if job .State == constant .JobFailed {
379
- return true , fmt .Errorf (
380
- "Instance %s failed %s, reason: %+v" ,
381
- name ,
382
- space ,
383
- job .Errors (),
384
- )
385
- }
386
- // If job completed, check if the service instance exists
387
- if job .State == constant .JobComplete {
388
- si , _ , _ , err := session .ClientV3 .GetServiceInstanceByNameAndSpace (name , space )
370
+ // jobURL is empty if no update is required or if the updates were done synchronously
371
+ if jobURL != "" {
372
+ // Poll the state of the async job
373
+ err = common .PollingWithTimeout (func () (bool , error ) {
374
+ job , _ , err := session .ClientV3 .GetJob (jobURL )
389
375
if err != nil {
390
376
return true , err
391
377
}
392
- d .SetId (si .GUID )
393
- return true , nil
394
- }
395
378
396
- // Last operation initial or inprogress or job not completed, continue polling
397
- return false , nil
398
- }, 5 * time .Second , d .Timeout (schema .TimeoutUpdate ))
399
- if err != nil {
400
- return diag .FromErr (err )
379
+ // Stop polling and return error if job failed
380
+ if job .State == constant .JobFailed {
381
+ return true , fmt .Errorf (
382
+ "Instance %s failed %s, reason: %+v" ,
383
+ name ,
384
+ space ,
385
+ job .Errors (),
386
+ )
387
+ }
388
+ // If job completed, check if the service instance exists
389
+ if job .State == constant .JobComplete {
390
+ si , _ , _ , err := session .ClientV3 .GetServiceInstanceByNameAndSpace (name , space )
391
+ if err != nil {
392
+ return true , err
393
+ }
394
+ d .SetId (si .GUID )
395
+ return true , nil
396
+ }
397
+
398
+ // Last operation initial or inprogress or job not completed, continue polling
399
+ return false , nil
400
+ }, 5 * time .Second , d .Timeout (schema .TimeoutUpdate ))
401
+ if err != nil {
402
+ return diag .FromErr (err )
403
+ }
401
404
}
405
+
402
406
// We succeeded, disable partial mode
403
407
d .Partial (false )
404
408
return nil
0 commit comments