runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.81k stars 1.06k forks source link

unable to plan or apply in the PR #3296

Closed shettypriy closed 10 hours ago

shettypriy commented 1 year ago

Community Note


Overview of the Issue

I have deployed atlantis version 0.23.1 on AWS EKS cluster using helm with a custom domain, bitbucket as VCS and added ingress rule as below

ingress:
  enabled: true
  ingressClassName: alb
  annotations: 
      #kubernetes.io/ingress.class: alb
      alb.ingress.kubernetes.io/scheme: internet-facing
      alb.ingress.kubernetes.io/target-type: instance
      alb.ingress.kubernetes.io/healthcheck-path: /healthz
      alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
      alb.ingress.kubernetes.io/ssl-redirect: '443'
      alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
      alb.ingress.kubernetes.io/inbound-cidrs: 13.52.5.96/28, 13.236.8.224/28, 18.136.214.96/28, 18.184.99.224/28, 18.234.32.224/28, 18.246.31.224/28, 52.215.192.224/28, 104.192.137.240/28, 104.192.138.240/28, 104.192.140.240/28, 104.192.142.240/28, 104.192.143.240/28, 185.166.143.240/28, 185.166.142.240/28
  host: "atlantis.abc.com"

I raise a PR for creating a null resource and there is a autopaln happening as shown in the below logs

{"level":"info","ts":"2023-04-05T07:42:57.842Z","caller":"models/shell_command_runner.go:156","msg":"successfully ran \"terraform init\" in \"/atlantis-data/repos/test-terraform/atlantis-tf-repo/36/default\"","json":{"repo":"test-terraform/atlantis-tf-repo","pull":"36"}}
{"level":"debug","ts":"2023-04-05T07:42:57.842Z","caller":"models/shell_command_runner.go:93","msg":"starting \"terraform plan\" in \"/atlantis-data/repos/test-terraform/atlantis-tf-repo/36/default\"","json":{"repo":"test-terraform/atlantis-tf-repo","pull":"36"}}
{"level":"info","ts":"2023-04-05T07:43:00.241Z","caller":"models/shell_command_runner.go:156","msg":"successfully ran \"terraform plan\" in \"/atlantis-data/repos/test-terraform/atlantis-tf-repo/36/default\"","json":{"repo":"test-terraform/atlantis-tf-repo","pull":"36"}}
{"level":"info","ts":"2023-04-05T07:43:00.445Z","caller":"events/instrumented_project_command_runner.go:87","msg":"plan success. output available at: https://bitbucket.org/test-terraform/atlantis-tf-repo/pull-requests/36","json":{"repo":"test-terraform/atlantis-tf-repo","pull":"36"}}
{"level":"debug","ts":"2023-04-05T07:43:00.446Z","caller":"metrics/debug.go:52","msg":"timer","json":{"name":"atlantis.execution_time","value":4.826902569,"tags":{"base_repo":"test-terraform/atlantis-tf-repo","pr_number":"36","project":"","project_path":".","terraform_version":"","workspace":"default"},"type":"timer"}}
{"level":"debug","ts":"2023-04-05T07:43:00.746Z","caller":"events/db_updater.go:25","msg":"updating DB with pull results","json":{"repo":"test-terraform/atlantis-tf-repo","pull":"36"}}
{"level":"debug","ts":"2023-04-05T07:43:00.928Z","caller":"metrics/debug.go:52","msg":"timer","json":{"name":"atlantis.cmd.autoplan.execution_time","value":6.666953457,"tags":{},"type":"timer"}}
{"level":"debug","ts":"2023-04-05T07:43:01.442Z","caller":"metrics/debug.go:42","msg":"counter","json":{"name":"atlantis.execution_success","value":1,"tags":{"base_repo":"test-terraform/atlantis-tf-repo","pr_number":"36","project":"","project_path":".","terraform_version":"","workspace":"default"},"type":"counter"}}

However, when I run a apply using the command atlantis apply -d . for the above auto-plan , there is no apply happening. Also, if I run the plan again atlantis plan -d ., no plan is happening.

If I check the logs when I run plan or apply there is nothing in the logs and it shows the following

{"level":"debug","ts":"2023-03-27T20:36:38.678Z","caller":"metrics/debug.go:47","msg":"gauge","json":{"name":"atlantis.scheduled.runtime.memory.heap.inuse","value":7700480,"tags":{},"type":"gauge"}}
{"level":"debug","ts":"2023-03-27T20:36:38.678Z","caller":"metrics/debug.go:47","msg":"gauge","json":{"name":"atlantis.scheduled.runtime.memory.heap.released","value":3407872,"tags":{},"type":"gauge"}}
{"level":"debug","ts":"2023-03-27T20:36:38.678Z","caller":"metrics/debug.go:47","msg":"gauge","json":{"name":"atlantis.scheduled.runtime.memory.heap.objects","value":25129,"tags":{},"type":"gauge"}}
{"level":"debug","ts":"2023-03-27T20:36:38.678Z","caller":"metrics/debug.go:47","msg":"gauge","json":{"name":"atlantis.scheduled.runtime.memory.gc.sys","value":8901704,"tags":{},"type":"gauge"}}
{"level":"debug","ts":"2023-03-27T20:36:38.678Z","caller":"metrics/debug.go:47","msg":"gauge","json":{"name":"atlantis.scheduled.runtime.memory.gc.next","value":9011936,"tags":{},"type":"gauge"}}
{"level":"debug","ts":"2023-03-27T20:36:38.678Z","caller":"metrics/debug.go:47","msg":"gauge","json":{"name":"atlantis.scheduled.runtime.memory.gc.last","value":1679949308682745300,"tags":{},"type":"gauge"}}
{"level":"debug","ts":"2023-03-27T20:36:38.678Z","caller":"metrics/debug.go:47","msg":"gauge","json":{"name":"atlantis.scheduled.runtime.memory.gc.pause_total","value":11340204,"tags":{},"type":"gauge"}}
{"level":"debug","ts":"2023-03-27T20:36:38.678Z","caller":"metrics/debug.go:47","msg":"gauge","json":{"name":"atlantis.scheduled.runtime.memory.gc.count","value":206,"tags":{},"type":"gauge"}}
{"level":"debug","ts":"2023-03-27T20:36:45.445Z","caller":"server/middleware.go:45","msg":"GET /healthz – from xxxxxxx:44626","json":{}}
{"level":"debug","ts":"2023-03-27T20:36:45.445Z","caller":"server/middleware.go:72","msg":"GET /healthz – respond HTTP 200","json":{}}
{"level":"debug","ts":"2023-03-27T20:36:45.446Z","caller":"server/middleware.go:45","msg":"GET /healthz – from xxxxxxxx:44624","json":{}}
{"level":"debug","ts":"2023-03-27T20:36:45.446Z","caller":"server/middleware.go:72","msg":"GET /healthz – respond HTTP 200","json":{}}

Environment details

Additional Context

jamengual commented 1 year ago

Please update Atlantis to the latest since 0.23.1 has a bug. can you show us your atlantis.yaml and repos.yaml?

shettypriy commented 1 year ago

I do not have an atlantis.yml file since I am using the default settings and following is my /etc/atlantis/repos.yml file

repoConfig: |
 ---
 repos:
 - id: bitbucket.org/xxxxxxx/atlantis-repo
   apply_requirements: []
   workflow: default
   allowed_overrides: []
   allow_custom_workflows: false
 workflows:
   default:
     plan:
       steps: 
        - run: "terraform init"
        - run: "terraform plan"
     apply:
       steps:    
        - run: "terraform apply"
jamengual commented 1 year ago

do you see the plan comment after autoplan run?

jamengual commented 1 year ago

if you run atlantis apply anything happen?

shettypriy commented 1 year ago

Yes, I do see the plan comment after autoplan run. But when I type atlantis apply nothing happens. Following is what I get in the bitbucket /events request

Event Details   Actions
pullrequest:comment_created 34 seconds ago 403 View details
pullrequest:comment_created 1 minute ago 403 View details
pullrequest:updated 1 minute ago 200 View details
jamengual commented 1 year ago

what permissions you have in your webhook? can you try giving more perms to tests and see?

shettypriy commented 1 year ago

I initially gave the permissions mentioned here https://www.runatlantis.io/docs/configuring-webhooks.html#bitbucket-cloud-bitbucket-org . Since it did not work, I checked all the boxes for the webhook. That too did not work.