cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Does "databricks bundle deploy" clean up old files?

xhead
New Contributor II

I'm looking at this page (Databricks Asset Bundles development work tasks) in the Databricks documentation.

When repo assets are deployed to a databricks workspace, it is not clear if the "databricks bundle deploy" will remove files from the target workspace that aren't in the source repo. For example, if a repo contained a notebook named "test1.py" and had been deployed, but then "test1.py" was removed from the repo and a new notebook "test2.py" was created, what is the content of the target workspace after? I believe it will contain both "test1.py" and "test2.py".

Secondly, the description of "databricks bundle destroy" does not indicate that it would remove all files from the workspace - only that it will remove all the artifacts referenced by the bundle. So when the "test1.py" file has been removed from the repo, and the "databricks bundle destroy" is run, will it only remove "test2.py" (which has not yet been deployed)?

I am trying to determine how to ensure that the shared workspace contains only the files that are in the repo - that whatever I do in a release pipeline, I will only have the latest assets in the workspace that are in the repo, and none of the old files that were previously in the repo.

The semantics of "databricks bundle deploy" (in particular the term "deploy") would indicate to me that it should do a clean up of assets in the target workspace as part of the deployment.

But if that is not the case, then if I did a "databricks bundle destroy" prior to the "databricks bundle deploy", would that adequately clean up the target workspace? Or do I need to do something with "databricks fs rm" to delete all the files in the target workspace folder prior to the bundle deploy?

5 REPLIES 5

fbaxter
New Contributor II

With thew newer Datbricks CLI (v0.215.0) this seems to be broken.  Now I can't destroy a bundle if it doesn't exist - it used to be idempotent.  Now I get this error (shortned my deploy area to <ws> below:

Starting plan computation
Planning complete and persisted at <ws>/dab-stage/pytest/.databricks/bundle/new-cluster/terraform/plan

No resources to destroy in plan. Skipping destroy!
Error: open <ws>/dab-stage/pytest/.databricks/bundle/new-cluster/terraform/terraform.tfstate: no such file or directory
make: *** [test-on-cluster] Error 1

Will you add a synchronization option that does not remove existing jobs and pipelines?

We are using DAB for DBT and generally it works well, however, lifecycling models is a bit of a issue at the moment ๐Ÿ™‚

Quick update on this: Now if you remove a file locally (or from GIT in the case of CI/CD) and run "bundle deploy" from the CLI, it will remove the corresponding file from your Databricks workspace. 

e.g.
1. Add new file locally, run "bundle deploy"
2. File appears in Databricks workspace
3. Remove file locally, run "bundle deploy"
4. File is removed automatically from the Databricks workspace

Therefore, I don't think there's a need to manually do a cleanup of files. 

xhead
New Contributor II

One further question:

  • The purpose of โ€œdatabricks bundle destroyโ€ is to remove all previously-deployed jobs, pipelines, and artifacts that are defined in the bundle configuration files.

Which bundle configuration files? The ones in the repo? Or are there bundle configuration files in the target workspace location that are used? If the previous version of the bundle contained a reference to test1.py and it has been deployed to a shared workspace, and the new version of the repo no longer contains test1.py, will the destroy command remove test1.py from the shared workspace? 

 

JamesGraham
Databricks Employee
Databricks Employee

xhead I think the configuration files it's referring to is the local ones in your repo. It checks these against what has been deployed in the workspace and will remove anything that you've got rid of in you repo in the new version. Behind the scenes it uses a terraform state file to keep track of what has been deployed, which is saved in the workspace along with your other files in the bundle. 

In your example, yes it should remove test1.py from the shared workspace.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group