Repository navigation
Commit 4c87e6a
acc: add plan_filter.py to keep backend-owned remote_state out of plan goldens (#7764)
## Changes
New acceptance helper `acceptance/bin/plan_filter.py`: reads `bundle
plan -o json` on stdin, drops `remote_state` from every plan entry and
removes the deployment stamp (reusing `nostamp.render`). With a resource
key it prints just that entry, and fails if the key isn't in the plan.
So
```
$CLI bundle plan -o json | nostamp | jq '(.plan."resources.X.y" // .) | del(.remote_state)'
```
becomes
```
$CLI bundle plan -o json | plan_filter.py resources.X.y
```
It's covered by a selftest (`acceptance/selftest/plan_filter`) and
documented in `.agents/rules/testing.md`, along with a rule to use it
unless a test checks `remote_state` itself.
Applied to the cloud postgres plan tests:
`postgres_branches/update_protected`, `postgres_databases/update`,
`postgres_roles/update`,
`postgres_projects/add_default_endpoint_settings`, plus
`postgres_projects/update_display_name` and
`postgres_endpoints/update_autoscaling`, which already dropped
`remote_state` with jq. The golden updates only remove `remote_state`
blocks (3 insertions, all from trailing-comma changes, 193 deletions).
## Why
`remote_state` is the backend's GET response copied into the plan as is:
status, timestamps, sizes, UIDs, and any field the backend starts
returning. If a golden records it, the test fails whenever the backend
changes, even when the CLI's decision (`action`, `new_state`, `changes`)
is the same, and the failure shows up on every cloud at once.
`changes[*].remote` still records the remote value of each field the
plan compares.
Measured on main before this PR:
- 115 goldens record `remote_state`, 42 of them in `Cloud = true` tests.
- Over 30 days of main runs, these "Plan differs" errors had every diff
line inside `remote_state`, so this filter would have prevented them:
[error/2961](http://go/cli/dashboard/error/2961?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d)
(13 failures),
[error/2893](http://go/cli/dashboard/error/2893?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d)
(10),
[error/2964](http://go/cli/dashboard/error/2964?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/3587](http://go/cli/dashboard/error/3587?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/3526](http://go/cli/dashboard/error/3526?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d).
#7745 and #7495 fixed some of these test by test.
- Not prevented: the postgres GET change from last week
([error/3534](http://go/cli/dashboard/error/3534?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/3535](http://go/cli/dashboard/error/3535?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/3537](http://go/cli/dashboard/error/3537?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d)
and siblings, fixed in #7596). Once the backend echoed spec fields back,
`changes` changed too (`skip`/`spec:input_only` entries disappeared and
`remote` values appeared), so those tests would have failed with or
without `remote_state`. That's a real change in the plan, and the
goldens should catch it.
| error | snippet (inside `remote_state`) |
|---|---|
|
[error/2961](http://go/cli/dashboard/error/2961?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d)
| `+ "compute_last_active_time": "[TIMESTAMP]",` |
|
[error/2893](http://go/cli/dashboard/error/2893?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d)
| `Unexpected output "status": "MONITOR_STATUS_PENDING",` |
## Decisions
- Tests opt in with a helper; the runner doesn't strip `remote_state` by
default. Some tests check `remote_state` on purpose (dashboards'
`serialized_dashboard`, grants' `__embed__` principals,
`apps/config-env-no-drift`, `quality_monitors`' allow-list), and a
filter hidden in the runner would make those goldens misleading.
- `changes[*].remote` is kept. It's the input to the CLI's drift
decision, and out-of-band tests depend on it.
- When the resource key is missing, `plan_filter.py` fails. The old `jq
'.plan."KEY" // .'` silently wrote the whole plan instead. None of the
converted goldens relied on that fallback, and a missing entry should
fail loudly.
- For `skip` entries (the `no_change` goldens), only `action` is left,
because a skip has no `changes`. That's intended: the plan's decision is
the assertion. If a broken read changed what the CLI sees, the action
would turn into update or recreate, and that still shows up.
- It's a separate script rather than a flag on `nostamp.py`. `nostamp`
is also used for states and request bodies, where `remote_state` doesn't
apply. `plan_filter.py` reuses `nostamp.render`, so stamp handling stays
in one place.
- Scope is the postgres family, which has churned the most. The other
cloud goldens that record `remote_state` (dashboards, grants,
quality_monitors) check it on purpose or already filter it. Local-only
tests can adopt the helper when they're next touched.
## Tests
- `selftest/plan_filter` (local): whole plan, one entry, missing entry,
non-plan and empty input.
- All 12 variants (DMS= and DMS=true) of the six postgres tests pass on
AWS (`testme-aws`). The last commit message requests the same AWS run in
CI.
## Dashboard
[error/3534](http://go/cli/dashboard/error/3534?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/3535](http://go/cli/dashboard/error/3535?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/3537](http://go/cli/dashboard/error/3537?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d):
these motivated the change. They were already fixed on main by #7596,
and this PR wouldn't have prevented them (see above). It does prevent
the class above:
[error/2961](http://go/cli/dashboard/error/2961?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/3587](http://go/cli/dashboard/error/3587?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/2964](http://go/cli/dashboard/error/2964?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d),
[error/3526](http://go/cli/dashboard/error/3526?main=1&pr=1&end=2026-11-18T11:00:00Z&last=14d).
```
Plan differs (out.plan.update.json): Unexpected output "is_protected": false, "no_expiry": true,
Plan differs (out.plan.restore.json): Unexpected output "compute_last_active_time": "[TIMESTAMP]",
```
This pull request and its description were written by Isaac.
---------
Co-authored-by: Isaac <no-reply@databricks.com>1 parent 247b83e commit 4c87e6a
22 files changed
Lines changed: 193 additions & 216 deletions
File tree
- .agents/rules
- acceptance
- bin
- bundle/resources
- postgres_branches/update_protected
- postgres_databases/update
- postgres_endpoints/update_autoscaling
- postgres_projects
- add_default_endpoint_settings
- update_display_name
- postgres_roles/update
- selftest/plan_filter
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
| 190 | + | |
| 191 | + | |
189 | 192 | | |
190 | 193 | | |
191 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 8 | + | |
29 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 17 | | |
38 | 18 | | |
39 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 17 | | |
38 | 18 | | |
39 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 12 | + | |
27 | 13 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | 21 | | |
36 | 22 | | |
37 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | 21 | | |
36 | 22 | | |
37 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
0 commit comments