Skip to content

Commit f0edaa4

Browse files
authored
Fix --force-pull on bundle summary and bundle open (#5028)
## Why `--force-pull` on `bundle summary` and `bundle open` is silently ignored: both commands declare the flag but never pass it through, so the local state cache is used even when the user explicitly asks for a remote pull. Users see stale URLs or IDs and have no way to bypass the cache short of deleting `.databricks/` by hand. The flag works as expected on `pipelines open` and `bundle debug states`. ## Changes Wire `forcePull` into `ProcessOptions.AlwaysPull` in `cmd/bundle/summary.go` and `cmd/bundle/open.go` so the flag reaches `statemgmt.PullResourcesState`. This matches the pattern used in the two commands where the flag already works. No behavior change when the flag is unset. ## Test plan - [x] New acceptance test `acceptance/bundle/state/force_pull_commands/` asserts that a workspace-files state GET is issued only when `--force-pull` is set, for both `bundle summary` and `bundle open`. Runs under both engines via EnvMatrix. - [x] Reverted the fix locally and confirmed the test fails with the expected diff (missing state GETs), then restored. - [x] \`make checks\` clean; state/help/open/summary/pipelines-open acceptance suites all pass.
1 parent 6115d17 commit f0edaa4

10 files changed

Lines changed: 106 additions & 1 deletion

File tree

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66

77
### Bundles
88

9+
* Fixed `--force-pull` on `bundle summary` and `bundle open` so the flag bypasses the local state cache and reads state from the workspace.
10+
911
### Dependency updates
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bundle:
2+
name: force-pull-commands
3+
4+
resources:
5+
jobs:
6+
foo:
7+
name: foo
8+
tasks:
9+
- task_key: task
10+
spark_python_task:
11+
python_file: ./foo.py
12+
environment_key: default
13+
environments:
14+
- environment_key: default
15+
spec:
16+
client: "2"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("hello")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
echo "I AM BROWSER"

acceptance/bundle/state/force_pull_commands/out.test.toml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/force-pull-commands/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
=== Modify PATH so that real open is not run
9+
=== bundle summary without --force-pull: no remote state read
10+
11+
>>> [CLI] bundle summary
12+
13+
=== bundle summary --force-pull: remote state read
14+
15+
>>> [CLI] bundle summary --force-pull
16+
{
17+
"method": "GET",
18+
"path": "/api/2.0/workspace-files/Workspace/Users/[USERNAME]/.bundle/force-pull-commands/default/state/STATE_FILENAME"
19+
}
20+
21+
=== bundle open without --force-pull: no remote state read
22+
23+
>>> [CLI] bundle open foo
24+
Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID]
25+
Error: exec: "open": cannot run executable found relative to current directory
26+
27+
=== bundle open --force-pull: remote state read
28+
29+
>>> [CLI] bundle open foo --force-pull
30+
Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID]
31+
Error: exec: "open": cannot run executable found relative to current directory
32+
{
33+
"method": "GET",
34+
"path": "/api/2.0/workspace-files/Workspace/Users/[USERNAME]/.bundle/force-pull-commands/default/state/STATE_FILENAME"
35+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
trace $CLI bundle deploy > /dev/null
2+
rm -f out.requests.txt
3+
4+
title "Modify PATH so that real open is not run"
5+
export PATH=.:$PATH
6+
7+
title "bundle summary without --force-pull: no remote state read\n"
8+
trace $CLI bundle summary > /dev/null
9+
print_requests.py --get //workspace-files/
10+
11+
title "bundle summary --force-pull: remote state read\n"
12+
trace $CLI bundle summary --force-pull > /dev/null
13+
print_requests.py --get //workspace-files/
14+
15+
title "bundle open without --force-pull: no remote state read\n"
16+
musterr trace $CLI bundle open foo > /dev/null
17+
print_requests.py --get //workspace-files/
18+
19+
title "bundle open --force-pull: remote state read\n"
20+
musterr trace $CLI bundle open foo --force-pull > /dev/null
21+
print_requests.py --get //workspace-files/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Local = true
2+
Cloud = false
3+
RecordRequests = true
4+
5+
# bundle open opens a browser; restrict to darwin to get stable output
6+
# (mirrors acceptance/bundle/open/test.toml).
7+
GOOS.windows = false
8+
GOOS.linux = false
9+
10+
Ignore = [".databricks"]
11+
12+
[EnvMatrix]
13+
DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"]
14+
15+
[[Repls]]
16+
Old = '(resources\.json|terraform\.tfstate)'
17+
New = 'STATE_FILENAME'

cmd/bundle/open.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ Use after deployment to quickly navigate to your resources in the workspace.`,
7474
arg, err = resolveOpenArgument(ctx, b, args)
7575
return err
7676
},
77-
InitIDs: true,
77+
AlwaysPull: forcePull,
78+
InitIDs: true,
7879
})
7980
if err != nil {
8081
return err

cmd/bundle/summary.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Useful after deployment to see what was created and where to find it.`,
4646
} else {
4747
b, err := utils.ProcessBundle(cmd, utils.ProcessOptions{
4848
ReadState: true,
49+
AlwaysPull: forcePull,
4950
IncludeLocations: includeLocations,
5051
InitIDs: true,
5152
})

0 commit comments

Comments
 (0)