preview-action icon indicating copy to clipboard operation
preview-action copied to clipboard

`--creation-source` not supported by selfhosted version

Open jemand771 opened this issue 1 year ago • 4 comments

Hi there,

I'm just getting started with uffizzi so sorry in advance if I missed something obvious.

I'm using a selfhosted install of uffizzi, although not using the official helm chart for bogus personal reasons[^nothelm]. Creating manual preview environments via uffizzi preview create docker-compose.yaml works, so the server setup itself feels okay. However, using the github action based on this repo's readme like this...

  deploy-uffizzi-preview:
    name: Use Remote Workflow to Preview on Uffizzi
    needs: render-compose-file
    uses: jemand771/preview-action/.github/workflows/reusable.yaml@no-creation-source
    with:
      compose-file-cache-key: ${{ needs.render-compose-file.outputs.compose-file-cache-key }}
      compose-file-cache-path: ${{ needs.render-compose-file.outputs.compose-file-cache-path }}
      server: https://my-uffizzi-host.example.com
      username: some-user
      project: test-project
    secrets:
      password: ${{ secrets.uffizzi_pass }}
    permissions:
      contents: read
      pull-requests: write
      id-token: write

...results in an error. I've tried to investigate it but got stuck unsure if I'm doing something wrong or if this is just broken.

starting with https://github.com/UffizziCloud/preview-action/pull/55, --creation-source=github_actions gets passed to the CLI here: https://github.com/UffizziCloud/preview-action/blob/bae81764cf3e0427042c148eb6059d91db9893de/action.yaml#L102-L107 This is part of the v2 branch which people are supposed to use according to the readme: https://github.com/UffizziCloud/preview-action/blob/bae81764cf3e0427042c148eb6059d91db9893de/README.md?plain=1#L78-L90

However, the server doesn't seem to support that. I'm getting this error...

Server Error:
is not included in the list

...which I'm assuming comes from here: https://github.com/UffizziCloud/uffizzi/blob/a4b1356695c5e89f905585c649ee07ca33c4489f/core/app/lib/uffizzi_core/concerns/models/deployment.rb#L30

    enumerize :creation_source, in: [:manual, :demo, :continuous_preview, :compose_file_manual, :compose_file_continuous_preview],
                                predicates: true, scope: true, default: :manual

This was actually almost implemented in https://github.com/UffizziCloud/uffizzi/pull/346, https://github.com/UffizziCloud/uffizzi/pull/346/commits/1204d83975f0e9b13918048bf374b51b51045c78#diff-7eaf3aeada9f27cbf1c93ca78682ca4bda47e215fb0f2c941e6b38a31ff4e346R30 to be precise...

- enumerize :creation_source, in: [:manual, :continuous_preview, :compose_file_manual, :compose_file_continuous_preview],
+ enumerize :creation_source, in: [:manual, :continuous_preview, :compose_file_manual, :compose_file_continuous_preview, :github_actions],

...but got reverted in https://github.com/UffizziCloud/uffizzi/pull/346/commits/9be671c8729a7cb2540fe198d59d6b07fda8213e after https://github.com/UffizziCloud/uffizzi/pull/346#discussion_r1058326452

Now, it's possible that I'm just unlucky and caught this feature mid-development where one side is already updated but the other one hasn't been adjusted yet. But since this was in january and the change has been explicitly declined, I'm afraid this is "working" as intended. (just not for me)

I see a couple of possible solutions here:

  1. pass a different --creation-source
  2. support :github_actions in https://github.com/UffizziCloud/uffizzib)
  3. add an option that lets users specify a creation source, defaulting to the saas-supported one
  4. automatically detect whether a selfhosted server url is passed and if so, pass a different creation source

This might be related to https://github.com/UffizziCloud/uffizzi/pull/230, but I don't really have a full picture there (again, new to uffizzi). It's worth noting that the preview URL posted by github actions is in the format example.com/github.com/REPO_OWNER/REPO_NAME/pull/NUMBER while the actual preview url as returned by the server and posted to the github deployment status is deployment-INDEX-PROJECT_NAME.example.com. (index unrelated to pr number)

Again, that might be a separate issue but feels related anyway.

Again, sorry if this is just an issue with how I'm using the action. If it turns out that this is a bug, let me know if you need me to test anything; I'd be happy to help.

[^nothelm]: Here's (probably) irrelevant context about my setup that I still wanted to share: uffizzi feels like it's designed to run on its own standalone cluster, seeing how it comes with cert-manager and an ingress controller that can't be disabled. Because this is just for my personal/hobby setup, I tried integrating it into my existing cluster which already has cert-manager, a clusterissuer with dns-01 support and traefik as an ingress controller. I kinda copy-pasted together all of the env variables for the controller, web and sidekiq deployments, and everything seems to work together. The only hack I still have to do is manually removing the ingress class annotation for every deployment created by uffizzi. I'll probably either create an automated hack for this or submit an issue about making the annotation configurable to the controller repo.

jemand771 avatar Apr 09 '23 21:04 jemand771

Thanks @jemand771 - we'll take a look at this soon. Hopefully Monday

jpthurman avatar Apr 09 '23 21:04 jpthurman

@jemand771 Please update the uffizzi/core to the latest version (v2.1.18) and try again

moklidia avatar Apr 10 '23 16:04 moklidia

Huh, I'm not even using uffizzi/core anywhere, just /app and /controller. Updating those seems to fix the issue, thanks! I don't see a readme on dockerhub, what does the core image do? and while we're here: do the uffizzi/app and uffizzi/controller images really not have version tags? Just pulling :latest and relying on imagePullPolicy: Always feels really hacky and could cause unexpected updates in the future.

The server still creates the ingress as deployment-XXX-test-project.preview.example.com instead of the preview.example.com/github.com/REPO_OWNER/REPO_NAME/pull/YYY linked in the comment. Is that intentional? This might just be due to the selfhosted version not having a dashboard, so all requests to preview.example.com just result in rails error pages either way. In general, the comment left by the action is pretty useless for selfhosted since the "application logs" link doesn't lead anywhere either.

jemand771 avatar Apr 10 '23 18:04 jemand771

The server still creates the ingress as deployment-XXX-test-project.preview.example.com instead of the preview.example.com/github.com/REPO_OWNER/REPO_NAME/pull/YYY linked in the comment. Is that intentional? This might just be due to the selfhosted version not having a dashboard, so all requests to preview.example.com just result in rails error pages either way. In general, the comment left by the action is pretty useless for selfhosted since the "application logs" link doesn't lead anywhere either.

These "predictable URL's" are a feature of our hosted platform so they may not work for open-source Uffizzi. It looks like the URL comes back from the API so we can look at changing that behavior.

axisofentropy avatar Apr 12 '23 20:04 axisofentropy