-
Notifications
You must be signed in to change notification settings - Fork 56
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
[BUG] Using a wrong cidr_v4 does not get validated #263
Comments
Hi team, I've been working on this issue and would like to share my approach for your review. Outcome:
Approach:
So, I have tried to extract the Json part of it, and return only the Complete code can be seen in the gist Here. Regarding Error Message Rewriting:
I am a bit confused, would you like to refactor error handling throughout the provider as shown below? Current:
Proposed:
Screenshots for issues: 263, 256 & 249: You can see them error-ing out, This prevents ghost resource creation and quota exhaustion. Issue 263: Issue 256: Issue 249: Regards, |
Hii @Praveen005 |
Hi @uzaxirr, Thanks for the input. We currently have retries only in instance, err := apiClient.CreateInstance(config)
if err != nil{
customErr, parseErr := utils.ParseErrorResponse(err.Error())
if parseErr == nil {
err = customErr
}
return diag.Errorf("[ERR] failed to create an instance: %s", err)
} In // Add retry logic here to delete the node pool
err = retry.RetryContext(ctx, d.Timeout(schema.TimeoutDelete)-time.Minute, func() *retry.RetryError {
_, err := apiClient.GetKubernetesClusterPool(getKubernetesCluster.ID, d.Id())
if err != nil {
if errors.Is(err, civogo.DatabaseClusterPoolNotFoundError) {
log.Printf("[INFO] kubernetes node pool %s deleted", d.Id())
return nil
}
log.Printf("[INFO] error trying to read kubernetes cluster pool: %s", err)
return retry.NonRetryableError(fmt.Errorf("error waiting for Kubernetes node pool to be deleted: %s", err))
}
log.Printf("[INFO] kubernetes node pool %s still exists", d.Id())
return retry.RetryableError(fmt.Errorf("kubernetes node pool still exists"))
})
if err != nil {
return diag.FromErr(err)
} I feel we shouldn't delete this, many a times it errors out because of its dependency on other resources. or should we? Also, is the format of error below okay? Is there anything else, I should take care of? |
@Praveen005 the above seems fine, can you raise a PR |
Hi @uzaxirr, I have raised the PR. When you have a moment, could you please review it? Regards, |
Issues
Using a completely wrong
cidr_v4
causes terraform to keep trying to provision this resource for two minutes rather than failing straight away:This should fail straight away as it does on the API, CLI, etc.
Acceptance Criteria
This ticket should be used as a reference for a bigger piece of work revamping the way we handle errors in terraform. The default behaviour with our provider seems to be to keep trying and it does NOT return the error the API gives, which is a problem.
We need to go through the entire provider and change the behaviour for everything not by writing error messages in terraform provider, but returning errors from the API
The text was updated successfully, but these errors were encountered: