Skip to content

Support IS_OWNER as a top-level permission - #1387

Closed
lennartkats-db wants to merge 12 commits into
databricks:mainfrom
lennartkats-db:cp-support-owners
Closed

Support IS_OWNER as a top-level permission#1387
lennartkats-db wants to merge 12 commits into
databricks:mainfrom
lennartkats-db:cp-support-owners

Conversation

@lennartkats-db

@lennartkats-dblennartkats-db commented Apr 22, 2024

Copy link
Copy Markdown
Contributor

Changes

This adds a top-level IS_OWNER permission to help with collaborative deployment scenarios:

  • IS_OWNER is now accepted at the top level
  • Templates now include a top-level owner
  • Validation for mode: production now accepts a top-level owner as an alternative to a run_as identity.

Tests

Unit tests, manual experimentation.

@codecov-commenter

codecov-commenter commented Apr 22, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 98.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 53.63%. Comparing base (e22dd8a) to head (e4df0b9).
Report is 125 commits behind head on main.

FilesPatch %Lines
bundle/permissions/apply_resource_permissions.go96.77%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #1387 +/- ##
==========================================
+ Coverage 52.25% 53.63% +1.37% 
==========================================
Files 317 351 +34 Lines 18004 20290 +2286 ==========================================
+ Hits 9408 10882 +1474 - Misses 7903 8610 +707 - Partials 693 798 +105 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment threadbundle/config/mutator/run_as_test.go Outdated
Comment threadbundle/permissions/apply_folder_permissions.go Outdated
return diag.Errorf("'run_as' must be set for all jobs when using 'mode: production'")
// We need to verify that there is only a single deployment of the current target.
// A good way to enforce this is to explicitly set root_path or run_as.
if !isExplicitRootSet(b) && !isRunAsSet(r) {

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to require

run_as: alice@company.com

but when considering collaborative deployment, we prefer

root_path: /Users/Alice

This change makes it so either restriction is allowed for mode: production.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also warn if only run_as is set? It doesn't prevent multiple deployments.

// Only show a warning in case a principal was used for backward compatibility
// with projects from before the DABs GA.
if isPrincipalUsed {
return diag.Warningf("target with 'mode: production' should specify explicit 'workspace.root_path' to make sure only one copy is deployed")

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service principals still have an exception, like they used to.

var allowedLevels = []string{CAN_MANAGE, CAN_VIEW, CAN_RUN, IS_OWNER}
var levelsMap = map[string](map[string]string){
"jobs": {
IS_OWNER: "IS_OWNER",

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a few resources, like jobs, actually have an "owner": https://docs.databricks.com/en/security/auth-authz/access-control/index.html. For almost all the others we don't distinguish between the owner and the other can-manage users.

Note that clusters is a special case here. They don't have an owner permission but treat the creator as a kind of owner that has special privileges. There's even a special API for changing that notion of "owner": https://docs.databricks.com/api/workspace/clusters/changeowner. Once we do clusters we should discuss if we want this notion of an owner to affect how clusters are created, or if we perhaps want to show a warning when someone who doesn't have IS_OWNER would be the first creator of a cluster.

@lennartkats-dblennartkats-db changed the title [WIP] Support IS_OWNER as a top-level permissionSupport IS_OWNER as a top-level permissionJun 3, 2024
@lennartkats-db

Copy link
Copy Markdown
ContributorAuthor

@pietern could you take another look?

return diag.Errorf("'run_as' must be set for all jobs when using 'mode: production'")
// We need to verify that there is only a single deployment of the current target.
// A good way to enforce this is to explicitly set root_path or run_as.
if !isExplicitRootSet(b) && !isRunAsSet(r) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also warn if only run_as is set? It doesn't prevent multiple deployments.

Comment threadbundle/config/mutator/select_target.go
return &workspaceRootPermissions{}
func ApplyFolderPermissions() bundle.Mutator {
return &applyFolderPermissions{}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the rename? The mutator still applies only to the workspace root path.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mutator still applies only to the workspace root path.

That seems like a bug :(

In any case I renamed this so apply_folder_permisions to make it a bit shorter and to reflect that it applies permissions to folders, while its sister mutator apply_resource_permissions applies permissions to resources.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw I don't think we should change the semantics of this module at this time, but we should include this in the upcoming work on permission warnings.

Comment threadbundle/config/mutator/run_as.go Outdated
Comment threadbundle/permissions/apply_resource_permissions.go Outdated
@pietern

Copy link
Copy Markdown
Contributor

@andrewnester Could you take a look as well?

@lennartkats-db

Copy link
Copy Markdown
ContributorAuthor

Let's have another brief live discussion about this before merging it @pietern

@lennartkats-db

Copy link
Copy Markdown
ContributorAuthor

As discussed, we're going to take this work in a different direction. Closing this for now.

github-merge-queueBot pushed a commit that referenced this pull request Sep 3, 2024
## Changes
This updates the templates to include a `permissions` section. Having a
permissions section is a best practice, is helpful to understand the
notion of permissions, and helps diagnose permission errors
(#1386).
This is a cherry-pick from #1387.
This change was verified to work both in dev and prod. Existing unit
tests validate the validity of the templates in these modes.
github-merge-queueBot pushed a commit that referenced this pull request Jan 13, 2025
…ent (#1712)
## Changes
This updates `mode: production` to allow `root_path` to indicate
uniqueness. Historically, we required `run_as` for this, which isn't
actually very effective for that purpose. `run_as` also had the problem
that it doesn't work for pipelines.
This is a cherry-pick from #1387
---------
Co-authored-by: Pieter Noordhuis <pcnoordhuis@gmail.com>
denik pushed a commit that referenced this pull request May 20, 2026
## Changes
This updates the templates to include a `permissions` section. Having a
permissions section is a best practice, is helpful to understand the
notion of permissions, and helps diagnose permission errors
(#1386).
This is a cherry-pick from #1387.
This change was verified to work both in dev and prod. Existing unit
tests validate the validity of the templates in these modes.
denik pushed a commit that referenced this pull request May 20, 2026
…ent (#1712)
## Changes
This updates `mode: production` to allow `root_path` to indicate
uniqueness. Historically, we required `run_as` for this, which isn't
actually very effective for that purpose. `run_as` also had the problem
that it doesn't work for pipelines.
This is a cherry-pick from #1387
---------
Co-authored-by: Pieter Noordhuis <pcnoordhuis@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@lennartkats-db@codecov-commenter@pietern