Add retry calls to protect against api rate limiting

This commit is contained in:
Brett Mack 2015-11-17 17:27:39 +00:00
parent c8dfecc65f
commit 29dfc4322e
1 changed files with 19 additions and 16 deletions

View File

@ -313,26 +313,29 @@ func resourceVcdVAppDelete(d *schema.ResourceData, meta interface{}) error {
vapp, err := vcdClient.OrgVdc.FindVAppByName(d.Id())
if err != nil {
return fmt.Errorf("error finding vdc: %s", err)
return fmt.Errorf("error finding vapp: %s", err)
}
err = retryCall(4, func() error {
task, err := vapp.Undeploy()
if err != nil {
return fmt.Errorf("Error Powering Off: %#v", err)
}
err = task.WaitTaskCompletion()
if err != nil {
return fmt.Errorf("Error completing tasks: %#v", err)
return fmt.Errorf("Error undeploying: %#v", err)
}
task, err = vapp.Delete()
return task.WaitTaskCompletion()
})
if err != nil {
return fmt.Errorf("Error Powering Off: %#v", err)
}
err = task.WaitTaskCompletion()
if err != nil {
return fmt.Errorf("Error completing tasks: %#v", err)
return err
}
return nil
err = retryCall(4, func() error {
task, err := vapp.Delete()
if err != nil {
return fmt.Errorf("Error deleting: %#v", err)
}
return task.WaitTaskCompletion()
})
return err
}