Skip to content

Commit 4556111

Browse files
authored
direct: Support updating name and recreate for volumes (#3342)
## Changes - Handle changing name of the volume via "new_name" field. - Fill in RecreateFields based on TF. ## Tests New acceptance tests.
1 parent c378c1c commit 4556111

File tree

13 files changed

+146
-6
lines changed

13 files changed

+146
-6
lines changed

acceptance/bundle/resources/volumes/databricks.yml renamed to acceptance/bundle/resources/volumes/change-comment/databricks.yml

File renamed without changes.

acceptance/bundle/resources/volumes/out.test.toml renamed to acceptance/bundle/resources/volumes/change-comment/out.test.toml

File renamed without changes.

acceptance/bundle/resources/volumes/output.txt renamed to acceptance/bundle/resources/volumes/change-comment/output.txt

File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resources:
2+
volumes:
3+
volume1:
4+
catalog_name: main
5+
schema_name: myschema
6+
name: myvolume
7+
comment: COMMENT1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"method": "GET",
3+
"path": "/api/2.1/unity-catalog/volumes/main.myschema.myvolume"
4+
}
5+
{
6+
"method": "GET",
7+
"path": "/api/2.1/unity-catalog/volumes/main.myschema.mynewvolume"
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> print_requests
9+
{
10+
"method": "POST",
11+
"path": "/api/2.1/unity-catalog/volumes",
12+
"body": {
13+
"catalog_name": "main",
14+
"comment": "COMMENT1",
15+
"name": "myvolume",
16+
"schema_name": "myschema",
17+
"volume_type": "MANAGED"
18+
}
19+
}
20+
21+
=== Summary should now show id and url
22+
{
23+
"volumes": {
24+
"volume1": {
25+
"catalog_name": "main",
26+
"comment": "COMMENT1",
27+
"id": "main.myschema.myvolume",
28+
"name": "myvolume",
29+
"schema_name": "myschema",
30+
"url": "[DATABRICKS_URL]/explore/data/volumes/main/myschema/myvolume?o=[NUMID]",
31+
"volume_type": "MANAGED"
32+
}
33+
}
34+
}
35+
36+
=== Update name
37+
>>> update_file.py databricks.yml myschema mynewschema
38+
39+
>>> [CLI] bundle plan
40+
recreate volumes.volume1
41+
42+
>>> [CLI] bundle deploy --auto-approve
43+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
44+
45+
This action will result in the deletion or recreation of the following volumes.
46+
For managed volumes, the files stored in the volume are also deleted from your
47+
cloud tenant within 30 days. For external volumes, the metadata about the volume
48+
is removed from the catalog, but the underlying files are not deleted:
49+
recreate volume volume1
50+
Deploying resources...
51+
Updating deployment state...
52+
Deployment complete!
53+
54+
>>> print_requests
55+
{
56+
"method": "DELETE",
57+
"path": "/api/2.1/unity-catalog/volumes/main.myschema.myvolume"
58+
}
59+
{
60+
"method": "POST",
61+
"path": "/api/2.1/unity-catalog/volumes",
62+
"body": {
63+
"catalog_name": "main",
64+
"comment": "COMMENT1",
65+
"name": "myvolume",
66+
"schema_name": "mynewschema",
67+
"volume_type": "MANAGED"
68+
}
69+
}
70+
71+
>>> musterr [CLI] volumes read main.myschema.myvolume
72+
Error: Resource catalog.VolumeInfo not found: main.myschema.myvolume
73+
74+
Exit code (musterr): 1
75+
76+
>>> [CLI] volumes read main.myschema.mynewvolume
77+
Error: Resource catalog.VolumeInfo not found: main.myschema.mynewvolume
78+
79+
Exit code: 1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
trace $CLI bundle deploy
2+
3+
print_requests() {
4+
jq 'select(.method != "GET" and (.path | contains("/unity")))' < out.requests.txt
5+
rm out.requests.txt
6+
}
7+
8+
trace print_requests
9+
10+
title "Summary should now show id and url\n"
11+
$CLI bundle summary -o json | jq .resources
12+
13+
title "Update name"
14+
trace update_file.py databricks.yml myschema mynewschema
15+
16+
trace $CLI bundle plan # should show "recreate"
17+
trace $CLI bundle deploy --auto-approve
18+
trace print_requests
19+
20+
trace musterr $CLI volumes read main.myschema.myvolume
21+
trace $CLI volumes read main.myschema.mynewvolume
22+
rm out.requests.txt

0 commit comments

Comments
 (0)