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

Apply fails when there is no change in dependent module #4982

Open
pavelpulec opened this issue Oct 4, 2024 · 2 comments
Open

Apply fails when there is no change in dependent module #4982

pavelpulec opened this issue Oct 4, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@pavelpulec
Copy link

pavelpulec commented Oct 4, 2024

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

The application of changes fails when there is a dependency between 2 modules, and the dependent one doesn't have any change. A plan runs fine, it shows no changes. But then atlantis apply fails with Apply Failed: Can't apply your project unless you apply its dependencies:.

The wrong behavior is clear from Atlantis comments:

1st comment

Notice the plans ran for 2 projects but changes are in the first one only.

Ran Plan for 2 projects:

project: project1 dir: project1_dir workspace: default
project: project2 dir: project2_dir workspace: default

1. project: project1 dir: project1_dir workspace: default
Show Output
Plan: 0 to add, 1 to change, 0 to destroy.

2nd comment

atlantis apply

3rd comment

Changes are applied in the first project, that's correct. But for some reason it wants to try to apply changes in the second project even when there is no change from the plan.

Also it's strange that it can't apply changes in the 2nd project because the changes in the 1st project hasn't been applied. But as it can be seen in the output, the changes in the first project were applied.

Ran Apply for 2 projects:

project: project1 dir: project1_dir workspace: default
project: project2 dir: project2_dir workspace: default

1. project: project1 dir: project1_dir workspace: default
resource.example: Modifying... [id=123]
resource.example: Still modifying... [id=123, 10s elapsed]
resource.example: Modifications complete after 12s [id=123]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Outputs:
service_id = "123"


2. project: project2 dir: project2_dir workspace: default
Apply Failed: Can't apply your project unless you apply its dependencies: [project1]

Reproduction Steps

Logs

Logs
{"level":"error","ts":"2024-10-05T23:11:48.884+0200","caller":"events/instrumented_project_command_runner.go:84","msg":"Failure running apply operation: Can't apply your project unless you apply its dependencies: [project1]","json":{"repo":"<org>/<repo>","pull":"1207"},"stacktrace":"github.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\t/tmp/atlantis/server/events/instrumented_project_command_runner.go:84\ngit.luolix.top/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).Apply\n\t/atlantis/server/events/instrumented_project_command_runner.go:46\ngit.luolix.top/runatlantis/atlantis/server/events.runProjectCmdsParallel.func1\n\t/atlantis/server/events/project_command_pool_executor.go:29"}

Environment details

Additional Context

At the end of this section in docs is mentioned the Apply Failed: Can't apply your project unless you apply its dependencies: error but it's not clear under what circumstances the error is triggered.

I would expect that if there is a change for the first project only, then atlantis apply applies changes in this project only and doesn't try to apply them in a dependent project with no change.

@pavelpulec pavelpulec added the bug Something isn't working label Oct 4, 2024
Copy link

dosubot bot commented Oct 4, 2024

Hello @pavelpulec! I'm here to help you with any bugs, questions, or contributions you have. Let's work together to solve the issue you're facing.

A similar issue has been discussed where atlantis apply fails with the error "Can't apply your project unless you apply its dependencies" even when there are no changes in a dependent module. This behavior occurs because Atlantis requires all dependencies to be in an "applied" state or have no changes to apply before proceeding with the apply operation [1].

The logic behind this is implemented in the ValidateProjectDependencies method, which checks if all dependencies have been applied or have no changes planned. If any dependency is not in the AppliedPlanStatus or PlannedNoChangesPlanStatus, the apply will fail with the mentioned error [2].

There is no configuration option in Atlantis to ignore dependencies with no changes during the apply process, as per the available information [1].

To continue talking to Dosu, mention @dosu.

@pavelpulec
Copy link
Author

pavelpulec commented Oct 5, 2024

The logic behind this is implemented in the ValidateProjectDependencies method, which checks if all dependencies have been applied or have no changes planned.

That's exactly the issue I want to raise. There are no changes planned but the application fails anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant