Skip to content
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

No AWS provider error handler on detailed resource read #1650

Open
raulsh opened this issue Apr 3, 2023 · 0 comments
Open

No AWS provider error handler on detailed resource read #1650

raulsh opened this issue Apr 3, 2023 · 0 comments
Labels
kind/bug Something isn't working

Comments

@raulsh
Copy link

raulsh commented Apr 3, 2023

Description

There is no throttling error handling when reading resources if "deep" option is enabled. When I enable Terraform logs (TF_LOG=trace), I can see the throttling to Route53. But at no time is this error handled, because at least (to my knowledge) I can't get the error from the terraform library. I know there are other cases, like issue #1645. But I think the problem is not limited to a single resource, but it is where the detailed reading is done.

The problem is in these lines:

var newState cty.Value
r := retrier.New(retrier.ConstantBackoff(3, 100*time.Millisecond), nil)
err = r.Run(func() error {
resp := p.grpcProviders[alias].ReadResource(providers.ReadResourceRequest{
TypeName: typ,
PriorState: priorState,
Private: []byte{},
ProviderMeta: cty.NullVal(cty.DynamicPseudoType),
})
if resp.Diagnostics.HasErrors() {
return resp.Diagnostics.Err()
}
nonFatalErr := resp.Diagnostics.NonFatalErr()
if resp.NewState.IsNull() && nonFatalErr != nil {
return errors.Errorf("state returned by ReadResource is nil: %+v", nonFatalErr)
}
newState = resp.NewState
return nil
})

In my case, because I needed to use it, I just added this inside retry block

if resp.NewState.IsNull() {
	logrus.Info("state returned by ReadResource is nil, retrying ...")
	return errors.Errorf("state returned by ReadResource is nil")
}

I know this is not a good solution, because there may be other reasons why the response is null. But it works.

In some cases, when a resource is not found, driftctl scan fails and can't save an output.

Environment

How to reproduce

In my case, having a tons of Route53 records.

Possible Solution

  1. Implement a exponential backoff (instead of linear) according to AWS recommendations.
  2. Handle in retry logic in known cases like throttling or timeout

Additional context

@raulsh raulsh added the kind/bug Something isn't working label Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant