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

v0.22.0+: approve_policies: results in error "Pull request must be mergeable before running apply." #2974

Closed
pseudomorph opened this issue Jan 12, 2023 · 14 comments · Fixed by #2977
Labels
bug Something isn't working regression Bug introduced in a new version
Milestone

Comments

@pseudomorph
Copy link
Contributor

pseudomorph commented Jan 12, 2023

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

Running atlantis approve_policies results in failed apply status messages.

Reproduction Steps

Run no-op plan on stack, then approve policies.

Logs

{
  "level": "error",
  "ts": "2023-01-12T18:12:38.776Z",
  "caller": "events/instrumented_project_command_runner.go:78",
  "msg": "Failure running approve policies operation: Pull request must be mergeable before running apply.",
  "json": {
    "repo": "****",
    "pull": "53"
  },
  "stacktrace": "see below"
}

error from stacktrace

github.com/runatlantis/atlantis/server/events.RunAndEmitStats
	github.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:78
github.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).ApprovePolicies
	github.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:49
github.com/runatlantis/atlantis/server/events.(*ApprovePoliciesCommandRunner).buildApprovePolicyCommandResults
	github.com/runatlantis/atlantis/server/events/approve_policies_command_runner.go:102
github.com/runatlantis/atlantis/server/events.(*ApprovePoliciesCommandRunner).Run
	github.com/runatlantis/atlantis/server/events/approve_policies_command_runner.go:73
github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand
	github.com/runatlantis/atlantis/server/events/command_runner.go:296"}

Environment details

  • Atlantis version: v0.22.2
  • Atlantis flags: atlantis server --config /app/files/config.yaml --repo-config /app/files/repositories.yaml --enable-policy-checks

Atlantis server-side config file:

atlantis-url: ****
allow-draft-prs: true
allow-fork-prs: true
checkout-strategy: merge
automerge: true
gh-user: ****
log-level: debug
port: 3000
repo-whitelist: ****
hide-prev-plan-comments: true

Additional Context

The policy checks work as expected, but something seems to be triggering an apply in code. None of our default or custom workflows are specifying anything for apply workflow. I cannot find any connection which would implicate this behavior between workflow steps or command running in code. I'm a bit stumped.

@pseudomorph pseudomorph added the bug Something isn't working label Jan 12, 2023
@nitrocode
Copy link
Member

@pseudomorph

I wonder if this is a regression. Did you see this issue in previous versions? Is this issue present in v0.22.1 ?

@nitrocode nitrocode changed the title Running "atlantis approve_policies" results in "failed apply" status warnings. v0.22.2: approve_policies: results in error "Pull request must be mergeable before running apply." Jan 12, 2023
@pseudomorph
Copy link
Contributor Author

Looks like this is the case. I lowered version down to v0.20.0 and the problem went away.

@nitrocode
Copy link
Member

Could you try 0.22.1 and keep going lower until it's resolved? I'm curious where this regression came from.

@nitrocode nitrocode added the regression Bug introduced in a new version label Jan 12, 2023
@nitrocode
Copy link
Member

Here are some of the approve_policies PRs closed recently https://github.com/runatlantis/atlantis/pulls?q=is%3Apr+approve_policies+is%3Aclosed

@pseudomorph
Copy link
Contributor Author

Worked my way up from v0.21.0. It appears to show up when I run with v0.22.0

@nitrocode nitrocode changed the title v0.22.2: approve_policies: results in error "Pull request must be mergeable before running apply." v0.22.0+: approve_policies: results in error "Pull request must be mergeable before running apply." Jan 12, 2023
@nitrocode
Copy link
Member

nitrocode commented Jan 12, 2023

Hmm and then if you have more time, to further see if we can identify the correct pr, could you check the following pre releases?

this are the pre-releaes between v0.21.0 (nov 28) and v0.22.0 (jan 11)

Thank you

@nitrocode
Copy link
Member

nitrocode commented Jan 12, 2023

@krrrr38 is it possible that this issue resulted after merging #2939 or #2877. I'm having trouble tracking down the exact change.

if result.Failure != "" {
executionFailure.Inc(1)
logger.Err("Failure running %s operation: %s", commandName, result.Failure)
return result
}

@nitrocode
Copy link
Member

@pseudomorph is your PR mergeable? Were you able to run approve policies without needing your pr to be mergesble before?

@krrrr38
Copy link
Contributor

krrrr38 commented Jan 12, 2023

@nitrocode
Copy link
Member

Ah thank you @krrrr38 so then this regression came from pr #2767 cc @Fabianoshz

@nitrocode nitrocode added this to the 0.22.3 milestone Jan 12, 2023
@pseudomorph
Copy link
Contributor Author

Wow. Awesome work and collaboration here y'all!

@Fabianoshz
Copy link
Contributor

Fabianoshz commented Jan 12, 2023

Hi guys, that seems to be a quick fix, give me a minute and I will open a PR.

@nitrocode
Copy link
Member

it looks like @Fabianoshz fixed this issue very quickly. Nice job!

@pseudomorph once the new image is uploaded, could you try the atlantis image dev tag? Thats the tag that's updated whenever a new PR is merged.

@pseudomorph
Copy link
Contributor Author

I tested against the built image and confirmed the issue is gone.

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

Successfully merging a pull request may close this issue.

4 participants