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

Changing tags causes node groups to be replaced. #843

Closed
1 of 4 tasks
blongman-snapdocs opened this issue Apr 21, 2020 · 4 comments · Fixed by #867 or #868
Closed
1 of 4 tasks

Changing tags causes node groups to be replaced. #843

blongman-snapdocs opened this issue Apr 21, 2020 · 4 comments · Fixed by #867 or #868

Comments

@blongman-snapdocs
Copy link

I have issues

I'm submitting a...

  • bug report
  • feature request
  • support request - read the FAQ first!
  • kudos, thank you, warm fuzzy

What is the current behavior?

When I change the values of tags, a plan shows that all node groups need to be replaced:

 (feature/DEVOPS-586/recreate-east-cluster-but-better) $ terraform plan -no-color | grep "must be replaced"
  # module.eks.local_file.kubeconfig[0] must be replaced
  # module.eks.module.node_groups.aws_eks_node_group.workers["jobs"] must be replaced
  # module.eks.module.node_groups.aws_eks_node_group.workers["web"] must be replaced
  # module.eks.module.node_groups.random_pet.node_groups["jobs"] must be replaced
  # module.eks.module.node_groups.random_pet.node_groups["web"] must be replaced

If this is a bug, how to reproduce? Please include a code sample if relevant.

Create a cluster with node groups, and then change a base level tag.

What's the expected behavior?

Tags are updated in place.

Are you able to fix this problem and submit a PR? Link here if you have already.

No.

Environment details

  • Affected module version: 11.0.0
  • OS: OS-X 10.14.6
  • Terraform version: 0.12.10

Any other relevant info

@dpiddockcmp
Copy link
Contributor

Yes, this is unfortunate behaviour with how everything was stitched together to ensure dependency ordering in the one-shot module.

From my understanding of how Terraform works, this is roughly the reason behind why things gets recreated:

  • The aws_eks_cluster resource is now in an unknown state at refresh time due to pending changes
  • One of the null_data_source.node_groups data source's inputs is now "unknown" and so it can't be refreshed at "refresh" time. The refresh is delayed until apply time. Its outputs are now "unknown". This data source is required to enforce dependency between the eks_node_group and other required resources
  • node_groups.random_pet.node_groups has an unknown input, so is tagged for updating
  • node_groups.aws_eks_node_group.workers thus get tagged for recreation as its name will be changed

I don't think there's much we can do design-wise in the module to work around this particular issue at this time. Terraform 0.13 is scheduled to get a bunch of dependency improvements around modules: hashicorp/terraform#17101 . depends_on against variables would be the magic feature.

Work arounds:

  • You can avoid the recreation of the eks_node_group by using targetted apply. e.g. terraform plan -target=module.eks.aws_eks_cluster.this
  • Maybe running with refresh turned off would work around the data source unknown issue? terraform plan -refresh=false
  • A bigger change: have the node_groups in a different configuration. There's half support for using the module stand alone but it should be improved.

@blongman-snapdocs
Copy link
Author

Thanks for getting back to me on this. The tags aren't an giant issue for me quite yet, but if they become so (like we actually start tacking expenses to tags), it looks like I could remove the node group statements from the module input and define one or more aws_eks_node_groups separately, and import the existing node groups in to them.

@barryib
Copy link
Member

barryib commented May 6, 2020

After some tests, I ended up with this possible fix #868.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.