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

feat: Add use plugin cache flag #3720

Merged
merged 25 commits into from
Sep 22, 2023
Merged

feat: Add use plugin cache flag #3720

merged 25 commits into from
Sep 22, 2023

Conversation

wolmi
Copy link
Contributor

@wolmi wolmi commented Aug 31, 2023

what

Add flag to control the usage of plugin cache

why

By using atlantis for a long time we found a posible race condition where multiple projects in the same repository in different folders detects a change in a common module that is used by all the projects.

An example of folder structure is:

├── google
│   ├── environments
│   │   ├── prod
│   │   ├── staging
│   │   ├── dev
│   │   ├── modules
└── atlantis.yaml

Any time a change is made to a module used by the 3 environments a plan needs to run but all the times one ore none of them can run the plan properly becouse the next error:

╷
│ Error: Required plugins are not installed
│ 
│ The installed provider plugins are not consistent with the packages
│ selected in the dependency lock file:
│   - registry.terraform.io/hashicorp/google: the cached package for registry.terraform.io/hashicorp/google 4.80.0 (in .terraform/providers) does not match any of the checksums recorded in the dependency lock file
│ 
│ Terraform uses external plugins to integrate with a variety of different
│ infrastructure services. You must install the required plugins before
│ running Terraform operations.
╵

The package that changes id different on each run that means that seems to be a race condition.

tests

references

#3547

hashicorp/terraform#31964
hashicorp/terraform#33479

@wolmi wolmi requested a review from a team as a code owner August 31, 2023 07:07
@github-actions github-actions bot added the go Pull requests that update Go code label Aug 31, 2023
@GenPage GenPage enabled auto-merge (squash) August 31, 2023 17:51
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

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

Can you add documentation to the site for this?

@GenPage GenPage added waiting-on-response Waiting for a response from the user needs docs labels Aug 31, 2023
auto-merge was automatically disabled September 3, 2023 12:49

Head branch was pushed to by a user without write access

@github-actions github-actions bot added the docs Documentation label Sep 3, 2023
@wolmi
Copy link
Contributor Author

wolmi commented Sep 3, 2023

I've added the flag to the server-configuration section.

cmd/server.go Outdated Show resolved Hide resolved
cmd/server.go Outdated Show resolved Hide resolved
runatlantis.io/docs/server-configuration.md Outdated Show resolved Hide resolved
server/server.go Outdated Show resolved Hide resolved
server/user_config.go Outdated Show resolved Hide resolved
@jamengual
Copy link
Contributor

jamengual commented Sep 4, 2023 via email

@X-Guardian
Copy link
Contributor

I would also mention in the docs that this is a known Terraform issue, not an Atlantis one. Discussion here: hashicorp/terraform#31964 and possible PR to improve the situation here: hashicorp/terraform#33479.

@GenPage GenPage added feature New functionality/enhancement quick-win Is obviously something Atlantis should do and will take <4 hrs work waiting-on-review Waiting for a review from a maintainer and removed waiting-on-response Waiting for a response from the user docs Documentation needs docs labels Sep 11, 2023
GenPage
GenPage previously approved these changes Sep 11, 2023
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

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

LGTM when tests are green, thank you @X-Guardian for the review as well

@GenPage GenPage removed the waiting-on-review Waiting for a review from a maintainer label Sep 11, 2023
@GenPage GenPage enabled auto-merge (squash) September 11, 2023 15:26
@github-actions github-actions bot added the docs Documentation label Sep 11, 2023
@jamengual
Copy link
Contributor

@wolmi can you check the tests?

auto-merge was automatically disabled September 14, 2023 09:46

Head branch was pushed to by a user without write access

@github-actions github-actions bot added the build Relating to how we build Atlantis label Sep 14, 2023
@wolmi wolmi requested a review from GenPage September 14, 2023 09:49
@wolmi
Copy link
Contributor Author

wolmi commented Sep 22, 2023

I've changed the version to pass the test, is anything more need to merge this?

@jamengual
Copy link
Contributor

thanks @wolmi for your contribution

@jamengual jamengual merged commit c35ba0d into runatlantis:main Sep 22, 2023
14 checks passed
```
Set to false if you want to disable terraform plugin cache.

This flag is useful when having multiple projects that need to run a plan and apply in the same PR to avoid the race condition of `plugin_cache_dir` concurrently, this is a terraform known issue, more info:
Copy link

@virgofx virgofx Oct 11, 2023

Choose a reason for hiding this comment

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

Is there any way this sentence could be made more clear?

Specifically, does disabling or enabling of this flag prevent the race condition that's noted in the corresponding bug report?

E.g - one has Atlantis with lots of parallel plans and applies. This flag is "useful" but how? Should it be set to false? If so, the wording should dictate that

ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* feat: Add use plugin cache bool flag

* feat: Added use-plugin-cache doc

* feat: refactor to reflect terrafrom in plugin cache flag

Co-authored-by: Simon Heather <[email protected]>

* fix: missing closing in bash block documentation

* fix: typo in flag example

* feat: improve docs

* feat: performance implications documented

* feat: increase terraform minor version to 1.3.10

---------

Co-authored-by: Simon Heather <[email protected]>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* feat: Add use plugin cache bool flag

* feat: Added use-plugin-cache doc

* feat: refactor to reflect terrafrom in plugin cache flag

Co-authored-by: Simon Heather <[email protected]>

* fix: missing closing in bash block documentation

* fix: typo in flag example

* feat: improve docs

* feat: performance implications documented

* feat: increase terraform minor version to 1.3.10

---------

Co-authored-by: Simon Heather <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Relating to how we build Atlantis docs Documentation feature New functionality/enhancement go Pull requests that update Go code quick-win Is obviously something Atlantis should do and will take <4 hrs work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants