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: Fixed launch template version infinite plan issue and improved rolling updates #1447

Merged

Conversation

jaimehrubiks
Copy link
Contributor

@jaimehrubiks jaimehrubiks commented Jun 16, 2021

PR o'clock

Resolves #1446

Description

The recent PR (#1419) added support to set the launch template version on auto-generated launch templates for managed node groups, with the purpose of delaying rolling updates. However, it adds a bug caused by setting "$Latest" as the parameter to the node groups API call, which causes a never settled terraform plan, as the $Latest (or $Default) string is accepted by the API but translated into the corresponding integer afterwards. Read here: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group#version

This PR fixes this issue and sets the corresponding integer directly. When the user specifies either "$Latest" or "$Default" on the "launch_template_version" variable, the module will now resolve the corresponding version number as an integer and use that value instead.

This PR also adds the variable "update_default_version" which will allow delaying the rolling update without knowing a specific version number.

How to delay a Rolling Update?

Using the default values:

launch_template_version: "$Latest"
update_default_version: true

We achieve: 1) Always use the latest changes on the launch template, 2) Push the $Default tag to the latest version

Whenever we need to delay the rolling update, we can simply set:

launch_template_version: "$Default"
update_default_version: false

And when we apply, only the launch template will be changed, but not the node groups, as they will reference to the old "default" which was the last time when update_default_version was set to true

When we revert those changes, the node groups will be updated.

Also, by setting:

    launch_template_version: "$Default"

In all cases, will achieve the same result and we only need to play with update_default_version variable

Note that you cant make it such that "new instances use the new launch template but we don't roll update the old one". You can, however, delay the rolling update as stated above, and try if the new version is working by manually going to the AWS cli and creating a new VM out of the launch template version desired (the latest number for example).

@jaimehrubiks jaimehrubiks changed the title Fix launch template version infinite plan and improve rolling updates delaying fix: Resolve launch template version infinite plan issue and improve rolling updates delaying Jun 16, 2021
@jaimehrubiks
Copy link
Contributor Author

Not sure what is the pre-commit check complaining about

why the check is asking me to change

id      = aws_launch_template.workers[each.key].id

with

id = aws_launch_template.workers[each.key].id

when that part is aligned with above resource

@ArchiFleKs
Copy link
Contributor

Not sure what is the pre-commit check complaining about

why the check is asking me to change

id      = aws_launch_template.workers[each.key].id

with

id = aws_launch_template.workers[each.key].id

when that part is aligned with above resource

I'm pretty sure the CI error is due to this becasue teraform-docs file are extracted in the working folder and there is LICENSE file messing up the CI. I had the same issue on some of my repo. I'll make a PR if there is not one already

@jaimehrubiks
Copy link
Contributor Author

Any way I can help with getting this merged @barryib ?

@llamahunter
Copy link

What is blocking this PR merge? The "$Latest" thing is causing unnecessary 'drift' notifications in our terraform plans. Unfortunately, the launch template is not exported from the module as an output, so I can't fetch its latestVersion property. Needs to be fixed in the module.

Or, I could hard code the current value of the launch template version, but worried it might miss updates.

@jaimehrubiks
Copy link
Contributor Author

jaimehrubiks commented Jun 25, 2021

Looks like main maintainer is just away this week

Edit: this month*?

@Chili-Man
Copy link
Contributor

Any updates on this? I'm more then happy to help in any way to get this merged

@Chili-Man
Copy link
Contributor

I have tested and validated that this change works as expected. I can post the plan changes of with / without the fix to compare the difference if need be

@toneill818
Copy link
Contributor

Any updates on this PR?

@Chili-Man
Copy link
Contributor

@jaimehrubiks I'm more then happy to take over this change if you don't have time

@jaimehrubiks
Copy link
Contributor Author

@Chili-Man this PR is fully functional. I am actually using it right now. We are only waiting for a maintainer of this repository to review, accept all the pending PRs, and make a release. @barryib was the one doing it for a very long time, but he is currently missing.

@Chili-Man
Copy link
Contributor

Chili-Man commented Jul 21, 2021

@jaimehrubiks indeed it is functional, I'm using your changes as well; however, this PR is currently failing the Max TF pre-commit check , on the terraform fmt test: https:/terraform-aws-modules/terraform-aws-eks/pull/1447/checks?check_run_id=2843241949#step:6:9 ; I thought it was because of that. I did not realize that @barryib was MIA. maybe one of the other members @bryantbiggs @brandonjbjelland or @antonbabenko can help us out?

@divomen
Copy link

divomen commented Jul 27, 2021

I also faced this issue. It would be great if it was merged.

@yafanasiev
Copy link

Just hit this as well as #1461. Had to fork the base repo, and everything now works beautifully. Hope this gets merged soon.

@tnimni
Copy link

tnimni commented Aug 4, 2021

@Chili-Man the fmt fails because of line 51 in that file
after the : there is a line break and than another line break to close the ')', if you change the code to be all in one line i.e. making lines 51-53 a single line the fmt will work as expected. I hope it is clear if not please let me know

vijay-veeranki added a commit to ministryofjustice/cloud-platform-infrastructure that referenced this pull request Aug 9, 2021
The v17.1.0 have an issue(terraform-aws-modules/terraform-aws-eks#1446)

where each plan will have a change for the templates,
this cause our divergence pipeline fail"
# Pinned the version until this fix get merged
terraform-aws-modules/terraform-aws-eks#1447
vijay-veeranki added a commit to ministryofjustice/cloud-platform-infrastructure that referenced this pull request Aug 9, 2021
The v17.1.0 have an issue(terraform-aws-modules/terraform-aws-eks#1446)

where each plan will have a change for the templates,
this cause our divergence pipeline fail"
Pinned the version until this fix get merged
terraform-aws-modules/terraform-aws-eks#1447
vijay-veeranki added a commit to ministryofjustice/cloud-platform-infrastructure that referenced this pull request Aug 9, 2021
* Pin launch_template_version for EKS module

The v17.1.0 have an issue(terraform-aws-modules/terraform-aws-eks#1446)

where each plan will have a change for the templates,
this cause our divergence pipeline fail"
Pinned the version until this fix get merged
terraform-aws-modules/terraform-aws-eks#1447
@toneill818
Copy link
Contributor

It seems like this repository may need more maintainers, it has not had any new changes accepted for almost two months. @barryib @bryantbiggs @brandonjbjelland @antonbabenko Are you guys open to adding more maintainers to this project?

@bryantbiggs
Copy link
Member

hi all, I haven't had time to test this but - does this introduce any breaking changes? does anyone have a plan/diff they could share for this change against master?

@jaimehrubiks
Copy link
Contributor Author

No, there are no breaking changes. And there are no plan/diffs because the actual result of this PR is to prevent a diff from happening when no changes are made to the code.

@yafanasiev
Copy link

@bryantbiggs I've been using the latest version of module with this patch applied and had no issues with it. Infinite update is no longer present on no-changes plans, and managed node groups launch templates version updates are working as expected.

Copy link
Member

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

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

change seems small enough and seems to jive with what we've seen on ASG module - @antonbabenko / @barryib 👍🏼

@aidan-mundy
Copy link
Contributor

This MR appears to be ready to go and has two approvals. Any particular reason we are waiting on it?

@AndriiBarabash
Copy link
Contributor

I noticed that Pre-Commit / Max TF pre-commit (1.0.0) job fails. Do we have any ideas on how to fix it?

@ArchiFleKs
Copy link
Contributor

I noticed that Pre-Commit / Max TF pre-commit (1.0.0) job fails. Do we have any ideas on how to fix it?

@andreyBar it seems it is the terraform-docs README, but there is also some fmt to do on the code.

I've made a very small PR here #1541 to only extract the binary

@bryantbiggs
Copy link
Member

@jaimehrubiks once we merge #1541, could you rebase with master and resolve the conflicts please 🙏🏼

@antonbabenko antonbabenko changed the title fix: Resolve launch template version infinite plan issue and improve rolling updates delaying fix: Fixed launch template version infinite plan issue and improved rolling updates Aug 25, 2021
@antonbabenko antonbabenko merged commit d17007b into terraform-aws-modules:master Aug 25, 2021
@antonbabenko
Copy link
Member

@bryantbiggs I did the fix myself to release a bit quicker.

@antonbabenko
Copy link
Member

v17.3.0 has been just released.

@jaimehrubiks
Copy link
Contributor Author

Thanks @antonbabenko

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node groups' launch template "$Latest" version producing an infinite always-changing plan