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

Handle notfound error #1063

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import List

from databricks.sdk.service.catalog import PermissionsList, PrivilegeAssignment, SecurableType
Expand All @@ -6,6 +7,8 @@
from databricks_cdk.resources.permissions.changes import get_permission_changes
from databricks_cdk.utils import CnfResponse, get_workspace_client

logger = logging.getLogger(__name__)


class VolumePermissionsProperties(BaseModel):
workspace_url: str
Expand All @@ -17,7 +20,7 @@ def create_or_update_volume_permissions(
properties: VolumePermissionsProperties,
) -> CnfResponse:
"""Create volume permissions on volume at databricks"""

logger.info(f"Creating volume permissions {properties.privilege_assignments} for volume {properties.volume_name}")
workspace_client = get_workspace_client(properties.workspace_url)
existing_grants: PermissionsList = workspace_client.grants.get(
securable_type=SecurableType.VOLUME, full_name=properties.volume_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import logging
from typing import Optional

from databricks.sdk import WorkspaceClient
from databricks.sdk.errors import NotFound
from databricks.sdk.service.catalog import VolumeInfo, VolumeType
from pydantic import BaseModel

from databricks_cdk.utils import CnfResponse, get_workspace_client

logger = logging.getLogger(__name__)


class VolumeCreationError(Exception):
pass
Expand Down Expand Up @@ -99,5 +103,9 @@ def update_volume(
def delete_volume(properties: VolumeProperties, physical_resource_id: str) -> CnfResponse:
"""Delete a volume on databricks"""
workspace_client = get_workspace_client(properties.workspace_url)
workspace_client.volumes.delete(full_name_arg=properties.volume.full_name)
try:
workspace_client.volumes.delete(full_name_arg=properties.volume.full_name)
except NotFound:
logger.warning("Volume not found, never existed or already removed")

return CnfResponse(physical_resource_id=physical_resource_id)
Loading