Commit edcc112
authored
Fix persistent drift in dashboards (#4044)
## Changes
Fixes persistent drift detection issues in dashboard resources for
direct deployment mode.
## Why
Dashboards were incorrectly showing drift on every `bundle plan` even
when no actual changes were made. The following fields were causing
false positives:
**Local changes detected:**
- `embed_credentials` (action: update)
- `etag` (action: update)
- `serialized_dashboard` (action: update)
**Remote changes detected:**
- `parent_path` (action: recreate)
This PR fixes all of these issues by:
1. `parent_path`: Adding a `DashboardFixups` mutator to ensure
`/Workspace` prefix is added to `parent_path` in the local config to
match API responses
2. `serialized_dashboard`: Creating a new struct for dashboards that is
flat. The persistent drift occured because our diff logic is go based
and thus flagged a diff on the string based serialized_dashboard field
4. `etag`: Add skip trigger for local diffs.
5. `embed_credentials`: Creating a new struct for dashboards that is
flat. Before embed_credentials was not being marsalled because of the
custom override. Now it is being marshalled.
Plan before:
```
{
"plan": {
"resources.dashboards.dashboard1": {
"action": "recreate",
"new_state": {
"value": {
"display_name": "test bundle-deploy-dashboard [UUID]",
"parent_path": "/Users/[USERNAME]",
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
}
},
"remote_state": {
"create_time": "[TIMESTAMP]",
"dashboard_id": "[DASHBOARD_ID]",
"display_name": "test bundle-deploy-dashboard [UUID]",
"etag": [ETAG],
"lifecycle_state": "ACTIVE",
"parent_path": "/Workspace/Users/[USERNAME]",
"path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json",
"serialized_dashboard": "{\n \"pages\": [\n {\n \"name\": \"02724bf2\",\n \"displayName\": \"Dashboard test bundle-deploy-dashboard\",\n \"pageType\": \"PAGE_TYPE_CANVAS\"\n }\n ]\n}\n",
"update_time": "[TIMESTAMP]",
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
},
"changes": {
"local": {
"embed_credentials": {
"action": "update"
},
"etag": {
"action": "update"
},
"serialized_dashboard": {
"action": "update"
}
},
"remote": {
"embed_credentials": {
"action": "skip",
"reason": "server_side_default"
},
"parent_path": {
"action": "recreate"
},
"serialized_dashboard": {
"action": "skip",
"reason": "server_side_default"
}
}
}
}
}
}
```
Plan now:
```
{
"plan": {
"resources.dashboards.dashboard1": {
"action": "skip",
"remote_state": {
"create_time": "[TIMESTAMP]",
"dashboard_id": "[DASHBOARD_ID]",
"display_name": "test bundle-deploy-dashboard [UUID]",
"embed_credentials": true,
"etag": [ETAG],
"lifecycle_state": "ACTIVE",
"parent_path": "/Workspace/Users/[USERNAME]",
"path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json",
"serialized_dashboard": "{\n \"pages\": [\n {\n \"name\": \"02724bf2\",\n \"displayName\": \"Dashboard test bundle-deploy-dashboard\",\n \"pageType\": \"PAGE_TYPE_CANVAS\"\n }\n ]\n}\n",
"update_time": "[TIMESTAMP]",
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
},
"changes": {
"local": {
"etag": {
"action": "skip"
}
},
"remote": {
"serialized_dashboard": {
"action": "skip"
}
}
}
}
}
}
```
## Tests
Updated acceptance test `acceptance/bundle/resources/dashboards/simple`
now passes with no drift detected on second plan.1 parent 7a84cf1 commit edcc112
File tree
32 files changed
+326
-224
lines changed- acceptance/bundle
- migrate/dashboards
- refschema
- resources
- dashboards
- change-parent-path
- delete-trashed-out-of-band
- simple_outside_bundle_root
- simple_syncroot
- simple
- permissions/dashboards/create
- validate/dashboard_defaults
- bundle
- config
- mutator
- resourcemutator
- resources
- deploy/terraform
- tfdyn
- direct/dresources
- statemgmt
32 files changed
+326
-224
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
Lines changed: 4 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 4 | + | |
12 | 5 | | |
13 | 6 | | |
14 | 7 | | |
15 | 8 | | |
| 9 | + | |
16 | 10 | | |
17 | 11 | | |
18 | 12 | | |
| |||
23 | 17 | | |
24 | 18 | | |
25 | 19 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 20 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 21 | + | |
34 | 22 | | |
35 | 23 | | |
36 | 24 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 25 | | |
45 | | - | |
46 | | - | |
| 26 | + | |
47 | 27 | | |
48 | 28 | | |
49 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 35 | + | |
39 | 36 | | |
40 | 37 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 38 | + | |
45 | 39 | | |
46 | 40 | | |
47 | 41 | | |
48 | 42 | | |
49 | 43 | | |
50 | 44 | | |
51 | 45 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | 46 | | |
57 | 47 | | |
58 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
439 | 438 | | |
440 | 439 | | |
441 | 440 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
Lines changed: 3 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 16 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 17 | + | |
22 | 18 | | |
23 | 19 | | |
24 | 20 | | |
| |||
Lines changed: 32 additions & 0 deletions
| 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 | + | |
Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments