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: disable autoplan label #3649

Merged
merged 22 commits into from
Sep 25, 2023

Conversation

ghaiszaher
Copy link
Contributor

@ghaiszaher ghaiszaher commented Aug 5, 2023

what

  • Add new flag to allow disabling auto-planning only on pull requests that have a certain label
  • Command line flag: --disable-autoplan-label=<string>
  • Environment variable: ATLANTIS_DISABLE_AUTOPLAN_LABEL=<string>
  • If --disable-autoplan flag is set to true, the new flag --disable-autoplan-label has no effect
  • If --disable-autoplan-label is unset or if it's an empty string, it will have no effect

why

We encounter this especially in a large repository used by many developers. It gets hard to manage the lock queue so we use an external bot to manage the queue for us. Only in certain pull requests, we don't want the autoplan feature to kick in.

  • Example 1: Working on a multi-project pull request and some locks are taken by other pull requests. You'd rather wait until all locks are free before planning all the directories (in the meantime, you receive pull request reviews and push commits to the PR)
  • Example 2: A pull request that is marked as ready for review but requires some changes and you don't want to keep acquiring the lock on each commit
  • Example 3: Automations that create pull requests but you don't want them to take the lock on each created PR.

tests

Tested with a Github pull request and environment variable ATLANTIS_DISABLE_AUTOPLAN_LABEL=no-autoplan.

  1. Adding the label then pushing a commit:
image
  1. Creating a pull request with that label doesn't trigger a plan:
image
  1. Creating a pull request without the label still plans:
image

references

Copy link

@raynigon raynigon left a comment

Choose a reason for hiding this comment

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

LGTM

It would be nice to have more test coverage for the VCS implementations.
Because the other clients can be implemented on an "On Demand" bases, this PR can be merged without these implementations.

server/events/vcs/github_client.go Show resolved Hide resolved
server/events/vcs/gitlab_client.go Show resolved Hide resolved
Copy link

@raynigon raynigon left a comment

Choose a reason for hiding this comment

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

LGTM

@ghaiszaher
Copy link
Contributor Author

@jamengual @GenPage @chenrui333 could you take a look at this PR? We'd love to have the feature included in the next release.

@raizyr
Copy link

raizyr commented Aug 17, 2023

I found this because I also need this feature. My use case is that I have a pull request created via automation and need to include terraform args to replace some resources. ie. atlantis plan -p project_a -- -replace="resource.to_replace". The automation creates a PR triggering autoplan, then the comment to plan & replace is added which Atlantis replies with a Plan error because the workspace is locked by the autoplan. Being able to create the PR and have Atlantis skip the autoplan would be ideal.

@GenPage
Copy link
Member

GenPage commented Aug 31, 2023

I will be taking a look over the weekend.

@GenPage GenPage added this to the v0.26.0 milestone Aug 31, 2023
@GenPage GenPage removed the docs Documentation label Aug 31, 2023
@GenPage GenPage added feature New functionality/enhancement waiting-on-review Waiting for a review from a maintainer labels Aug 31, 2023
# Conflicts:
#	server/events/command_runner.go
#	server/user_config.go
@github-actions github-actions bot added the docs Documentation label Sep 7, 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, good tests. Thank you for the feature contribution

@GenPage GenPage merged commit 80ecc38 into runatlantis:main Sep 25, 2023
15 checks passed
@ghaiszaher ghaiszaher deleted the feat/no-autoplan-label branch September 25, 2023 17:54
@X-Guardian
Copy link
Contributor

Hi @ghaiszaher, just wanted to say thankyou for coming up with this feature, as it has made our apply/rebase/merge process much quicker on our infra repo!

@brandon-fryslie
Copy link

We've had plan locks turned off entirely (both Atlantis and Terraform) in our dev environment and there seem to be 0 consequences. It's been months. They were a massive bottleneck.

@jamengual
Copy link
Contributor

jamengual commented Jan 11, 2024 via email

@nitrocode
Copy link
Member

I've sometimes wondered if removing the locks is a working solution. Good to know that some people have disabled it and it's working for them. I would hope that if you do not run into edge cases then maybe we can disable locking in atlantis by default and turn it on with a flag when users want it.

@nitrocode
Copy link
Member

@brandon-fryslie please see #2876

ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* feat: disable autoplan label

* documentation

* revert unrelated change

* fix property

* gitlab and github

* dd more test

* small fixes

* add tests for github and gitlab clients

* fix: remove unrelated comments

* fmt

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* feat: disable autoplan label

* documentation

* revert unrelated change

* fix property

* gitlab and github

* dd more test

* small fixes

* add tests for github and gitlab clients

* fix: remove unrelated comments

* fmt

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation feature New functionality/enhancement go Pull requests that update Go code provider/azuredevops provider/bitbucket provider/github provider/gitlab waiting-on-review Waiting for a review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants