Pluralith / actions

A collection of GitHub Actions to run Pluralith in CI and automate infrastructure documentation generation
Mozilla Public License 2.0
26 stars 3 forks source link

I got failed with message "posting run for PR comment failed" in "run" step #10

Closed heumsi closed 2 years ago

heumsi commented 2 years ago

Hello. Firstly, thank for making good tools.

I used this github action in my repository. but I got some troubles when actions executed.

This is my github actions yaml file.

https://github.com/heumsi/hands-on-terraform-with-gcp/blob/test6/.github/workflows/terraform-pr.yaml

And this is error I got when actions executed.

https://github.com/heumsi/hands-on-terraform-with-gcp/runs/8182992051?check_suite_focus=true#step:7:375

image
Run pluralith run --title=\#7 --version= --export-pdf=false --show-changes=true --show-drift=true --show-costs=true --cost-mode=delta --cost-period=month
⠿ Initiating Run ⇢ Posting To Pluralith Dashboard
 → Branch detected: test6

→ Verify
  ✔ API key is valid, you are authenticated!
  ✔ Project ID is valid!

→ Plan
  ✔ Execution Plan Generated
  ✔ Secrets Stripped
  ✔ Costs Calculated

→ Export
  ✔ Diagram Generated
  ✘ Posting Run To Pluralith Dashboard Failed
posting run for PR comment failed -> HandleCIRun: request failed -> LogRun: &***400 Bad Request 400 HTTP/2.0 2 0 map[Access-Control-Allow-Origin:[*] Content-Length:[54] Content-Type:[application/json; charset=utf-8] Date:[Mon, 05 Sep 2022 06:29:45 GMT] Etag:[W/"36-Sbx30uwj25sHt5XLThLAnENn3l8"] Server:[Google Frontend] X-Cloud-Trace-Context:[2636e5186bfcbe8f71659db7ac794f92] X-Powered-By:[Express]] ***0xc0001ae600*** 54 [] false false map[] 0xc00019fc00 0xc0001aa210***

Could you help me what is the problem?

heumsi commented 2 years ago

I found codes about cli run (https://github.com/Pluralith/pluralith-cli/blob/1cce5fe9eef84465d412ca805abd7e6648892b57/app/pkg/graph/HandleCIRun.go#L12)

and checked pluralith.cache.json

$ cat pluralith.cache.json

{
  "graph": {
    "resources": [
      {
        "id": 1,
        "provider": "google",
        "address": "google_service_account.gce",
        "module": "iam",
        "name": "gce",
        "resourceType": "google_service_account",
        "resourceCategory": "normal",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "iam.google_service_account.gce",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": false,
        "frameColor": [],
        "graphingData": {
          "height": 3,
          "width": 15,
          "posX": 4,
          "posY": 10
        },
        "costs": {}
      },
      {
        "id": 2,
        "provider": "google",
        "address": "google_compute_network.hotwg_prod_1",
        "module": "network",
        "name": "hotwg_prod_1",
        "resourceType": "google_compute_network",
        "resourceCategory": "nested",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "network.google_compute_network.hotwg_prod_1",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": false,
        "frameColor": [],
        "graphingData": {
          "height": 19,
          "width": 53,
          "posX": 20,
          "posY": 4
        },
        "costs": {}
      },
      {
        "id": 3,
        "provider": "google",
        "address": "google_storage_bucket.hotwg_asne3_tfstate_prod_1",
        "module": "storage",
        "name": "hotwg_asne3_tfstate_prod_1",
        "resourceType": "google_storage_bucket",
        "resourceCategory": "normal",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "storage.google_storage_bucket.hotwg_asne3_tfstate_prod_1",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": false,
        "frameColor": [],
        "graphingData": {
          "height": 3,
          "width": 15,
          "posX": 4,
          "posY": 14
        },
        "costs": {}
      },
      {
        "id": 4,
        "provider": "google",
        "address": "google_compute_firewall.hotwg_prod_1_allow_http",
        "module": "network",
        "name": "hotwg_prod_1_allow_http",
        "resourceType": "google_compute_firewall",
        "resourceCategory": "normal",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "network.google_compute_firewall.hotwg_prod_1_allow_http",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": false,
        "frameColor": [],
        "graphingData": {
          "height": 3,
          "width": 15,
          "posX": 21,
          "posY": 11
        },
        "costs": {}
      },
      {
        "id": 5,
        "provider": "google",
        "module": "network",
        "name": "asia-northeast3",
        "resourceType": "google_compute_region",
        "resourceCategory": "nested",
        "before": {},
        "after": {},
        "resourceId": "network.google_compute_region.asia-northeast3",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": true,
        "emulationParentId": "network.google_compute_network.hotwg_prod_1",
        "frameColor": [],
        "graphingData": {
          "height": 15,
          "width": 35,
          "posX": 37,
          "posY": 7
        }
      },
      {
        "id": 6,
        "provider": "google",
        "address": "google_compute_firewall.hotwg_prod_1_allow_ssh",
        "module": "network",
        "name": "hotwg_prod_1_allow_ssh",
        "resourceType": "google_compute_firewall",
        "resourceCategory": "normal",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "network.google_compute_firewall.hotwg_prod_1_allow_ssh",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": false,
        "frameColor": [],
        "graphingData": {
          "height": 3,
          "width": 15,
          "posX": 21,
          "posY": 15
        },
        "costs": {}
      },
      {
        "id": 7,
        "provider": "google",
        "address": "google_compute_address.hotwg_asne3_prod_1",
        "module": "network",
        "name": "hotwg_asne3_prod_1",
        "resourceType": "google_compute_address",
        "resourceCategory": "normal",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "network.google_compute_address.hotwg_asne3_prod_1",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": false,
        "frameColor": [],
        "graphingData": {
          "height": 3,
          "width": 15,
          "posX": 38,
          "posY": 14
        },
        "costs": {
          "totalHourly": 0.01,
          "totalMonthly": 7.3
        }
      },
      {
        "id": 8,
        "provider": "google",
        "address": "google_compute_subnetwork.hotwg_asne3_prod_1",
        "module": "network",
        "name": "hotwg_asne3_prod_1",
        "resourceType": "google_compute_subnetwork",
        "resourceCategory": "nested",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "network.google_compute_subnetwork.hotwg_asne3_prod_1",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": false,
        "frameColor": [
          "#9B7DC7"
        ],
        "graphingData": {
          "height": 11,
          "width": 17,
          "posX": 54,
          "posY": 10
        },
        "costs": {}
      },
      {
        "id": 9,
        "provider": "google",
        "address": "google_compute_instance.hotwg_asne3_prod_1",
        "module": "compute",
        "name": "hotwg_asne3_prod_1",
        "resourceType": "google_compute_instance",
        "resourceCategory": "normal",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "compute.google_compute_instance.hotwg_asne3_prod_1",
        "stage": "plan",
        "changeActions": [
          "no-op"
        ],
        "emulated": false,
        "frameColor": [],
        "graphingData": {
          "height": 3,
          "width": 15,
          "posX": 55,
          "posY": 13
        },
        "costs": {
          "totalHourly": 0.043695188767123284,
          "totalMonthly": 31.8974878
        }
      },
      {
        "id": 10,
        "provider": "google",
        "address": "google_compute_instance.hotwg_asne3_prod_2",
        "module": "compute",
        "name": "hotwg_asne3_prod_2",
        "resourceType": "google_compute_instance",
        "resourceCategory": "normal",
        "before": {},
        "after": {},
        "drift": false,
        "resourceId": "compute.google_compute_instance.hotwg_asne3_prod_2",
        "stage": "plan",
        "changeActions": [
          "create"
        ],
        "emulated": false,
        "frameColor": [],
        "graphingData": {
          "height": 3,
          "width": 15,
          "posX": 55,
          "posY": 17
        },
        "costs": {
          "totalHourly": 0.043695188767123284,
          "totalMonthly": 31.8974878,
          "diffHourly": 0.043695188767123284,
          "diffMonthly": 31.8974878
        }
      }
    ],
    "terraformVersion": "1.2.8",
    "connections": [],
    "graphCenterX": 39,
    "graphCenterY": 14,
    "graphWidth": 77,
    "graphHeight": 27,
    "costs": {
      "diffTotalHourlyCost": 0.043695188767123284,
      "diffTotalMonthlyCost": 31.8974878,
      "pastTotalHourlyCost": 0.053695188767123286,
      "pastTotalMonthlyCost": 39.1974878,
      "totalHourlyCost": 0.09739037753424658,
      "totalMonthlyCost": 71.0949756
    }
  },
  "changes": {
    "create": 1,
    "update": 0,
    "delete": 0,
    "deletecreate": 0,
    "no-op": 9,
    "drift": 0
  },
  "providers": [
    "google"
  ]
}

what's the problems?

heumsi commented 2 years ago

I also tried to request server manually like this.

curl -X POST https://api.pluralith.com/v1/run/log -H "Content-Type: application/json" -H "Authorization: Bearer ${API_TOKEN}" -d @data.json

{"code":400,"message":"Generating exports failed","error":{}

It still respond 400 code and error is empty.

DanThePutzer commented 2 years ago

Hi @heumsi,

Thanks for running Pluralith! I commented about this issue in the pluralith-cli issue #54. It is an issue caused by the CLI, not the GitHub action.

heumsi commented 2 years ago

It works now (after https://github.com/Pluralith/pluralith-cli/issues/54#issuecomment-1253048154) Following is the result.

https://github.com/heumsi/hands-on-terraform-with-gcp/pull/8

Thank you!