Pluralith / pluralith-cli

A tool for Terraform state visualisation and automated generation of infrastructure documentation
https://www.pluralith.com
Mozilla Public License 2.0
787 stars 54 forks source link

Never ending Github Actions #84

Open pcartas opened 2 years ago

pcartas commented 2 years ago

Hi! im using Pluralith with the CI/CD integration for Github Actions, with my personal account. I dont know if it its a billed feature When the job runs this it never finish

    - name: Pluralith Init
      uses: Pluralith/actions/init@v1.2.0
      with:
        terraform-path: ${{env.TF_ACTION_WORKING_DIR}}
        api-key: ${{ secrets.PLURALITH_API_KEY }}
        project-id: ${{ secrets.PLURALITH_PROJECT_ID }}

image and when i stop the job seems like it was expecting for "Org Id" input

DanThePutzer commented 2 years ago

Hi @pcartas thanks for reporting!

We recently released a new version of the CLI that introduced some changes on the init command.

We're currently in the process of updating the GitHub actions to work with the new init command.

Admittedly, we should've updated the actions simultaneously, sorry for the disruption!

We'll push a new release for the GitHub actions that fixes the problem tomorrow, I'll report back here once it's available 👍

DanThePutzer commented 2 years ago

@pcartas the new actions are out and you should be ready to roll!

Please make sure to update to v1.3.0 of our actions and check out the docs. There have been a few small changes. You now need to pass in an org ID and a project ID. There are a few ways to set this up, they are outlined here in point no. 3.

In your case, if you want to keep passing parameters directly inside the action, the new snipped would look something like this (don't forget to set PLURALITH_ORG_ID in your action secret settings):

    - name: Pluralith Init
      uses: Pluralith/actions/init@v1.3.0
      with:
        terraform-path: ${{env.TF_ACTION_WORKING_DIR}}
        api-key: ${{ secrets.PLURALITH_API_KEY }}
        org-id: ${{ secrets.PLURALITH_ORG_ID }}
        project-id: ${{ secrets.PLURALITH_PROJECT_ID }}

It worked great while testing on my end, but let me know if you run into any issues!

pcartas commented 2 years ago

How long does this part usually take? image i made a big refactor, there are many changes

DanThePutzer commented 2 years ago

It actually shouldn't take that long! So I'm assuming something is off

Before the refactor did it usually run in reasonable time?

pcartas commented 2 years ago

is the first time im using Pluralith so i dont know :(

DanThePutzer commented 2 years ago

Gotcha!

Then I'm assuming its an issue on our end. Is the project a large/complex one?

pcartas commented 2 years ago

i guess is a mid size project, it has 4 vpc/clusters/load_balancers and 3 microservices for now, we are migrating to terraform and im doing the initial devops of the project, im also new at terraform, i can show you the github action/job if you need

DanThePutzer commented 2 years ago

Hm ok thanks for the info! I'm thinking this might be an issue with our graphing algorithm getting caught in some loop.

Do you have the chance to run pluralith locally and see if you get a diagram there?

You can simply download our desktop app here, should be super quick to get installed, simply hit the download button here: https://docs.pluralith.com/docs/get-started/run-locally

After that you could run pluralith plan in your terraform project. If it takes a very long time there as well, then its a graphing issue for sure!

DanThePutzer commented 2 years ago

Apologies for the inconvenience btw, we really appreciate the help in debugging! :+1:

pcartas commented 2 years ago

thanx for the support! and for the patience image the file downloaded is extensionless, how do i install it? im using ubuntu 20.04 and chrome 107.0.5304.87

DanThePutzer commented 2 years ago

Ah yes, our Linux setup is still a bit weird, we have to change that!

It is actually a command line executable. So if you open a terminal, run chmod +x on the file and then just run it as if it was a bash script (simply ./pluralith_linux_installer_amd64_0.1.1) then it should install and the desktop app should open automatically.

If it doesn't open automatically (we've had some issues with that before) simply open the AppImage manually at ~/Pluralith/bin/Pluralith.AppImage

pcartas commented 2 years ago

image image i guess a confirmation button must appear in the UI

DanThePutzer commented 2 years ago

Ok I'm assuming it stays stuck on the "Generating Diagram" screen right?

pcartas commented 2 years ago

yes

DanThePutzer commented 2 years ago

Ok then it is definitely a graphing problem, meaning the action itself should be fine!

Now to debug our graphing algorithm we built a dedicated command into our CLI that completely anonymises your plan state and strips out all secrets. Would you be up for running pluralith strip in the same terraform project you just ran pluralith plan in and sharing the stripped and hashed plan state? The file we'd be interested in is in your terraform project in .pluralith/pluralith.state.hashed. Feel free to look over it before to make sure it's all hashed and anonymised!

If you'd send the file to my man @PhiWeber he's the one working on the graphing algorithm and this would be super helpful for him to debug. His email is: phi@pluralith.com

pcartas commented 2 years ago

Sended!

DanThePutzer commented 2 years ago

Awesome thanks a lot! We'll report back here when we found something!

DanThePutzer commented 2 years ago

Haven't seen that happen on macOS or Windows lately, I think it must be a Linux-specific bug. I'll dig into it!

We really appreciate the help! 👍

DanThePutzer commented 2 years ago

Btw, which Linux distro are you running?

pcartas commented 2 years ago

image if it helps, i tried colsing the UI and running pluralith plan, this error appears when it tries to open the UI after that it never release the lock and i have force-unlock im using ubuntu Ubuntu 20.04.5 LTS (ubuntu focal)

pcartas commented 2 years ago

i guess github actions now are using ubuntu 22.04

DanThePutzer commented 2 years ago

Yeah I think because you never actually get to the step where the UI draws the diagram, it never sends the signal to the CLI to confirm or cancel the apply (depending on what you would choose in the UI, the prompt to do this only become available after the graph shows up), so the CLI never tells Terraform to terminate. With remote state that means Terraform doesn't get to let go of the lock.

We need to build a fail-safe into the CLI so terraform can terminate properly to avoid the locking issue!

That's actually great input, gotta fix that up, thanks a lot!

pcartas commented 2 years ago

thnx to you! this tool seems very useful, here we are just starting with IaC and a visual tool is a big step to "evangelize" the rest of the team, when they see their own changes graphed they will freak out

DanThePutzer commented 2 years ago

Yes that's exactly the idea behind the product, let people see what they are working with and at the same time always have updated documentation so you never need to draw and maintain it manually 👍

Glad you like where the tool is going! We're still early, so lots of work to do to improve things, but bug reports and feedback like yours help a lot! 🚀

PhiWeber commented 1 year ago

@pcartas we've made some good progress debugging the project so far. I have a question regarding the plan: is this a pre-apply plan? By that I mean you haven't run terraform apply yet and the infrastructure hasn't been deployed. It would be very helpful if you could create a post-apply plan (first run terraform apply and then run pluralith plan) and send me the hashed plan (run pluralith strip again). Thank you!

pcartas commented 1 year ago

@PhiWeber Hi! i've made a lot of changes too. Indeed its a pre-apply plan, i've send you the pre-apply plan because the action is a PR action (so the changes are not aproved yet, so there arent applied). I can send you the actual post-apply plan (which is a bit diferent of the previous one)

DanThePutzer commented 1 year ago

@pcartas would be awesome if you could send the pluralith strip-ed post-apply plan to Phi again (phi@pluralith.com) 👍

Edit: Phi just told me you already sent it haha, nevermind and thanks!