Skip to content

Commit

Permalink
Return error on task failure (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
posriniv authored Jul 17, 2024
1 parent 1f56fda commit 7e47886
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion managed/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

// Use to differentiate errors
var ErrFailedTask = errors.New("")
var ErrFailedTask = errors.New("the task failed")

func getProjectId(ctx context.Context, apiClient *openapiclient.APIClient, accountId string) (projectId string, projectIdOK bool, errorMessage string) {
accountResp, resp, err := apiClient.AccountApi.ListAccounts(ctx).Execute()
Expand Down
3 changes: 3 additions & 0 deletions managed/resource_allow_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ func removeAllowListFromCluster(ctx context.Context, accountId string, projectId
if asState == string(openapiclient.TASKACTIONSTATEENUM_SUCCEEDED) {
return nil
}
if asState == string(openapiclient.TASKACTIONSTATEENUM_FAILED) {
return ErrFailedTask
}
} else {
return retry.RetryableError(errors.New("unable to check edit network allow list for cluster : " + message))
}
Expand Down
3 changes: 3 additions & 0 deletions managed/resource_associate_db_audit_export_config_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ func (r resourceAssociateDbAuditExportConfigCluster) Delete(ctx context.Context,
if asState == string(openapiclient.TASKACTIONSTATEENUM_SUCCEEDED) {
return nil
}
if asState == string(openapiclient.TASKACTIONSTATEENUM_FAILED) {
return ErrFailedTask
}
} else {
return retry.RetryableError(errors.New("Unable to check DB audit log config removal: " + message))
}
Expand Down
6 changes: 6 additions & 0 deletions managed/resource_associate_me_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ func (r resourceAssociateMetricsExporterCluster) Create(ctx context.Context, req
if asState == string(openapiclient.TASKACTIONSTATEENUM_SUCCEEDED) {
return nil
}
if asState == string(openapiclient.TASKACTIONSTATEENUM_FAILED) {
return ErrFailedTask
}
} else {
return retry.RetryableError(errors.New("Unable to get check metrics exporter cluster association: " + message))
}
Expand Down Expand Up @@ -251,6 +254,9 @@ func (r resourceAssociateMetricsExporterCluster) Delete(ctx context.Context, req
if asState == string(openapiclient.TASKACTIONSTATEENUM_SUCCEEDED) {
return nil
}
if asState == string(openapiclient.TASKACTIONSTATEENUM_FAILED) {
return ErrFailedTask
}
} else {
return retry.RetryableError(errors.New("Unable to check metrics exporter cluster association: " + message))
}
Expand Down

0 comments on commit 7e47886

Please sign in to comment.