-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use retry.StateChangeConf for encryption-at-rest resource. #1463
Conversation
Running
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments. Make sure to run the acceptance tests locally
Pending: []string{"RETRY"}, | ||
Target: []string{"COMPLETED", "ERROR"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Should we make RETRY/COMPLETE/ERROR constants and use them in all the resources with a similar strategy?
_, err := stateConf.WaitForStateContext(ctx) | ||
if err != nil { | ||
return diag.FromErr(fmt.Errorf(errorCreateEncryptionAtRest, err)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_, err := stateConf.WaitForStateContext(ctx) | |
if err != nil { | |
return diag.FromErr(fmt.Errorf(errorCreateEncryptionAtRest, err)) | |
} | |
if _, err := stateConf.WaitForStateContext(ctx); err != nil { | |
return diag.FromErr(fmt.Errorf(errorCreateEncryptionAtRest, err)) | |
} |
Refresh: resourceMongoDBAtlasEncryptionAtRestCreateRefreshFunc(ctx, d.Get("project_id").(string), conn, encryptionAtRestReq), | ||
Timeout: timeout, | ||
MinTimeout: 30 * time.Second, | ||
Delay: 1 * time.Minute, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the delay was 10 seconds. Any reason why is now 1 minutes?
if strings.Contains(err.Error(), "CANNOT_ASSUME_ROLE") || strings.Contains(err.Error(), "INVALID_AWS_CREDENTIALS") || | ||
strings.Contains(err.Error(), "CLOUD_PROVIDER_ACCESS_ROLE_NOT_AUTHORIZED") { | ||
log.Printf("warning issue performing authorize EncryptionsAtRest not done try again: %s \n", err.Error()) | ||
log.Println("retrying ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use a more golang idiomatic way to handle the error: with error.is() https://gosamples.dev/check-error-type/
Description
Use
retry.StateChangeConf
instead of thefor loop
to remove technical debt and improve retry strategy.Link to any related issue(s): https://jira.mongodb.org/browse/INTMDB-1039
Type of change:
Required Checklist:
Further comments