Skip to content

Add per-resource permissions support to cluster_policies - #6304

Open
Sankalp-Mittal wants to merge 5 commits into
sankalp-mittal/cluster-policy-resourcefrom
sankalp-mittal/cluster-policy-permissions
Open

Add per-resource permissions support to cluster_policies#6304
Sankalp-Mittal wants to merge 5 commits into
sankalp-mittal/cluster-policy-resourcefrom
sankalp-mittal/cluster-policy-permissions

Conversation

@Sankalp-Mittal

@Sankalp-Mittal Sankalp-Mittal commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #6225 (cluster policy resource). Adds the per-resource permissions field to cluster_policies so a policy can grant access via the direct engine's generic permissions applier.

Cluster policies support a single ACL level — CAN_USE (SDK compute.ClusterPolicyPermissionLevel), meaning "may create clusters governed by this policy." There is no CAN_MANAGE/CAN_VIEW/CAN_RUN; policy administration is an admin-only function.

resources:
  cluster_policies:
    my_policy:
      name: my-policy
      permissions:
        - level: CAN_USE
          group_name: users

Changes

  • Resource wiring: declare ClusterPolicyPermission, add the Permissions field, register cluster_policies.permissions in the direct engine, and map the permissions-API object type to /cluster-policies/.
  • FixPermissions: add cluster_policies to ignoredResources so the deploying user is not auto-injected as CAN_MANAGE/IS_OWNER — cluster policies can't accept it, and the real backend would reject the deploy (same treatment as secret_scopes).
  • Testserver: model the real API — a non-CAN_USE level on a cluster policy returns 400, so local and cloud runs agree.
  • Generated files: regenerated schema, refschema field list, and validation (level enum = CAN_USE only, level required).

Design note

cluster_policies is intentionally not added to the top-level levelsMap; it stays in unsupportedResources. The bundle-wide permissions: block is expressed in CAN_MANAGE/CAN_VIEW/CAN_RUN (and auto-grants the deployer CAN_MANAGE), none of which a cluster policy can accept. Supporting only the explicit per-resource form avoids silently dropping those grants. Two current-user injection paths had to be handled for this: the top-level levelsMap and the FixPermissions mutator.

Testing

Acceptance tests under acceptance/bundle/resources/cluster_policies/permissions/:

  • basic/ — deploy applies the CAN_USE grants, redeploy updates the ACL; requests asserted with print_requests.py.
  • out_of_band_change/ — an out-of-band ACL change is detected by bundle plan and reconciled on redeploy.
  • levels/ (Cloud=true) — CAN_USE deploys successfully; a direct CAN_MANAGE set-permissions call is rejected (asserted with musterr; the backend error differs between the fake and cloud, so it is routed to a LOG file rather than pinned).

Plus the cluster_policies.permissions CRUD roundtrip fixture in dresources/all_test.go. Unit + acceptance suites pass locally.

This pull request and its description were written by Isaac.

Cluster policies support a single ACL level, CAN_USE (SDK
compute.ClusterPolicyPermissionLevel). Wire up the per-resource
`permissions` field so a policy can grant CAN_USE to users, groups, and
service principals via the direct engine's generic permissions applier:

- Declare the ClusterPolicyPermission type and add the Permissions field.
- Register cluster_policies.permissions in the direct engine and map the
  permissions-API object type to /cluster-policies/.
- Regenerate the bundle JSON schema and fill in the field descriptions.

cluster_policies is intentionally left out of the top-level levelsMap
(it stays in unsupportedResources): the bundle-wide permissions block is
expressed in CAN_MANAGE/CAN_VIEW/CAN_RUN, none of which a cluster policy
can accept, so only the explicit per-resource form is supported.

Co-authored-by: Isaac
Add basic and out_of_band_change acceptance tests for the cluster_policies
`permissions` field, filtering permission requests with print_requests.py.

The basic test surfaced that FixPermissions injects the current user as
CAN_MANAGE onto every resource with a permissions field. Cluster policies
only accept CAN_USE, so the real backend would reject that. Add
cluster_policies to fix_permissions.go's ignoredResources (like
secret_scopes) so only the user-specified CAN_USE grants are sent.

Co-authored-by: Isaac
Add a Cloud=true test that deploys a policy with CAN_USE (accepted) and
then asserts a direct CAN_MANAGE set-permissions call is rejected.

Model the rejection in the testserver: the permissions API only accepts
CAN_USE for cluster policies, so a non-CAN_USE level returns 400. This
keeps the local run and the cloud run in agreement. The backend error
text differs between the fake and a real workspace, so it is routed to a
LOG file and musterr asserts only that the request fails.

Co-authored-by: Isaac
Runs generate-check output: the refschema field list, the level enum
(CAN_USE only), and the required-field entry for the new cluster_policies
permissions block.

Co-authored-by: Isaac
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 504c16d

Run: 32132459409

Env 🟨​KNOWN 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
🟨​ aws linux 3 2 3 304 1438 11:55
🟨​ aws windows 3 1 2 3 305 1436 11:04
🟨​ azure linux 3 2 3 303 1438 9:37
🟨​ azure windows 3 2 3 305 1436 12:09
💚​ gcp linux 2 4 304 1438 8:28
💚​ gcp windows 2 4 306 1436 10:06
9 interesting tests: 3 SKIP, 3 KNOWN, 2 RECOVERED, 1 flaky
Test Name aws linux aws windows azure linux azure windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/invariant/no_drift 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestSyncNestedFolderSync ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p
🟨​ TestFetchRepositoryInfoAPI_FromRepo 🟨​K 🟨​K 🟨​K 🟨​K 🙈​S 🙈​S
🟨​ TestFetchRepositoryInfoAPI_FromRepo/root 🟨​K 🟨​K 🟨​K 🟨​K
🟨​ TestFetchRepositoryInfoAPI_FromRepo/subdir 🟨​K 🟨​K 🟨​K 🟨​K
Top 8 slowest tests (at least 2 minutes):
duration env testname
7:10 gcp windows TestAccept
5:32 azure windows TestAccept
5:25 aws windows TestAccept
3:54 azure linux TestAccept
3:50 gcp linux TestAccept
3:48 aws linux TestAccept
2:37 azure windows TestAccept/bundle/invariant/delete_idempotent/DATABRICKS_BUNDLE_ENGINE=direct/INPUT_CONFIG=cluster_policy.yml.tmpl/READPLAN=
2:21 azure windows TestAccept/bundle/invariant/delete_idempotent/DATABRICKS_BUNDLE_ENGINE=direct/INPUT_CONFIG=cluster_policy.yml.tmpl/READPLAN=1

TestInvariantConfigsCoverage requires every resource with a permissions
field to have an invariant config exercising it. Attach a CAN_USE grant
to the cluster_policies invariant config.

Co-authored-by: Isaac
@Sankalp-Mittal
Sankalp-Mittal marked this pull request as ready for review August 18, 2026 13:45
@github-actions

Copy link
Copy Markdown
Contributor

Approval status: pending

/acceptance/bundle/ - needs approval

17 files changed
Suggested: @janniklasrose
Also eligible: @pietern, @denik, @andrewnester, @shreyas-goenka, @anton-107, @lennartkats-db

/bundle/ - needs approval

10 files changed
Suggested: @janniklasrose
Also eligible: @pietern, @denik, @andrewnester, @shreyas-goenka, @anton-107, @lennartkats-db

General files (require maintainer)

Files: libs/testserver/permissions.go
Based on git history:

  • @janniklasrose -- recent work in bundle/internal/validation/generated/, bundle/schema/, bundle/direct/dresources/

Any maintainer (@andrewnester, @anton-107, @denik, @pietern, @shreyas-goenka, @simonfaltum, @renaudhartert-db, @janniklasrose, @lennartkats-db, @rugpanov, @rclarey) can approve all areas.
See OWNERS for ownership rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants