Skip to content

Fixed bundle deploy to not update permissions for unbound resources - #3642

Merged
andrewnester merged 10 commits into
mainfrom
fix/unbind-permissions
Sep 24, 2025
Merged

Fixed bundle deploy to not update permissions for unbound resources#3642
andrewnester merged 10 commits into
mainfrom
fix/unbind-permissions

Conversation

@andrewnester

@andrewnesterandrewnester commented Sep 22, 2025

Copy link
Copy Markdown
Contributor

Changes

Fixed bundle deploy to not update permissions for unbound resources

Why

The original issue occurred because we hadn't removed the permissions section for the corresponding resources from the TF state. and therefore, permissions were continued to be managed by TF and, as a result, cleared out.

Tests

Added an acceptance test

}

s.Jobs[jobId] = jobs.Job{JobId: jobId, Settings: &jobSettings}
s.Jobs[jobId] = jobs.Job{JobId: jobId, Settings: &jobSettings, CreatorUserName: TestUser.UserName}

@andrewnesterandrewnesterSep 22, 2025

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.

CreatorUserName field is used by TF to check if the resource exists or not. CreatorUserName should be non-empty for the resource to be considered as "exists"

https://github.com/databricks/terraform-provider-databricks/blob/main/permissions/permission_definitions.go#L108

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.

Useful context, please include as a comment to persist it.

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Sep 22, 2025

Copy link
Copy Markdown
Collaborator

Run: 17972827773

Env✅​pass🙈​skip
✅​aws linux312530
✅​aws windows313529
✅​aws-ucws linux425427
✅​aws-ucws windows426426
✅​azure linux312529
✅​azure windows313528
✅​azure-ucws linux425426
✅​azure-ucws windows426425
✅​gcp linux311531
✅​gcp windows312530

@shreyas-goenkashreyas-goenka left a comment

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.

This PR fixes the issue for all resource types right? Can we fix that in the PR title?

Comment threadacceptance/bundle/deployment/unbind/permissions/output.txt
Comment threadacceptance/bundle/deployment/unbind/permissions/test.toml Outdated
Comment threadbundle/deploy/terraform/unbind.go Outdated
@andrewnesterandrewnester changed the title Fixed bundle deploy to not update permissions for unbound jobsFixed bundle deploy to not update permissions for unbound resourcesSep 23, 2025
Comment threadacceptance/bundle/deploy/experimental-python/output.txt
Comment threadacceptance/bundle/deployment/unbind/grants/script
Comment threadacceptance/bundle/deployment/unbind/permissions/script
Comment threadacceptance/bundle/deployment/unbind/permissions/test.toml Outdated
Comment threadbundle/deploy/terraform/unbind.go
Comment threadlibs/testserver/fake_workspace.go Outdated
Comment threadlibs/testserver/fake_workspace.go Outdated
}

s.Jobs[jobId] = jobs.Job{JobId: jobId, Settings: &jobSettings}
s.Jobs[jobId] = jobs.Job{JobId: jobId, Settings: &jobSettings, CreatorUserName: TestUser.UserName}

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.

Useful context, please include as a comment to persist it.

Comment threadNEXT_CHANGELOG.md Outdated

@pieternpietern left a comment

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 you confirm if the acceptance test fails if unbind doesn't remove the permissions from the state? The permissions for the first and second resources are identical, and the resource key in the state is identical as well.

Monitors map[string]catalog.MonitorInfo
Apps map[string]apps.App
Schemas map[string]catalog.SchemaInfo
SchemasGrants map[string][]catalog.PrivilegeAssignment

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.

Nit: should also be singular, SchemaGrants, as in "grants for a schema".

@andrewnester

Copy link
Copy Markdown
ContributorAuthor

@pietern yes, I wrote the acceptance test with this failure first and confirmed that removing the fix makes the test fail

=== NAME TestAccept/bundle/deployment/unbind/permissions
acceptance_test.go:803: Diff:
--- bundle/deployment/unbind/permissions/output.txt
+++ /var/folders/nt/xjv68qzs45319w4k36dhpylc0000gp/T/TestAcceptbundledeploymentunbindpermissions1723835858/001/output.txt
@@ -29,15 +29,6 @@
=== Permissions should be the same as before unbind
>>> [CLI] jobs get-permissions [NUMID] --output json
-{
- "all_permissions": [
- {
- "inherited": false,
- "permission_level": "CAN_MANAGE"
- }
- ],
- "group_name": "users"
-}
 === Grants should be the same as before unbind
>>> [CLI] grants get schema main.test-schema-[UNIQUE_NAME] --output json
-{
- "principal": "account users",
- "privileges": [
- "CREATE_VOLUME",
- "SELECT"
- ]
-}
+jq: error (at <stdin>:1): Cannot iterate over null (null)

@andrewnester
andrewnester added this pull request to the merge queueSep 24, 2025
Merged via the queue into main with commit 4291bccSep 24, 2025
13 checks passed
@andrewnester
andrewnester deleted the fix/unbind-permissions branch September 24, 2025 11:37
deco-sdk-taggingBot added a commit that referenced this pull request Sep 24, 2025
## Release v0.270.0
### Notable Changes
* Add 'databricks bundle plan' command. This command shows the deployment plan for the current bundle configuration without making any changes. ([#3530](#3530))
### Bundles
* Add 'databricks bundle plan' command ([#3530](#3530))
* Add new Lakeflow Pipelines support for bundle generate ([#3568](#3568))
* Fix bundle deploy to not update permissions or grants for unbound resources ([#3642](#3642))
* Introduce new bundle variable: `${workspace.current_user.domain_friendly_name}` ([#3623](#3623))
* Improve the output of bundle run when bundle is not deployed ([#3652](#3652))
denik pushed a commit that referenced this pull request May 20, 2026
…3642)
## Changes
Fixed bundle deploy to not update permissions for unbound resources
## Why
The original issue occurred because we hadn't removed the permissions
section for the corresponding resources from the TF state. and
therefore, permissions were continued to be managed by TF and, as a
result, cleared out.
## Tests
Added an acceptance test
<!-- If your PR needs to be included in the release notes for next
release,
add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
denik pushed a commit that referenced this pull request May 20, 2026
## Release v0.270.0
### Notable Changes
* Add 'databricks bundle plan' command. This command shows the deployment plan for the current bundle configuration without making any changes. ([#3530](#3530))
### Bundles
* Add 'databricks bundle plan' command ([#3530](#3530))
* Add new Lakeflow Pipelines support for bundle generate ([#3568](#3568))
* Fix bundle deploy to not update permissions or grants for unbound resources ([#3642](#3642))
* Introduce new bundle variable: `${workspace.current_user.domain_friendly_name}` ([#3623](#3623))
* Improve the output of bundle run when bundle is not deployed ([#3652](#3652))
Sign up for freeto 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.

4 participants

@andrewnester@eng-dev-ecosystem-bot@pietern@shreyas-goenka