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: Prevent download terraform with version 1.8.2 or higher #4474

Merged
merged 3 commits into from
Apr 24, 2024

Conversation

stasostrovskyi
Copy link
Contributor

@stasostrovskyi stasostrovskyi commented Apr 24, 2024

what

Short-term fix for #4471. With this change Atlantis will only download terraform version 1.8.1 or lower, still respecting constraints set in required_version field. If required_version is set to >=1.8.2 or higher Atlantis will fallback to default version.

why

Terraform packaging was changed in release 1.8.2 (see https://github.com/hashicorp/terraform/releases/tag/v1.8.2) and Atlantis throws an error for every default and custom workflow when trying to download it. Proper, long-term fix is described here - #4472 (comment).

tests

I have added two test cases to an existing test, but haven't run full Atlantis with this change.

references

@stasostrovskyi stasostrovskyi changed the title [hotfix] Prevent download terraform with version 1.8.2 or higher fix: Prevent download terraform with version 1.8.2 or higher Apr 24, 2024
@stasostrovskyi stasostrovskyi marked this pull request as ready for review April 24, 2024 16:18
@stasostrovskyi stasostrovskyi requested review from a team as code owners April 24, 2024 16:18
@stasostrovskyi stasostrovskyi requested review from chenrui333, lukemassa and nitrocode and removed request for a team April 24, 2024 16:18
@github-actions github-actions bot added the go Pull requests that update Go code label Apr 24, 2024
@MicheleArturo
Copy link

MicheleArturo commented Apr 24, 2024

In my opinion this change is useless as client can set terraform required version upper-bound constrain to "< 1.8.2".

@stasostrovskyi
Copy link
Contributor Author

In my opinion this change is useless as client can set terraform required version upper-bound constrain to "< 1.8.2".

How many repositories you have in your org to fix? :) Also, this is counter-productive in general. People should be able to use any terraform version they want, by providing version(s) in custom image, this change just prevents auto-download function from failing.

@lukemassa
Copy link
Contributor

I tested the code manually and it worked as expected.

Branch Required version string Outcome
main >= 1.5.5 Fails to download 1.8.2
main >= 1.5.5, < 1.8.2 Successfully downloads and runs 1.8.1
stasostrovskyi:prevent_latest_tf_download >= 1.5.5 Successfully downloads and runs 1.8.1
stasostrovskyi:prevent_latest_tf_download >= 1.5.5, < 1.8.2 Successfully downloads and runs 1.8.1

@lukemassa
Copy link
Contributor

In my opinion this change is useless as client can set terraform required version upper-bound constrain to "< 1.8.2".

How many repositories you have in your org to fix? :) Also, this is counter-productive in general. People should be able to use any terraform version they want, by providing version(s) in custom image, this change just prevents auto-download function from failing.

I agree with @stasostrovskyi. IMO this is an issue with atlantis so should be solved at the atlantis level. Having users put "< 1.8.2" in repositories that have terraform that don't actually have such a constraint is confusing. This change makes atlantis have identical behavior that it had yesterday, which is if we specify latest (or something like it) you get 1.8.1. If users actually need some feature in 1.8.2, they can specify that in their required version, and this code will now correctly not attempt to download that version, since it's incompatible w atlantis.

Longer term, we likely should figure out how to extract the binary from >=1.8.2 versions, then we won't need this constraint, but this is a reasonable workaround until then.

nitrocode
nitrocode previously approved these changes Apr 24, 2024
@nitrocode
Copy link
Member

There is a test failure. Please fix

@nitrocode nitrocode dismissed their stale review April 24, 2024 18:48

test failure

@BioEricSalter
Copy link

We're affected by this as well and troubleshooting led me here. I very much appreciate the effort shown here and I understand the desire for a quick fix. Would it not be better though to go ahead and implement the library described in this comment? That seems like a better plan than having a hack workaround in the Atlantis repository.

For a quick workaround though, having this change available as an image (with no intent to merge) seems like a good temporary plan to me.

@stasostrovskyi
Copy link
Contributor Author

There is a test failure. Please fix

It fails on every single PR, and fix for it is here - #4462

@lukemassa
Copy link
Contributor

There is a test failure. Please fix

It fails on every single PR, and fix for it is here - #4462

I agree this is the known issue, should not affect this PR. @nitrocode any concerns?

@lukemassa
Copy link
Contributor

We're affected by this as well and troubleshooting led me here. I very much appreciate the effort shown here and I understand the desire for a quick fix. Would it not be better though to go ahead and implement the library described in this comment? That seems like a better plan than having a hack workaround in the Atlantis repository.

For a quick workaround though, having this change available as an image (with no intent to merge) seems like a good temporary plan to me.

I agree we should investigate alternatives as recommended by terraform, but that will be a larger change and might necessitate a minor release.

As for not producing a release, I personally feel as I mention in my comment above #4474 (comment) that this is now a bug in atlantis and so warrants a release in atlantis.

@jamengual jamengual enabled auto-merge (squash) April 24, 2024 19:42
@jamengual
Copy link
Contributor

We will patch the 0.27.2 and later release the 0.28.0

@jamengual jamengual merged commit cf9137b into runatlantis:main Apr 24, 2024
24 checks passed
@lukemassa
Copy link
Contributor

/cherry-pick 0.27

@lukemassa
Copy link
Contributor

/cherry-pick release-0.27

// Atlantis fails to download version 1.8.2 and higher. So, as a short-term fix,
// we need to block any version higher than 1.8.1 until proper solution is implemented.
// More details on the issue here - https://github.com/runatlantis/atlantis/issues/4471
highestSupportedConstraint, _ := version.NewConstraint("<= 1.8.1")
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if this value was condigurable. I recall a ticket from a frustrated user that could not set the maximum version allowed across their terraform

Copy link
Member

Choose a reason for hiding this comment

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

@nitrocode
Copy link
Member

Thanks again for this fix!

terakoya76 pushed a commit to terakoya76/atlantis that referenced this pull request Dec 31, 2024
kvanzuijlen pushed a commit to kvanzuijlen/atlantis that referenced this pull request Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants