runatlantis / helm-charts

Atlantis Helm Chart
Apache License 2.0
114 stars 184 forks source link

Branch not deleting Automatically after apply is success and PR is merged. #415

Closed ankitmahajan-appfire closed 23 hours ago

ankitmahajan-appfire commented 2 months ago

Hi team,

I have deployed the atlantis to test tf automation. Below is my config.

Server Side Repo config: repoConfig: |

repos:

Repo Level atlantis.yaml Config version: 3 autodiscover: mode: auto delete_source_branch_on_merge: true automerge: true parallel_plan: true parallel_apply: true projects:

In both the config, i have given delete_source_branch_on_merge: true to delete the branch after everything is executed. However, same is not happening. Screenshot below.

image

I have also enabled the debug logs, and below are the same for above event.

{"level":"debug","ts":"2024-08-26T13:57:03.777Z","caller":"vcs/github_client.go:180","msg":"Creating comment on GitHub pull request 5","json":{"gh-request-id":"X-Github-Delivery=125b3dc0-9925-d1e5816912c7"}} {"level":"debug","ts":"2024-08-26T13:57:03.935Z","caller":"server/middleware.go:45","msg":"POST /events – from 10.0.4.38:47060","json":{}} {"level":"debug","ts":"2024-08-26T13:57:03.935Z","caller":"events/events_controller.go:119","msg":"handling GitHub post","json":{}} {"level":"debug","ts":"2024-08-26T13:57:03.935Z","caller":"events/events_controller.go:185","msg":"request valid","json":{"gh-request-id":"X-Github-Delivery=12aa3b28-9b85-497723f9c70a"}} {"level":"debug","ts":"2024-08-26T13:57:03.936Z","caller":"server/middleware.go:72","msg":"POST /events – respond HTTP 200","json":{}}

{"level":"debug","ts":"2024-08-26T13:57:04.250Z","caller":"vcs/github_client.go:198","msg":"POST /repos/atlantis-poc/issues/5/comments returned: 201","json":{"gh-request-id":"X-Github-Delivery=125b3dc0-9925-d1e5816912c7"}} {"level":"debug","ts":"2024-08-26T13:57:04.250Z","caller":"metrics/debug.go:52","msg":"timer","json":{"name":"atlantis.github.create_comment.execution_time","value":0.472759649,"tags":{"base_repo":"atlantis-poc","pr_number":"5"},"type":"timer"}} {"level":"debug","ts":"2024-08-26T13:57:04.250Z","caller":"metrics/debug.go:52","msg":"timer","json":{"name":"atlantis.pullclosed_cleanup.execution_time","value":0.47882662,"tags":{},"type":"timer"}} {"level":"info","ts":"2024-08-26T13:57:04.250Z","caller":"events/events_controller.go:579","msg":"deleted locks and workspace for repo atlantis-poc, pull 5","json":{"gh-request-id":"X-Github-Delivery=125b3dc0-9925-d1e5816912c7"}} {"level":"debug","ts":"2024-08-26T13:57:04.250Z","caller":"server/middleware.go:72","msg":"POST /events – respond HTTP 200","json":{}}

{"level":"debug","ts":"2024-08-26T13:57:04.487Z","caller":"metrics/debug.go:42","msg":"counter","json":{"name":"atlantis.pullclosed_cleanup.execution_success","value":1,"tags":{},"type":"counter"}} {"level":"debug","ts":"2024-08-26T13:57:04.487Z","caller":"metrics/debug.go:42","msg":"counter","json":{"name":"atlantis.github_event.pr_closed.success_200","value":1,"tags":{"base_repo":"atlantis-poc","pr_number":"5"},"type":"counter"}} {"level":"debug","ts":"2024-08-26T13:57:04.487Z","caller":"metrics/debug.go:42","msg":"counter","json":{"name":"atlantis.github_event.success_200","value":1,"tags":{},"type":"counter"}} {"level":"debug","ts":"2024-08-26T13:57:04.487Z","caller":"metrics/debug.go:42","msg":"counter","json":{"name":"atlantis.github.create_comment.execution_success","value":1,"tags":{"base_repo":"atlantis-poc","pr_number":"5"},"type":"counter"}}

{"level":"debug","ts":"2024-08-26T13:57:05.714Z","caller":"server/middleware.go:45","msg":"POST /events – from 10.0.4.38:47060","json":{}} {"level":"debug","ts":"2024-08-26T13:57:05.715Z","caller":"events/events_controller.go:119","msg":"handling GitHub post","json":{}} {"level":"debug","ts":"2024-08-26T13:57:05.718Z","caller":"events/events_controller.go:185","msg":"request valid","json":{"gh-request-id":"X-Github-Delivery=13884c10-9614-b9178d616468"}} {"level":"debug","ts":"2024-08-26T13:57:05.719Z","caller":"server/middleware.go:72","msg":"POST /events – respond HTTP 200","json":{}} {"level":"debug","ts":"2024-08-26T13:57:06.487Z","caller":"metrics/debug.go:42","msg":"counter","json":{"name":"atlantis.github_event.comment_created.success_200","value":1,"tags":{"base_repo":"atlantis-poc","pr_number":"5"},"type":"counter"}}

Deployed with helm chart version as

appVersion: v0.28.5 version: 5.4.5

Could you please check and help here in fixing this issue?

GMartinez-Sisti commented 2 months ago

Hi, this is a GitHub configuration: please check https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-the-automatic-deletion-of-branches.

ankitmahajan-appfire commented 2 months ago

Hi,

That we already know. I am specificly asking for this config "delete_source_branch_on_merge: true". If we need to handle that by git config, then what is the use of this in server and repo config?

GMartinez-Sisti commented 2 months ago

This configuration exists for all VCS type: Github, Azure, Gitlab, etc. Looks like it's just being ignored in your configuration.

Are you using a GitHub user or a GitHub app (docs)?

ankitmahajan-appfire commented 2 months ago

I am using GitHub user. Created a PAT token for access and provided that in secrets.

GMartinez-Sisti commented 2 months ago

My best guess is that Atlantis is not getting the webhook for the merge event. Can you confirm the events you have configured (docs)?

ankitmahajan-appfire commented 2 months ago

In the configured the webhook as per the documentation and select 4 checkboxes as mentioned.

image

Below are the webhooks that are getting triggerred

image

I don't see any event for merge

GMartinez-Sisti commented 2 months ago

The most strange part is that Atlantis log doesn't show any event or failure for that event. We might have a bug or something is missing.

@jamengual can you move this issue into https://github.com/runatlantis/atlantis pls?

ankitmahajan-appfire commented 2 months ago

Thanks @GMartinez-Sisti for considering. @jamengual pls take this up and release the fix

GMartinez-Sisti commented 2 months ago

pls take this up and release the fix

@ankitmahajan-appfire not quite like this 😅 first we need to see if it's actually a bug or if someone is able to use it correctly. Then since this an open source project someone will need to volunteer to pick it up. But at least it's a start 😃

ankitmahajan-appfire commented 2 months ago

Sure @GMartinez-Sisti . Thanks

github-actions[bot] commented 1 month ago

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.'