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

Fix issue with with Opsworks and empty Custom Cook Book sources #6078

Merged
merged 2 commits into from
Apr 21, 2016

Conversation

u2mejc
Copy link
Contributor

@u2mejc u2mejc commented Apr 8, 2016

This resolves #6077

@u2mejc
Copy link
Contributor Author

u2mejc commented Apr 8, 2016

I've confirmed this persists with HEAD: Terraform v0.6.15-dev (aef5bcf98227b0ac964657a29ef2a1ebeed19a51)

I've created a simple gist to demonstrate the fix against: https://gist.github.com/u2mejc/c1613ed663daa9bd3eb8749e8a658cfd

@catsby
Copy link
Contributor

catsby commented Apr 8, 2016

Replied to #6077, I'd like for us to considering not making this computed, but instead only saving the information when there is actual a custom cookbook returned

@u2mejc
Copy link
Contributor Author

u2mejc commented Apr 12, 2016

@catsby said:

Hey @u2mejc – do you have a simple config that demonstrates this problem? The computed flag tells Terraform that the API may return data and to not worry about it; the resource itself is not populating empty data on it's own. Or, it shouldn't 😄

I did some debugging, and found that the CustomCookbooksSource source that's returned from DescribeStacks call here is coming back empty, instead of the typical nil. As a result we're storing empty values when we should omit it if nothing there is found. Do you think you could adjust #6078 to account for that?

Moving development discussion here so we don't get too split brained. I'm guessing you saw the example to reproduce the issue above. ☝️

Replied to #6077, I'd like for us to considering not making this computed, but instead only saving the information when there is actual a custom cookbook returned

I'm not sure I understand, by not making this computed did you mean something different then what is already dropped in this PR? I thought Terraform was populating the empty strings intentioanlly when computed based on inline comments like this:

// If the key does exist in the schema but doesn't exist in the configuration,
// then the default value for that type will be returned. For strings, this is
// "", for numbers it is 0, etc.

Is that not what's expected?

@u2mejc
Copy link
Contributor Author

u2mejc commented Apr 13, 2016

@catsby I'm happy to be able to help, getting Terraform to fully support OpsWorks is aligned with my current sprint. But I'm not super familiar with the code base. Can you please give a little more context around your ask, I'll be happy to work on the code for you then. 👍

@u2mejc
Copy link
Contributor Author

u2mejc commented Apr 18, 2016

@apparentlymart I was wondering if you could look at this PR? I know you're probably most intimate with it.

Use case is for creating OpsWorks stacks without custom repos, namely for recipes that are all available in the supermarket. I think this change is pretty straightforward, can you think of a use case this wouldn't work?

@apparentlymart
Copy link
Contributor

@u2mejc I'm not sure exactly what @catsby was getting at here, but I think what he's suggesting is that instead of changing the schema we would check for and ignore an empty cookbooks source.

So maybe in resourceAwsOpsworksSetStackCustomCookbooksSource the condition would become:

    if v != nil && *.v.Type != "" {
        // ...

This would mean that if the Opsworks API returns a the cookbooks source as a bunch of empty strings then we just keep the values we already had.

Hopefully @catsby can confirm whether that was what he was driving at.

I'm super rusty on this code so I don't have any better theories than his, but I would agree that setting it as Computed is probably just masking the issue by ignoring the diff, and so other related problems may still arise as a result.

@u2mejc
Copy link
Contributor Author

u2mejc commented Apr 19, 2016

Thank you Martin!

I don't believe that AWS should ever respond with computed values for custom cookbooks? But if @catsby believes it would be better to ignore Terraform creating empty strings, I'm happy to adjust the PR.

Clint, let me know if you have time to look at this and comment or if you'd like Paul / Martin to approve it.

@catsby
Copy link
Contributor

catsby commented Apr 19, 2016

Hi friends! I'm terribly sorry to have left you hanging here. I popped in, said a thing, and then left, leaving you not unable to understand my glaring typo 😄

I'd like for us to considering not making this computed, but instead only saving the information when there is actual a custom cookbook returned

What I meant was not changing the computed nature, but instead only saving data if it's non-empty. I alluded to that in my comment #6077 (comment) but I failed to speak clearly, sorry!

What I'm seeing here is that if you do not specify a custom cookbook, that the stack.CustomCookbooksSource still has an "empty" cookbook, which is getting saved to state.

So, what @apparentlymart said, in that we should verify it's not nil and also contains something meaningful. I would want to triple check that this is true though (the empty value)

I hope that clears things up! I apologize again for the science* silence

*edit: I don't think I ever apologize for science ;)

@u2mejc
Copy link
Contributor Author

u2mejc commented Apr 19, 2016

Thank you Clint!!! I'll rework the PR and shoot it back up.

@u2mejc
Copy link
Contributor Author

u2mejc commented Apr 20, 2016

@catsby Per your request, I've adjusted this PR to simply check for nil and empty string, instead of disabling the computed value. Please let me know if there is anything else you'd like me to add. 👍

@catsby catsby changed the title Remove computed value on opsworks update Fix issue with with Opsworks and empty Custom Cook Book sources Apr 21, 2016
@catsby
Copy link
Contributor

catsby commented Apr 21, 2016

Excellent, thank you!

@catsby catsby merged commit f430fe2 into hashicorp:master Apr 21, 2016
@ghost
Copy link

ghost commented Apr 26, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

provider/aws : Opsworks fails on update
4 participants