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

pre-workflow hooks are not re-run when a PR is open + closed #1700

Closed
david-heward-unmind opened this issue Jul 13, 2021 · 3 comments
Closed
Labels
waiting-on-response Waiting for a response from the user

Comments

@david-heward-unmind
Copy link
Contributor

david-heward-unmind commented Jul 13, 2021

I noticed that I managed to get my Atlantis rather stuck after modifying the pre-workflow hooks custom Atlantis repo config generation to flip between creating-workspace and default workspace. After re-opening the PR and running the atlantis plan the generate config step (pre-workflow-step) is not re-run. Thus due to the --parallel flag being present the contention for the default workspace remains, and breaks things.

I also notice that the PR is not presently checked out at its regular location on disk /home/atlantis/.atlantis/repos.

Why could this be? And is there anything more that can be done, beyond recreating the PR.

@nishkrishnan
Copy link
Contributor

hmm so is the underlying issue here that --parallel is breaking pre-workflow hooks because of this? #1618

@nishkrishnan nishkrishnan added the waiting-on-response Waiting for a response from the user label Jul 19, 2021
@github-actions github-actions bot added the Stale label Aug 19, 2021
@david-heward-unmind
Copy link
Contributor Author

david-heward-unmind commented Aug 24, 2021

hmm so is the underlying issue here that --parallel is breaking pre-workflow hooks because of this? #1618

It is not. Slightly different problem here, let me explain a little more.

TLDR; pre-workflow hook is exec'd only on initial checkout, so auto config is not regenerated as the PR evolves, symptoms are: build output for projects no longer in PR, double runs if utilising run in custom step, or forced to open+close a PR to refresh dir structure.

Let's say we a single VCS repo & we utilise Atlantis pre-workflow hook to generate config for atlantis dynamically.

During pre-workflow-hook auto-generation step we instruct the auto generator to use both parallel and dir separation per project found.

- default
- project_1
- project_2
- project_3_etc

Where each dir has a full checkout of source code (presumably cp from default rather than individual checkouts from git).

This creates 2 distinct problems for us;

1). pre-workflow-hook infact is only exec'd once. not as the docs describe. pre-workflow hook would suggest it is run before every workflow execution. Could you provide some clarity on this? Problematic because, if during a PR review the author decides/is instructed to make additions/deletions to the PR these files are never correctly picked up in the auto-config generation as it only executes on PR open. despite suggesting (by name) that it runs before every workflow exec.

We could of course utilise the custom run cmd in our custom workflow, if the task at hand was not to generate an atlantis config (chicken & egg, or at least known failures before re-running for success).

2). Secondly we've found that if a PR is generated lets say with 10 projects, each of which are represented in the config, then the PR author removes a project, Atlantis does not remove the projects it can no longer find. Meaning we get build output for things that are not even part of the PR or are removed in the PR now. This can be manually overcome by simply open+close the PR which essentially kills the project dir structure altogether before re-checking out from VCS and re-running the pre-workflow hook.

Does this make a bit more sense?

Suggestions: ensure or introduce a hook that is truly exec'd on each project workflow init, or have the default pre-workflow-hook be bumped manually, via some mechanism perhaps atlantis init or re-init comments.

@giuli007
Copy link
Contributor

giuli007 commented Jun 27, 2022

Just worth a mention that I think the 2nd problem described is the same as #1624 for which my fix (#1633 which we run on a custom atlantis build) was to automatically delete plans with subsequent PR updates/atlantis plan commands, so they are not "picked up" but apply commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-response Waiting for a response from the user
Projects
None yet
Development

No branches or pull requests

3 participants