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: Delete locks and workdirs with potentially stale previous plans which fixes 1624 #1704

Conversation

giuli007
Copy link
Contributor

@giuli007 giuli007 commented Jul 14, 2021

This PR is an alternative to #1633 and aims to fix #1624

It solves the same problem but instead of deleting plans and locks directly it uses the DeleteLocksByPull method.

As a consequence every time an autoplan or generic atlantis plan command is issued it completely removes the working dir (which might be more than one for a single PR if non-default workspaces are used).

The change in this PR might be better because it reuses an existing method for cleaning up lock and plan but it might in some cases delete working directories that atlantis could have otherwise reused.

Especially when using non-default workspaces atlantis creates a copy of the repository for every project in a PR. With this PR a atlantis plan will cause atlantis to delete them all to re-clone them even if there was no code change.

In those cases performance might be affected negatively. This is why this change has been opened as alternative, I prefer the original solution in #1633

When using non-default workspaces, plans are stored
in pr-and-workspace-specific directories.
If a PR is subsequently updated it might happen that
some of the plans are no longer relevant with regards
to the latest changes.
This change ensures that plans are always deleted
when a generic plan is triggered either by autoplan
or by a "atlantis plan" command.
NB Plans are not cleaned up when specific projects are
planned explicitly with "atlantis plan -p/-d/-w".
@giuli007 giuli007 requested a review from a team as a code owner July 14, 2021 17:07
@giuli007 giuli007 force-pushed the delete_locks_and_workdirs_with_potentially_stale_previous_plans_which_fixes_1624 branch from 2a93ee0 to d01db03 Compare July 14, 2021 17:29
@giuli007 giuli007 force-pushed the delete_locks_and_workdirs_with_potentially_stale_previous_plans_which_fixes_1624 branch from d01db03 to 011fb1a Compare July 14, 2021 17:33
@chenrui333 chenrui333 changed the title Delete locks and workdirs with potentially stale previous plans which fixes 1624 fix: Delete locks and workdirs with potentially stale previous plans which fixes 1624 Nov 20, 2021
@ghost
Copy link

ghost commented Dec 29, 2021

Any progress on this? we are facing the same issue.

@srlightbody
Copy link

Is there anything I can do to help get eyes on this or anything? We're continuing to see this edge case occasionally, and it causes confusion for our devs and unintentional deploys.

@jamengual jamengual added the feature New functionality/enhancement label May 13, 2022
@jamengual
Copy link
Contributor

@srlightbody @giuli007 if any of you can contribute and continue the work, we can review it

@jamengual jamengual added the waiting-on-response Waiting for a response from the user label May 13, 2022
@yevhenvolchenko
Copy link

Hi, any progress?
Our teams need to be on their toes all the time, because of this

@jamengual jamengual merged commit 82ac706 into runatlantis:master Jun 11, 2022
jamengual added a commit that referenced this pull request Jun 13, 2022
jamengual added a commit that referenced this pull request Jun 29, 2022
krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
…which fixes 1624 (runatlantis#1704)

* Delete previous plans on autoplan or atlantis plan

When using non-default workspaces, plans are stored
in pr-and-workspace-specific directories.
If a PR is subsequently updated it might happen that
some of the plans are no longer relevant with regards
to the latest changes.
This change ensures that plans are always deleted
when a generic plan is triggered either by autoplan
or by a "atlantis plan" command.
NB Plans are not cleaned up when specific projects are
planned explicitly with "atlantis plan -p/-d/-w".

* Use DeleteLockCommand to delete locks and workdirs
containing previous plans

Co-authored-by: giuli007 <[email protected]>
krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
@nitrocode nitrocode added this to the v0.19.5 milestone Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement waiting-on-response Waiting for a response from the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apply picks up stale plans
5 participants