Add retry to file delete
@@ -251,9 +251,10 @@ func resourceGitRepositoryFileDelete(d *schema.ResourceData, m interface{}) erro
branch := d.Get("branch").(string)
message := fmt.Sprintf("Delete %s", file)
+ err := resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
objectID, err := getLastCommitId(clients, repoId, branch)
if err != nil {
- return err
+ return resource.NonRetryableError(err)
}
change := &git.GitChange{
@@ -262,7 +263,6 @@ func resourceGitRepositoryFileDelete(d *schema.ResourceData, m interface{}) erro
Path: &file,
},
}
-
_, err = clients.GitReposClient.CreatePush(ctx, git.CreatePushArgs{
RepositoryId: &repoId,
Push: &git.GitPush{
@@ -280,10 +280,17 @@ func resourceGitRepositoryFileDelete(d *schema.ResourceData, m interface{}) erro
},
},
})
+ if err != nil {
+ if utils.ResponseContainsStatusMessage(err, "has already been updated by another client") {
+ return resource.RetryableError(err)
+ }
+ return resource.NonRetryableError(err)
+ }
+ return nil
+ })
if err != nil {
return err
}
-
return nil
}
