Skip to content

Commit 26724c5

Browse files
authored
direct: increase "serial" field after every deployment (#4115)
## Why It was always the intention. ## Tests Existing tests already capture serials, some are extended to print it and check for specific value.
1 parent 71331d8 commit 26724c5

File tree

17 files changed

+60
-38
lines changed

17 files changed

+60
-38
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Bundles
1010
* `bundle deployment migrate` will now run a plan before migration to check if deployment was done ([#4088](https://github.com/databricks/cli/pull/4088))
11+
* engine/direct: Increase "serial" in state file after every deployment ([#4115](https://github.com/databricks/cli/pull/4115))
1112

1213
### Dependency updates
1314

acceptance/bundle/migrate/basic/out.new_state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lineage": "[UUID]",
3-
"serial": 5,
3+
"serial": 6,
44
"state": {
55
"resources.jobs.test_job": {
66
"__id__": "[NUMID]",

acceptance/bundle/migrate/basic/output.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ Error: Required engine "terraform" does not match present state files. Clear "DA
3232

3333
Available state files:
3434
- terraform.tfstate: remote terraform state serial=4 lineage="[UUID]"
35-
- [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=5 lineage="[UUID]"
35+
- [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=6 lineage="[UUID]"
3636

3737

3838
>>> DATABRICKS_BUNDLE_ENGINE=terraform musterr [CLI] bundle deploy
3939
Error: Required engine "terraform" does not match present state files. Clear "DATABRICKS_BUNDLE_ENGINE" env var to use engine appropriate for the state.
4040

4141
Available state files:
4242
- terraform.tfstate: remote terraform state serial=4 lineage="[UUID]"
43-
- [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=5 lineage="[UUID]"
43+
- [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=6 lineage="[UUID]"
4444

4545

4646
=== Should show that it's already migrated
4747
>>> musterr [CLI] bundle deployment migrate
4848
Error: already using direct engine
49-
Details: [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=5 lineage="[UUID]"
49+
Details: [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=6 lineage="[UUID]"
5050

5151
>>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan
5252
update pipelines.test_pipeline
@@ -97,14 +97,14 @@ Deployment complete!
9797
=== Should show that it's already migrated
9898
>>> musterr [CLI] bundle deployment migrate
9999
Error: already using direct engine
100-
Details: [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=5 lineage="[UUID]"
100+
Details: [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=7 lineage="[UUID]"
101101

102102
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states
103-
[TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=5 lineage="[UUID]"
103+
[TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=7 lineage="[UUID]"
104104

105105
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states --force-pull
106-
resources.json: remote direct state serial=5 lineage="[UUID]"
107-
[TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=5 lineage="[UUID]"
106+
resources.json: remote direct state serial=7 lineage="[UUID]"
107+
[TEST_TMP_DIR]/.databricks/bundle/dev/resources.json: local direct state serial=7 lineage="[UUID]"
108108

109109
=== Extra plan: should have no drift
110110
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle plan

acceptance/bundle/migrate/dashboards/out.new_state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lineage": "[UUID]",
3-
"serial": 2,
3+
"serial": 3,
44
"state": {
55
"resources.dashboards.dashboard1": {
66
"__id__": "[DASHBOARD_ID]",

acceptance/bundle/migrate/dashboards/output.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ Error: Required engine "terraform" does not match present state files. Clear "DA
2222

2323
Available state files:
2424
- terraform.tfstate: remote terraform state serial=1 lineage="[UUID]"
25-
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=2 lineage="[UUID]"
25+
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=3 lineage="[UUID]"
2626

2727

2828
>>> DATABRICKS_BUNDLE_ENGINE=terraform musterr [CLI] bundle deploy
2929
Error: Required engine "terraform" does not match present state files. Clear "DATABRICKS_BUNDLE_ENGINE" env var to use engine appropriate for the state.
3030

3131
Available state files:
3232
- terraform.tfstate: remote terraform state serial=1 lineage="[UUID]"
33-
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=2 lineage="[UUID]"
33+
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=3 lineage="[UUID]"
3434

3535

3636
>>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan
@@ -54,11 +54,11 @@ Deployment complete!
5454
=== Should show that it's already migrated
5555
>>> musterr [CLI] bundle deployment migrate
5656
Error: already using direct engine
57-
Details: [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=2 lineage="[UUID]"
57+
Details: [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=4 lineage="[UUID]"
5858

5959
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states
60-
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=2 lineage="[UUID]"
60+
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=4 lineage="[UUID]"
6161

6262
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states --force-pull
63-
resources.json: remote direct state serial=2 lineage="[UUID]"
64-
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=2 lineage="[UUID]"
63+
resources.json: remote direct state serial=4 lineage="[UUID]"
64+
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=4 lineage="[UUID]"

acceptance/bundle/migrate/default-python/out.state_after_migration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lineage": "[UUID]",
3-
"serial": 4,
3+
"serial": 5,
44
"state": {
55
"resources.jobs.sample_job": {
66
"__id__": "[NUMID]",

acceptance/bundle/migrate/default-python/output.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ Deployment complete!
135135
>>> print_state.py
136136

137137
>>> diff.py ../out.state_after_migration.json ../out.state_after_deploy.json
138+
--- ../out.state_after_migration.json
139+
+++ ../out.state_after_deploy.json
140+
@@ -1,5 +1,5 @@
141+
{
142+
"lineage": "[UUID]",
143+
- "serial": 5,
144+
+ "serial": 6,
145+
"state": {
146+
"resources.jobs.sample_job": {
138147

139148
=== Extra plan: should have no drift
140149
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle plan

acceptance/bundle/migrate/grants/out.new_state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lineage": "[UUID]",
3-
"serial": 8,
3+
"serial": 9,
44
"state": {
55
"resources.registered_models.my_registered_model": {
66
"__id__": "main.schema_grants.mymodel",

acceptance/bundle/migrate/grants/output.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ Error: Required engine "terraform" does not match present state files. Clear "DA
2222

2323
Available state files:
2424
- terraform.tfstate: remote terraform state serial=7 lineage="[UUID]"
25-
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=8 lineage="[UUID]"
25+
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=9 lineage="[UUID]"
2626

2727

2828
>>> DATABRICKS_BUNDLE_ENGINE=terraform musterr [CLI] bundle deploy
2929
Error: Required engine "terraform" does not match present state files. Clear "DATABRICKS_BUNDLE_ENGINE" env var to use engine appropriate for the state.
3030

3131
Available state files:
3232
- terraform.tfstate: remote terraform state serial=7 lineage="[UUID]"
33-
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=8 lineage="[UUID]"
33+
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=9 lineage="[UUID]"
3434

3535

3636
>>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan
@@ -52,11 +52,11 @@ Deployment complete!
5252
=== Should show that it's already migrated
5353
>>> musterr [CLI] bundle deployment migrate
5454
Error: already using direct engine
55-
Details: [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=8 lineage="[UUID]"
55+
Details: [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=10 lineage="[UUID]"
5656

5757
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states
58-
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=8 lineage="[UUID]"
58+
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=10 lineage="[UUID]"
5959

6060
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states --force-pull
61-
resources.json: remote direct state serial=8 lineage="[UUID]"
62-
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=8 lineage="[UUID]"
61+
resources.json: remote direct state serial=10 lineage="[UUID]"
62+
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=10 lineage="[UUID]"

acceptance/bundle/migrate/permissions/out.new_state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lineage": "[UUID]",
3-
"serial": 6,
3+
"serial": 7,
44
"state": {
55
"resources.jobs.test_job": {
66
"__id__": "[NUMID]",

0 commit comments

Comments
 (0)