databricks / setup-cli

Sets up the Databricks CLI in your GitHub Actions workflow.
Other
9 stars 9 forks source link

Asset bundle deploy - zip file already exists #97

Closed johalnes closed 2 months ago

johalnes commented 5 months ago

Hi,

I'm using this action together with Asset bundles (GitHub file below). Installation works as expected, but during deploy I get

Run databricks bundle deploy
Uploading bundle files to /Production/risk_analytics/files...
Error: file already exists: /Production/risk_analytics/files/databricks_cli_0.217.1_linux_amd64.zip"

Just by adding a step with rm databricks_cli_0.217.1_linux_amd64.zip solves the issue.

Should one either change directory, like instal.sh that uses temp directory, or add a step to remove installation files?

jobs:
  deploy:
    name: Production DBT run
    runs-on: ubuntu-latest  # self-hosted
    steps:
      - name: Checkout
        uses: actions/checkout@v4.1.0

      - name: Install Databricks
        uses: databricks/setup-cli@main

      - name: Deploy Dataflows
        run: databricks bundle deploy 
        env:
          DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
          DATABRICKS_BUNDLE_ENV: prod
pietern commented 5 months ago

Thanks for reporting. I haven't heard about this before.

Are you sure that the zip file is coming from the action and isn't checked into the repository?

johalnes commented 5 months ago

hehe hadn't thought about that one actually. Would have been embarrassing! Luckily I didn't have it checked in 🙂

Would suspect that would make the install step fail, and not the deploy asset bundle step?

jonasfagnastolhenriksen commented 3 months ago

I also have this issue. The zip-file seems to be remnants after installing the cli, and should probably be cleaned up by the action :)

dane-marjanovic commented 3 months ago

Hi, I stumbled upon this thread after experiencing the same issue. Github actions fails on the "asset bundle deploy" step, throwing Error: file already exists: /Users/***/.bundle/my_asset_bundle/tst/files/databricks_cli_0.221.1_linux_amd64.zip even when done for the newly added user and hence an empty folder. Workaround with adding command to remove zip file does the trick, but I am still wondering why is this happening (we have another environment with the same config and no error thrown) and if we can avoid having an inelegant workaround.

pietern commented 3 months ago

Thanks for the additional reports. I confirmed the issue and have a fix in #113.

pietern commented 3 months ago

@dane-marjanovic There are two cases that I can think of when this is not happening, even in the current setup. First, if *.zip is part of your .gitignore file, it won't be part of the list of files to synchronize into the workspace. Second, if your bundle root directory is not at the root of the repository but in a subdirectory, the ZIP file won't ever be considered for file synchronization.

The issue here happens only for bundles that are located in the root of a repository, that don't ignore ZIP files by default.

pietern commented 2 months ago

The fix has been merged. If you're using the action from the main branch then it should now work.