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

Atlantis runs apply only on the last planned directory in the same PR #2325

Open
enarmontas opened this issue Jun 16, 2022 · 20 comments
Open
Labels
bug Something isn't working never-stale waiting-on-response Waiting for a response from the user

Comments

@enarmontas
Copy link

enarmontas commented Jun 16, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

Atlantis runs apply only on the last planned directory in the same PR.

For example I have 3 projects planned in my PR:

  1. dir: test/ec2-instance/memcached workspace: test_ec2-instance_memcached
  2. dir: test/ec2-instance/redis workspace: test_ec2-instance_redis
  3. dir: test/ec2-instance/consul workspace: test_ec2-instance_consul

Let's say atlantis plan succeeds for projects 1 and 3, but fails for the 2nd one due to a timeout issue.
In that case I want to replan it with a separate Atlantis command:

atlantis plan -d test/ec2-instance/redis -w test_ec2-instance_redis

Now the GitHub PR shows succesfull plan status checks for all directories, so we can proceed with an apply command: atlantis apply.

The issue is that Atlantis ignores the rest of the directories and will only attempt to apply the last planned project:
2. dir: test/ec2-instance/redis workspace: test_ec2-instance_redis

In addition to that, if I have ATLANTIS_HIDE_PREV_PLAN_COMMENTS variable set to true, Atlantis also hides all my previous plans, including those that ran only once.

I would like to be able to apply all my projects at once, without considering the plan order.

Environment details

Atlantis version: 0.19.4

Atlantis server-side config file:

repos:
  - id: /github.com/org/.*/
    workflow: terragrunt
    apply_requirements:
      - approved
      - mergeable
    allowed_overrides:
      - workflow
    allowed_workflows:
      - terragrunt
    pre_workflow_hooks:
      - run: >
          terragrunt-atlantis-config generate --output atlantis.yaml --autoplan
          --workflow terragrunt --create-workspace --parallel
workflows:
  terragrunt:
    plan:
      steps:
        - env:
            name: TERRAGRUNT_TFPATH
            command: 'echo "terraform${ATLANTIS_TERRAFORM_VERSION}"'
        - env:
            name: TF_CLI_ARGS
            value: '-no-color'
        - env:
            name: TF_INPUT
            value: '0'
        - run: terragrunt run-all validate-inputs --terragrunt-log-level=error
        - run: terragrunt run-all plan -out "$PLANFILE"
    apply:
      steps:
        - env:
            name: TERRAGRUNT_TFPATH
            command: 'echo "terraform${ATLANTIS_TERRAFORM_VERSION}"'
        - env:
            name: TF_CLI_ARGS
            value: '-no-color'
        - env:
            name: TF_INPUT
            value: '0'
        - run: terragrunt run-all apply "$PLANFILE"
@enarmontas enarmontas added the bug Something isn't working label Jun 16, 2022
@dschunack
Copy link

dschunack commented Jun 17, 2022

Hi,

we have the same problem but with projects and I wanted to open also a issue today for this.
3 of 35 failed, we triggered a plan on each of the 3 failed projects. Afterwards we run a atlantis apply to apply all.
But, only the 3 projects are applied and not all. Hope you can fix this.

We use atlantis 0.19.5 with terraform 1.1.7. If you need further information, please let me know.

Our atlantis.yaml (short)

version: 3
automerge: true
parallel_plan: false
parallel_apply: false
projects:
- name: project-1
  dir: cld/accounts/1/project
  workspace: default
  autoplan:
    enabled: true
    when_modified:
      - "**/*.tf"
      - "**/*.yaml"
      - "**/*.secret"
  apply_requirements: [mergeable]
  workflow: git-crypt
- name: project-2
  dir: cld/accounts/2/project
  workspace: default
  autoplan:
    enabled: true
    when_modified:
      - "**/*.tf"
      - "**/*.yaml"
      - "**/*.secret"
  apply_requirements: [mergeable, approved]
  workflow: git-crypt
- name: project-3
  dir: cld/accounts/3/project
  workspace: default
  autoplan:
    enabled: true
    when_modified:
      - "**/*.tf"
      - "**/*.yaml"
      - "**/*.secret"
  apply_requirements: [mergeable]
  workflow: git-crypt
- name: project-4
  dir: cld/accounts/4/project
  workspace: default
  autoplan:
    enabled: true
    when_modified:
      - "**/*.tf"
      - "**/*.yaml"
      - "**/*.secret"
  apply_requirements: [mergeable, approved]
  workflow: git-crypt
workflows:
  git-crypt:
    plan:
      steps:
      - env:
          name: ACCOUNT_ID
          command: echo $REPO_REL_DIR |awk -F/ '{print $3}'
      - env: 
          name: AWS_PROFILE
          command: echo "${ACCOUNT_ID}"
      - env:
          name: AWS_SHARED_CREDENTIALS_FILE
          command: echo "${HOME}/.aws/credentials"
      - init:
          extra_args: ["-upgrade=false"]
      - run: terraform refresh 1>/dev/null
      - run: terraform plan -input=false -refresh=false -no-color -out $PLANFILE
    apply:
      steps:
      - env:
          name: ACCOUNT_ID
          command: echo $REPO_REL_DIR |awk -F/ '{print $3}'
      - env: 
          name: AWS_PROFILE
          command: echo "${ACCOUNT_ID}"
      - env:
          name: AWS_SHARED_CREDENTIALS_FILE
          command: echo "${HOME}/.aws/credentials"
      - init:
          extra_args: ["-upgrade=false"]
      - apply

@jamengual jamengual added the waiting-on-response Waiting for a response from the user label Aug 26, 2022
@github-actions github-actions bot added the Stale label Sep 26, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2022
@dschunack
Copy link

Problem still exists.

@jamengual
Copy link
Contributor

withe the latest version too?

@jamengual jamengual reopened this Oct 3, 2022
@jamengual jamengual removed the Stale label Oct 3, 2022
@dschunack
Copy link

Yes, with v0.19.8

@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

@github-actions github-actions bot added the Stale label Mar 12, 2023
@dschunack
Copy link

not solved yet

@nitrocode nitrocode removed the Stale label Mar 13, 2023
@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

@github-actions github-actions bot added the Stale label Apr 14, 2023
@nitrocode
Copy link
Member

I have noticed this too and it makes me not want to use the -d command.

If a plan of a project fails while other projects succeed, you should be able to plan a directory again without losing all previous plans

Perhaps we need a new flag

atlantis plan -d test/ec2-instance/redis -w test_ec2-instance_redis --keep-other-plans

Thoughts?

@nitrocode nitrocode removed the Stale label Apr 18, 2023
@jamengual
Copy link
Contributor

I do not use dir ever but I do use projects -p and I do not have this problem when using projects I believe.
the plan should be discarded if there are changes on the files ( that belong to the dir/project) or after a successful applybut only for that specific project/dir

@nitrocode
Copy link
Member

interesting. perhaps the behavior for -p is different for -d and -w ? If so, it sounds like a bug. They should all be consistent.

@jamengual are you saying that if you proposed a PR and it ran 3 projects, if one of them failed, and you reran it using -p, it succeeded, and then you did an atlantis apply, that apply would affect all 3 projects or only the most recent -p project ?

@jamengual
Copy link
Contributor

if you run -p for each project or if they get run by one invocation of atlantis plan without passing -p?

@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

@github-actions github-actions bot added the Stale label May 20, 2023
@dschunack
Copy link

Still open

@jamengual jamengual removed the Stale label May 20, 2023
@scott-standard
Copy link

Having this issue as well. Seeing it with -p or -d and I'm on atlantis versionv0.24.1

@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

@github-actions github-actions bot added the Stale label Jul 16, 2023
@enarmontas
Copy link
Author

This is still happening with latest Atlantis version.

@github-actions github-actions bot removed the Stale label Jul 18, 2023
@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

@github-actions github-actions bot added the Stale label Aug 19, 2023
@enarmontas
Copy link
Author

Still relevant

@jamengual jamengual removed the Stale label Aug 22, 2023
@github-actions
Copy link

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'

@github-actions github-actions bot added the Stale label Sep 22, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2023
@nitrocode nitrocode reopened this Oct 23, 2023
@darrylweaver
Copy link

Still an issue in atlantis 0.28.3 using '-d'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working never-stale waiting-on-response Waiting for a response from the user
Projects
None yet
Development

No branches or pull requests

6 participants