Skip to content

Commit eacf329

Browse files
authored
direct: Fix permissions for resources.models (#4941)
## Changes Pass correct ID to permissions API for resources.models. ## Why This resource has two IDs, one coming from Name field - used for all CRUD operations on the resource itself and another numerical ID that needs to be used for permissions request. Since we handle "id" specially in direct, we cannot reference it via $resources.models.foo.id anymore - it always points to CRUD id. So we make a wrapper struct that stores numerical ID under "model_id" and reference that. ## Tests New acceptance test and invariant test. Also fixes deployment of mlops-stack template with direct and enables that test on local (previously it was cloud-only).
1 parent 6dd4294 commit eacf329

22 files changed

Lines changed: 192 additions & 109 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
### Bundles
1313
* Added support for lifecycle.started option for apps ([#4672](https://github.com/databricks/cli/pull/4672))
14+
* engine/direct: Fix permissions for resources.models ([#4941](https://github.com/databricks/cli/pull/4941))
1415

1516
### Dependency updates
1617

acceptance/bundle/deploy/mlops-stacks/out.test.toml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
Cloud=true
2-
Local=false
2+
Local=true
33

44
Badness = "the newly initialized bundle from the 'mlops-stacks' template contains two validation warnings in the configuration"
55

66
Ignore = [
77
"config.json"
88
]
99

10-
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform"]
11-
# On direct, this fails with
12-
# +Endpoint: PUT [DATABRICKS_URL]/api/2.0/permissions/registered-models/%5Bdev%20[USERNAME]%5D%20dev-project_name_[UNIQUE_NAME]-model
13-
# +HTTP Status: 400 Bad Request
14-
# +API error_code: INVALID_PARAMETER_VALUE
15-
# +API message: '[dev [USERNAME]] dev-project_name_[UNIQUE_NAME]-model' is not a valid registered model ID.
16-
17-
1810
[[Repls]]
1911
Old = "aws|azure|gcp"
2012
New = "[CLOUD_ENV_BASE]"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
bundle:
2+
name: test-bundle-$UNIQUE_NAME
3+
4+
resources:
5+
models:
6+
foo:
7+
name: test-model-$UNIQUE_NAME
8+
permissions:
9+
- level: CAN_READ
10+
group_name: users

acceptance/bundle/invariant/continue_293/out.test.toml

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

acceptance/bundle/invariant/migrate/out.test.toml

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

acceptance/bundle/invariant/no_drift/out.test.toml

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

acceptance/bundle/invariant/test.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ EnvMatrix.INPUT_CONFIG = [
3838
"job_with_permissions.yml.tmpl",
3939
"job_with_task.yml.tmpl",
4040
"model.yml.tmpl",
41+
"model_with_permissions.yml.tmpl",
4142
"model_serving_endpoint.yml.tmpl",
4243
"pipeline.yml.tmpl",
4344
"postgres_branch.yml.tmpl",

acceptance/bundle/refschema/out.fields.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,6 +2105,7 @@ resources.models.*.latest_versions[*].user_id string REMOTE
21052105
resources.models.*.latest_versions[*].version string REMOTE
21062106
resources.models.*.lifecycle resources.Lifecycle INPUT
21072107
resources.models.*.lifecycle.prevent_destroy bool INPUT
2108+
resources.models.*.model_id string REMOTE
21082109
resources.models.*.modified_status string INPUT
21092110
resources.models.*.name string ALL
21102111
resources.models.*.permission_level ml.PermissionLevel REMOTE

acceptance/bundle/resources/permissions/models/current_can_manage/out.plan.direct.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"depends_on": [
1515
{
1616
"node": "resources.models.foo",
17-
"label": "${resources.models.foo.id}"
17+
"label": "${resources.models.foo.model_id}"
1818
}
1919
],
2020
"action": "create",
@@ -41,7 +41,7 @@
4141
]
4242
},
4343
"vars": {
44-
"object_id": "/registered-models/${resources.models.foo.id}"
44+
"object_id": "/registered-models/${resources.models.foo.model_id}"
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)