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

provider: Add AWSClient.StopContext #4179

Closed
wants to merge 1 commit into from
Closed

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Apr 11, 2018

Add ?w=1 to the PR files URL make it legible.

Reference: #4177

Provider smoke tests okay in the test framework 😉

make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsAvailabilityZone'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccDataSourceAwsAvailabilityZone -timeout 120m
=== RUN   TestAccDataSourceAwsAvailabilityZone
--- PASS: TestAccDataSourceAwsAvailabilityZone (9.45s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	9.493s

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. provider Pertains to the provider itself, rather than any interaction with AWS. labels Apr 11, 2018
@bflad bflad requested review from catsby, radeksimko and paultyng April 11, 2018 19:51
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Apr 11, 2018
@@ -238,7 +240,7 @@ func (c *AWSClient) IsChinaCloud() bool {
}

// Client configures and returns a fully initialized AWSClient
func (c *Config) Client() (interface{}, error) {
func (c *Config) Client() (*AWSClient, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this change locally makes sense, but I'm curious if there was any particular motivation for it aside from "cleanup"? I'd be potentially worried it will cause some troubles elsewhere where we expect interface{} and cast it to *AWSClient as casting a type which was already casted means crash. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm just overly cautious...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can switch it back, but I do not see why we need to hide it and it introduces extra type setting. Explicit > Implicit, in my mind anyways. 😄

if v, ok := d.GetOk("allowed_account_ids"); ok {
config.AllowedAccountIds = v.(*schema.Set).List()
}
// replaces the context between tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be a little bit more specific here about why do we need to do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://godoc.org/github.com/hashicorp/terraform/helper/schema#Provider

    // MetaReset is called by TestReset to reset any state stored in the meta
    // interface.  This is especially important if the StopContext is stored by
    // the provider.
    MetaReset func() error

Duplicated from azurerm:

https://github.com/terraform-providers/terraform-provider-azurerm/blob/e44d6292405662e4f20bfd21d540a18fa9a2d58f/azurerm/provider.go#L279-L283

}

p.ConfigureFunc = providerConfigure(p)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly not a blocker, but this whole extraction makes me think we should perhaps make the StopContext available more easily via ResourceData, else we'll end up doing this in all providers. 😑

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a precedent for this implementation pattern, but I second Radek's thoughts on this one, that the ctx should be surfaced in a cleaner manner if possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't hold up this PR personally, but I do think its worth looking at a PR in to core as well.

@radeksimko
Copy link
Member

FWIW I'm certainly up for addressing the problem on the SDK integration side, but I think the root cause which users hit much more often lies in our retriers which are currently not cancellable, see https://github.com/hashicorp/terraform/issues/11350

@paultyng
Copy link
Contributor

paultyng commented Apr 13, 2018

In your retry func can you do something similar to:

select {
  case <-StopContext.Done():
    //return non-retryable
  default:
    //keep trying...
}

@bflad
Copy link
Contributor Author

bflad commented Apr 20, 2018

@radeksimko @paultyng where did we land with this PR?

@bflad
Copy link
Contributor Author

bflad commented Jul 12, 2018

Closing this out as it seems it will not be handled this way.

@bflad bflad closed this Jul 12, 2018
@bflad bflad deleted the provider-stop-context branch July 12, 2018 19:38
@ghost
Copy link

ghost commented Apr 4, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. provider Pertains to the provider itself, rather than any interaction with AWS. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants