Skip to content

Commit

Permalink
CSI-5774: When volume is not mapped to a host, allow the unmap to fail (
Browse files Browse the repository at this point in the history
#756)

Signed-off-by: Shlomit Neufeld <[email protected]>
  • Loading branch information
shlomitn authored Jan 12, 2025
1 parent ba4582c commit 127df08
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions controllers/array_action/array_mediator_svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,8 +1220,10 @@ def unmap_volume(self, volume_id, host_name):
if OBJ_NOT_FOUND in ex.my_message:
raise array_errors.ObjectNotFoundError(volume_name)
if VOL_ALREADY_UNMAPPED in ex.my_message:
raise array_errors.VolumeAlreadyUnmappedError(
volume_name)
raise array_errors.VolumeAlreadyUnmappedError(volume_name)
if SPECIFIED_OBJ_NOT_EXIST in ex.my_message:
# host isn't in the volume's mappings
raise array_errors.VolumeNotMappedToHostError(volume_name, host_name)
raise array_errors.UnmappingError(volume_name,
host_name, ex)

Expand Down
5 changes: 5 additions & 0 deletions controllers/array_action/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ def __init__(self, volume_id_or_name):
super().__init__()
self.message = messages.VOLUME_ALREADY_UNMAPPED_MESSAGE.format(volume_id_or_name)

class VolumeNotMappedToHostError(BaseArrayActionException):

def __init__(self, volume_id_or_name, host):
super().__init__()
self.message = messages.VOLUME_NOT_MAPPED_TO_HOST_MESSAGE.format(volume_id_or_name, host)

class UnmappingError(BaseArrayActionException):

Expand Down
2 changes: 2 additions & 0 deletions controllers/array_action/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

VOLUME_ALREADY_UNMAPPED_MESSAGE = "Volume: {0} is already unmapped."

VOLUME_NOT_MAPPED_TO_HOST_MESSAGE = "Volume {0} is not mapped to host {1}"

UNMAPPING_ERROR_MESSAGE = "Unmapping error has occurred for volume : {0} and host : {1}. error : {2}"

VOLUME_ALREADY_MAPPED_TO_DIFFERENT_HOSTS_ERROR_MESSAGE = "Volume is already mapped to different hosts {0}"
Expand Down
2 changes: 2 additions & 0 deletions controllers/servers/csi/csi_controller_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ def ControllerUnpublishVolume(self, request, context):
logger.debug("Idempotent case. volume is already unmapped.")
except array_errors.ObjectNotFoundError:
logger.debug("Idempotent case. volume is already deleted.")
except array_errors.VolumeNotMappedToHostError:
logger.debug("Idempotent case. volume is not mapped to host.")
return csi_pb2.ControllerUnpublishVolumeResponse()

@csi_method(error_response_type=csi_pb2.ValidateVolumeCapabilitiesResponse, lock_request_attribute="volume_id")
Expand Down

0 comments on commit 127df08

Please sign in to comment.