Skip to content

Commit a9a9561

Browse files
committed
Skip app config/git_source drift when the app has no deployment
The app deploy-only fields (config, git_source) are applied through an app deployment, which only happens once the app compute is started (manageLifecycle). Until then DoRead leaves them nil, so an app that set config or git_source without lifecycle.started=true planned a perpetual update for a field that was never deployed. Extend OverrideChangeDesc to skip config and git_source while there is no active deployment, keying off remote.ActiveDeployment. source_code_path was already skipped; matching on the top-level field (Prefix(1)) now also catches nested config diffs. Real out-of-band drift is still reported once a deployment exists. Adds acceptance tests for the config and git_source cases.
1 parent c8c397f commit a9a9561

13 files changed

Lines changed: 181 additions & 5 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
3+
from flask import Flask
4+
5+
app = Flask(__name__)
6+
7+
8+
@app.route("/")
9+
def home():
10+
return "Hello from config-no-deployment app!"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
command:
2+
- python
3+
- app.py
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bundle:
2+
name: app-config-no-deployment
3+
4+
resources:
5+
apps:
6+
myapp:
7+
name: test-app-config-no-deployment
8+
description: my_app_description
9+
source_code_path: ./app
10+
config:
11+
command: ["python", "app.py"]
12+
env:
13+
- name: MY_ENV_VAR
14+
value: test_value

acceptance/bundle/resources/apps/config-no-deployment/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
=== Deploy: app created with no_compute; config is not deployed until the app starts
3+
>>> [CLI] bundle deploy
4+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/app-config-no-deployment/default/files...
5+
Deploying resources...
6+
Updating deployment state...
7+
Deployment complete!
8+
9+
=== Plan is a no-op: config/source_code_path drift is skipped while the app has no deployment
10+
>>> [CLI] bundle plan
11+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
12+
13+
=== Both deploy-only fields are skipped with reason "no deployment"
14+
>>> [CLI] bundle plan -o json
15+
{
16+
"config": {
17+
"action": "skip",
18+
"reason": "no deployment",
19+
"old": {
20+
"command": [
21+
"python",
22+
"app.py"
23+
],
24+
"env": [
25+
{
26+
"name": "MY_ENV_VAR",
27+
"value": "test_value"
28+
}
29+
]
30+
},
31+
"new": {
32+
"command": [
33+
"python",
34+
"app.py"
35+
],
36+
"env": [
37+
{
38+
"name": "MY_ENV_VAR",
39+
"value": "test_value"
40+
}
41+
]
42+
}
43+
},
44+
"source_code_path": {
45+
"action": "skip",
46+
"reason": "no deployment",
47+
"old": "/Workspace/Users/[USERNAME]/.bundle/app-config-no-deployment/default/files/app",
48+
"new": "/Workspace/Users/[USERNAME]/.bundle/app-config-no-deployment/default/files/app"
49+
}
50+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
echo "*" > .gitignore
2+
3+
title "Deploy: app created with no_compute; config is not deployed until the app starts"
4+
trace $CLI bundle deploy
5+
6+
title "Plan is a no-op: config/source_code_path drift is skipped while the app has no deployment"
7+
trace $CLI bundle plan | contains.py "Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged"
8+
9+
title "Both deploy-only fields are skipped with reason \"no deployment\""
10+
trace $CLI bundle plan -o json | jq '.plan[].changes | {config, source_code_path}'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Local = true
2+
Cloud = false
3+
4+
# Asserts plan classification, not requests; drop the inherited RecordRequests.
5+
RecordRequests = false
6+
7+
Ignore = [".databricks"]
8+
9+
# Direct engine only: the skip logic lives in OverrideChangeDesc. Mirrors
10+
# lifecycle-started-omitted.
11+
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
bundle:
2+
name: app-git-source-no-deployment
3+
4+
resources:
5+
apps:
6+
myapp:
7+
name: test-app-git-source-no-deployment
8+
description: my_app_description
9+
git_source:
10+
branch: main

acceptance/bundle/resources/apps/git-source-no-deployment/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
=== Deploy: app created with no_compute; git_source is not deployed until the app starts
3+
>>> [CLI] bundle deploy
4+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/app-git-source-no-deployment/default/files...
5+
Deploying resources...
6+
Updating deployment state...
7+
Deployment complete!
8+
9+
=== Plan is a no-op: git_source drift is skipped while the app has no deployment
10+
>>> [CLI] bundle plan
11+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
12+
13+
=== git_source is skipped with reason "no deployment"
14+
>>> [CLI] bundle plan -o json
15+
{
16+
"git_source": {
17+
"action": "skip",
18+
"reason": "no deployment",
19+
"old": {
20+
"branch": "main"
21+
},
22+
"new": {
23+
"branch": "main"
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)