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: fix google_container_cluster duplicating node pools when applied #1463

Merged
merged 1 commit into from
Mar 15, 2022

Conversation

aliscott
Copy link
Member

The google_container_cluster resource pulls all existing node pools into its node_pool attribute when deployed. This duplicates the default pool and any node pools defined in google_container_node_pool resources. To fix this we:

  1. Only add the default node pool subresource if it doesn't already exist in the node_pool array. If it does exist in that array, we add it as part of that.
  2. Check for node pools defined in other resources, and only add them as subresources if they are not.

@aliscott aliscott requested a review from vdmgolub March 15, 2022 13:13
@aliscott aliscott self-assigned this Mar 15, 2022
@aliscott aliscott marked this pull request as ready for review March 15, 2022 13:13
Copy link
Contributor

@vdmgolub vdmgolub left a comment

Choose a reason for hiding this comment

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

Awesome!

The `google_container_cluster` resource pulls all existing node pools into its `node_pool` attribute when deployed. This duplicates the default pool and any node pools defined in `google_container_node_pool` resources. To fix this we:
1. Only add the default node pool subresource if it doesn't already exist in the `node_pool` array. If it does exist in that array, we add it as part of that.
2. Check for node pools defined in other resources, and only add them as subresources if they are not.
@aliscott aliscott force-pushed the fix/deployed-container-cluster branch from f29a762 to ba6b975 Compare March 15, 2022 14:36
Comment on lines +41 to +48
func contains(a []string, x string) bool {
for _, n := range a {
if x == n {
return true
}
}
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

When you guys update the Golang version to 1.18, there's this awesomely helpful package to employ such features: https://github.com/samber/lo

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks awesome!

Copy link
Contributor

Choose a reason for hiding this comment

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

@aliscott aliscott merged commit f80cfca into master Mar 15, 2022
@hugorut hugorut deleted the fix/deployed-container-cluster branch March 16, 2022 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants