pulumi / pulumi-digitalocean

A DigitalOcean Pulumi resource package, providing multi-language access to DigitalOcean
Apache License 2.0
83 stars 13 forks source link

Pulumi deploys using an old commit when DO app is set to us elatest commit on main #771

Closed douglasg14b closed 1 week ago

douglasg14b commented 2 months ago

Describe what happened

When I deploy an app platform app with DO, the commit that's deployed in DO doesn't change. It appears to use the same commit that was last deployed. This causes issues between commits where the infrastructure & build commands have changed together, meaning that I cannot update the infrastructure with pulumi, and have to do it manually.

When I deploy (update the app) on digital ocean, the commit always updates to latest from my repo.

Sample program

I get the feeling this is a lack of understanding on my part, if it isn't and this is not intended behavior I can provide more info

Log output

N/A

Affected Resource(s)

App Platform

Output of pulumi about

N/A

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

VenelinMartinov commented 2 months ago

Hey @douglasg14b, sorry you hit this. This is, unfortunately, a somewhat awkward bit of how pulumi and similar tools work.

Are you using the git parameter here? If so, pulumi likely doesn't "know" when you update the git repo so can't know to redeploy the app.

Looking at the digitalocean App resource you might be better off using one of github or gitlab depending on where your source is stored with deploy_on_push. https://www.pulumi.com/registry/packages/digitalocean/api-docs/app/#appspecfunctiongithub These should be the easiest way for you to achieve the automatic redeployment of the app.

If that doesn't work for you then you need a way to tell pulumi to check for new updates to your git repo, for example using the Github provider - you can query the repo on every deployment and add a depends_on resource option to your digital ocean App, so that when the git repo is updated, pulumi knows to redeploy your digital ocean App.

douglasg14b commented 2 months ago

Are you using the git parameter here

I don't believe so. What is this parameter?


There may be a disconnect in what I explained, let me clarify:

Parameters:

Lets imagine this commit history on main:

Lets say the currently deployed version of the DO app is Commit 2.

If I was to go to DO and trigger a "deployment" in their UI (or via API) the app would pull Commit 3, build & deploy.

If I (CI/CD) was to instead trigger a deployment via Pulumi, the app will pull Commit 2, build & deploy. I need to directly trigger DO to do another deployment to get it to update to Commit 3. However, this may not be possible due to the timing of the DO rollback from the now failed DO deployment of Commit 2 now that the infra has broken the app itself on that old commit.


The problem this causes is if Commit 2 contains incompatible infrastructure & code changes. With the expectations that these are deployed as a unit, the infrastructure is updated, and then the application built & deployed. When the pulumi deployment is performed the application will build from an old commit, breaking, and be unable to rollback, resulting in extended downtime while this process resolved to a failed state. And then we can manually perform a deployment with DO to update to the newest commit, fixing the application.

VenelinMartinov commented 2 months ago

@douglasg14b Could you please include some code here so that we can reproduce what you are seeing - I don't quite understand the problem you are facing.

It would be really helpful if you could isolate a small pulumi program which exhibits the same problem so that we can work off of that. Thanks!