Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Fix deletion of dashboard if it was trashed out of band #4235

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

pietern
Copy link
Contributor

@pietern pietern commented Nov 15, 2024

Changes

If a dashboard created by TF was trashed out of band, it could no longer be deleted by TF.

Example TF configuration:

terraform {
  required_providers {
    databricks = {
      source = "databricks/databricks"
      version = "1.58.0"
    }
  }
}

data "databricks_current_user" "me" {
  // This data source is used to get the current user's username
}

resource "databricks_dashboard" "this" {
  display_name = "Terraform test"
  parent_path = "/Workspace/Users/${data.databricks_current_user.me.user_name}/tf-dashboard-oob-deletion"
  warehouse_id = "58aa1b363649e722"
  serialized_dashboard = file("nyc_taxi_trip_analysis.lvdash.json")
}

If you apply this, and then run:

databricks lakeview trash <dashboard id>

The subsequent apply would error out with:

Error: cannot delete dashboard: dashboard [01efa39479a1128aae017018e434a747] lifecycle state [TRASHED] is not among the accepted states [Set(ACTIVE)]

It turns out trashing an already trashed dashboard returns an error.

This change guards against this condition returns success if the underlying dashboard has already been trashed.

Tests

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • relevant acceptance tests are passing
  • using Go SDK

@pietern pietern requested review from a team as code owners November 15, 2024 21:04
@pietern pietern requested review from parthban-db and removed request for a team November 15, 2024 21:04
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/terraform

Inputs:

  • PR number: 4235
  • Commit SHA: 16503fc763686a0e86e0ace80c365f9e6c2a8534

Checks will be approved automatically on success.

@eng-dev-ecosystem-bot
Copy link
Collaborator

Test Details: go/deco-tests/11863430999

@pietern pietern changed the title Fix deletion of dashboard if it was trashed out of band [Fix] Fix deletion of dashboard if it was trashed out of band Nov 15, 2024
// If the dashboard was already trashed, we'll get a 403 (Permission Denied) error.
// There may be other cases where we get a 403, so we first confirm that the
// dashboard state is actually trashed, and if so, return success.
if errors.Is(err, apierr.ErrPermissionDenied) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR. Curious -- should we also check for 404 or if a dashboard is trashed already then the only response is 403? Mentioning since the api doc https://docs.databricks.com/api/workspace/lakeview/trash has 404 as one of the responses.

@pietern pietern added this pull request to the merge queue Nov 16, 2024
Merged via the queue into main with commit 27ff289 Nov 16, 2024
14 of 16 checks passed
@pietern pietern deleted the dashboard-trash-delete branch November 16, 2024 00:08
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.

3 participants