-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add preemptible as an option to node config #341
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
Merged
selmanj
merged 6 commits into
hashicorp:master
from
selmanj:add_preemptible_to_nodepool_config
Sep 1, 2017
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ce466ba
Add preemptible as an option to node config
selmanj 5e10400
Check for preemptible in test matching functions
selmanj d684bb1
Move flattenClusterNodeConfig to node_config
selmanj 60fb1e3
Merge branch 'master' into add_preemptible_to_nodepool_config
selmanj ae8e9a1
Handle bools properly when comparing in cluster and node pool tests
selmanj 6810ec0
Use a supported image_type in cluster tests
selmanj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,7 @@ func testAccCheckContainerNodePoolMatches(n string) resource.TestCheckFunc { | |
{"node_config.0.image_type", nodepool.Config.ImageType}, | ||
{"node_config.0.labels", nodepool.Config.Labels}, | ||
{"node_config.0.tags", nodepool.Config.Tags}, | ||
{"node_config.0.preemptible", nodepool.Config.Preemptible}, | ||
} | ||
|
||
for _, attrs := range nodepoolTests { | ||
|
@@ -261,6 +262,9 @@ func nodepoolCheckMatch(attributes map[string]string, attr string, gcp interface | |
if gcpMap, ok := gcp.(map[string]string); ok { | ||
return nodepoolCheckMapMatch(attributes, attr, gcpMap) | ||
} | ||
if gcpBool, ok := gcp.(bool); ok { | ||
return checkBoolMatch(attributes, attr, gcpBool) | ||
} | ||
tf := attributes[attr] | ||
if tf != gcp { | ||
return nodepoolMatchError(attr, tf, gcp) | ||
|
@@ -356,6 +360,7 @@ resource "google_container_node_pool" "np_with_node_config" { | |
"https://www.googleapis.com/auth/logging.write", | ||
"https://www.googleapis.com/auth/monitoring" | ||
] | ||
preemptible = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likewise for testAccCheckContainerNodePoolMatches There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
} | ||
}`, acctest.RandString(10), acctest.RandString(10)) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can you also add a check for this in testAccCheckContainerCluster?
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.
Added!
Interestingly the tests were failing without having to add any changes to check for preemptible (likely because the default is false, and the requested value is true, which creates a perpetual diff unless it's hooked up properly).
BTW, I assumed this method was just checking to see if the resource existed; I didn't realize it did all the checking inside this method. Some other resources look up the remote resource and store the api object in a variable, and then assert on that. Which is preferred for new resources?
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.
I'm not really sure- I did this one sort of as an experiment, and it definitely doesn't catch everything since it just checks that state matches remote, but not that those are actually the values we want (I actually had a bug slip through once because of this). Right now I've been using
TestCheckResourceAttrSet
to check that the correct values are in state for what I care about but I don't know if that actually checks that I did it with a .Set.