Hi team,
I have my custom provider, where I have implemented a wait logic to confirm the deletion of the resource
_, err := isWaitForDelete(apiService, id, d.Timeout(schema.TimeoutDelete))
Then the isWaitForDelete
is like this :
func isWaitForDelete(apiService *service.MyService, id string, timeout time.Duration) (interface{}, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{"notyet"},
Target: []string{"done"},
Refresh: isRemoveRefreshFunc(apiService, id),
Timeout: timeout,
Delay: 10 * time.Second,
MinTimeout: 10 * time.Second,
}
return stateConf.WaitForState()
}
func isRemoveRefreshFunc(apiService *service.MyService, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
response, err := apiService.findServiceTargets(id)
if err != nil {
if response != nil && response.StatusCode == 404 {
return nil, "done", nil
}
return nil, "done", fmt.Errorf("error getting response")
}
return response, "notyet", nil
}
}
The refresh function is returning done
but the wait function keeps on retrying 21 times and returns an error saying Error: couldn't find resource (21 retries)