Skip to content

Commit a6fbd57

Browse files
Add support for alerts to DABs (#4004)
## Changes Support for alerts was removed until API side issues were fixed. This PR enables alerts in DABs again. I had to regenerate openapi annotations and the pydabs code because the linter was complaining. It seems that we do not automatically update these. ## Tests Now the acceptance test is also run on cloud.
1 parent 0c6c7be commit a6fbd57

File tree

47 files changed

+1415
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1415
-218
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Dependency updates
1010

1111
### Bundles
12+
* Add support for alerts to DABs ([#4004](https://github.com/databricks/cli/pull/4004))
1213
* Allow `file://` URIs in job libraries to reference runtime filesystem paths (e.g., JARs pre-installed on clusters via init scripts). These paths are no longer treated as local files to upload. ([#3884](https://github.com/databricks/cli/pull/3884))
1314

1415
### API Changes

acceptance/bundle/deployment/bind/alert/alert.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"display_name": "test-alert-$UNIQUE_NAME",
3+
"query_text": "SELECT 1",
4+
"warehouse_id": "$TEST_DEFAULT_WAREHOUSE_ID",
5+
"custom_summary": "Test Alert Summary",
6+
"custom_description": "Test Alert Description",
7+
"evaluation": {
8+
"comparison_operator": "EQUAL",
9+
"notification": {
10+
"notify_on_ok": false,
11+
"retrigger_seconds": 1
12+
},
13+
"source": {
14+
"aggregation": "MAX",
15+
"display": "1",
16+
"name": "1"
17+
},
18+
"threshold": {
19+
"value": {
20+
"double_value": 1
21+
}
22+
}
23+
},
24+
"schedule": {
25+
"pause_status": "UNPAUSED",
26+
"quartz_cron_schedule": "0 0 * * * ?",
27+
"timezone_id": "UTC"
28+
}
29+
}

acceptance/bundle/deployment/bind/alert/databricks.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
bundle:
2+
name: test-bind-alert-$UNIQUE_NAME
3+
4+
resources:
5+
alerts:
6+
my_alert:
7+
display_name: test-alert
8+
evaluation:
9+
comparison_operator: EQUAL
10+
source:
11+
name: "1"
12+
threshold:
13+
value:
14+
double_value: 2
15+
query_text: select 2
16+
schedule:
17+
quartz_cron_schedule: "44 19 */1 * * ?"
18+
timezone_id: Europe/Amsterdam
19+
warehouse_id: aaaaaaaaaaaaaaaa

acceptance/bundle/deployment/bind/alert/out.test.toml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/deployment/bind/alert/output.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11

22
>>> [CLI] alerts-v2 create-alert --json @alert.json
33

4-
>>> [CLI] bundle deployment bind my_alert [UUID] --auto-approve
4+
>>> [CLI] bundle deployment bind my_alert [ALERT_ID] --auto-approve
55
Updating deployment state...
6-
Successfully bound alert with an id '[UUID]'
6+
Successfully bound alert with an id '[ALERT_ID]'
77
Run 'bundle deploy' to deploy changes to your workspace
88

99
>>> [CLI] bundle summary
10-
Name: test-bundle-$UNIQUE_NAME
10+
Name: test-bind-alert-[UNIQUE_NAME]
1111
Target: default
1212
Workspace:
1313
User: [USERNAME]
14-
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle-$UNIQUE_NAME/default
14+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bind-alert-[UNIQUE_NAME]/default
1515
Resources:
1616
Alerts:
1717
my_alert:
1818
Name: test-alert
19-
URL: [DATABRICKS_URL]/sql/alerts-v2/[UUID]?o=[NUMID]
19+
URL: [DATABRICKS_URL]/sql/alerts-v2/[ALERT_ID]
2020

2121
>>> [CLI] bundle deployment unbind my_alert
2222
Updating deployment state...
2323

2424
>>> [CLI] bundle summary
25-
Name: test-bundle-$UNIQUE_NAME
25+
Name: test-bind-alert-[UNIQUE_NAME]
2626
Target: default
2727
Workspace:
2828
User: [USERNAME]
29-
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle-$UNIQUE_NAME/default
29+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bind-alert-[UNIQUE_NAME]/default
3030
Resources:
3131
Alerts:
3232
my_alert:

acceptance/bundle/deployment/bind/alert/script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
envsubst < databricks.yml.tmpl > databricks.yml
2+
envsubst < alert.json.tmpl > alert.json
3+
14
alert_id=$(trace $CLI alerts-v2 create-alert --json @alert.json | jq -r '.id')
5+
echo "$alert_id:ALERT_ID" >> ACC_REPLS
26
trace $CLI bundle deployment bind my_alert $alert_id --auto-approve
37
trace $CLI bundle summary
48

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
Cloud = false
2-
Local = false # Enable when releasing support for alerts.
1+
Cloud = true
2+
Local = false
33

44
BundleConfigTarget = "databricks.yml"
5+
6+
# On aws the host URL includes the workspace ID as well. Thus skipping it to keep the test simple.
7+
CloudEnvs.aws = false
8+
9+
Ignore = [
10+
"databricks.yml",
11+
"alert.json",
12+
]

acceptance/bundle/refschema/out.fields.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ resources.alerts.*.schedule.timezone_id string ALL
5555
resources.alerts.*.update_time string ALL
5656
resources.alerts.*.url string INPUT
5757
resources.alerts.*.warehouse_id string ALL
58+
resources.alerts.*.permissions.object_id string ALL
59+
resources.alerts.*.permissions.permissions []iam.AccessControlRequest ALL
60+
resources.alerts.*.permissions.permissions[*] iam.AccessControlRequest ALL
61+
resources.alerts.*.permissions.permissions[*].group_name string ALL
62+
resources.alerts.*.permissions.permissions[*].permission_level iam.PermissionLevel ALL
63+
resources.alerts.*.permissions.permissions[*].service_principal_name string ALL
64+
resources.alerts.*.permissions.permissions[*].user_name string ALL
5865
resources.apps.*.active_deployment *apps.AppDeployment ALL
5966
resources.apps.*.active_deployment.create_time string ALL
6067
resources.apps.*.active_deployment.creator string ALL

0 commit comments

Comments
 (0)