Skip to content

Conversation

@klmp200
Copy link

@klmp200 klmp200 commented Oct 31, 2025

Check for usage status before deleting a linstor volume and raise an appropriate error if this happens

@klmp200 klmp200 requested review from Nambrok and Wescoeur October 31, 2025 12:02
@klmp200 klmp200 force-pushed the linstor_protect_in_use_volume branch from 2e28b7a to a86786c Compare October 31, 2025 12:05
@klmp200 klmp200 force-pushed the linstor_protect_in_use_volume branch from a86786c to e7af4ae Compare November 6, 2025 16:14
:param: volume_uuid
:rtype: dict
"""
for volume in self.get_resources_info().values():
Copy link
Member

Choose a reason for hiding this comment

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

The cost can be really important. I guess we can extract a few logic of get_resources_info to reduce this expense.

Copy link
Author

Choose a reason for hiding this comment

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

I've introduced some caching mechanism to mitigate this issue :)


raise LinstorVolumeManagerError(
f"Could not find info about volume `{volume_uuid}`",
LinstorVolumeManagerError.ERR_VOLUME_DESTROY
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
LinstorVolumeManagerError.ERR_VOLUME_DESTROY
LinstorVolumeManagerError.ERR_VOLUME_NOT_EXISTS


return resources

def get_resource_info(self, volume_uuid: str) -> Dict:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def get_resource_info(self, volume_uuid: str) -> Dict:
def get_resource_info(self, volume_uuid: str) -> Dict[str, Any]:

Not the best suggestion but meh. :p I think we should try to be explicit even when it's not simple. Of course, within the limits of readability!

@klmp200 klmp200 force-pushed the linstor_protect_in_use_volume branch from e7af4ae to 91916fe Compare November 14, 2025 13:17
@klmp200 klmp200 force-pushed the linstor_protect_in_use_volume branch 4 times, most recently from ae8c064 to 91916fe Compare November 14, 2025 13:59
Fix some typo in docstring

Signed-off-by: Antoine Bartuccio <antoine.bartuccio@vates.tech>
@klmp200 klmp200 force-pushed the linstor_protect_in_use_volume branch from 91916fe to a90db03 Compare November 14, 2025 14:16
Copy link

@Millefeuille42 Millefeuille42 left a comment

Choose a reason for hiding this comment

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

Not blocking. Other than that, LGTM.

Comment on lines 1759 to 1761
Give all resources info with provided uuid on current group name.
:param volume_uuid str: volume uuid to search for
:rtype: dict

Choose a reason for hiding this comment

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

Suggested change
Give all resources info with provided uuid on current group name.
:param volume_uuid str: volume uuid to search for
:rtype: dict
Give all resource info related to provided UUID in the current group.
:param volume_uuid str: volume uuid to search for
:rtype: dict

Copy link
Author

Choose a reason for hiding this comment

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

Done :)
I've also matched the rtype to the type hint ;)

Check for usage status before deleting a linstor volume and raise an appropriate error if this happens

Signed-off-by: Antoine Bartuccio <antoine.bartuccio@vates.tech>
@klmp200 klmp200 force-pushed the linstor_protect_in_use_volume branch from a90db03 to e85e3e9 Compare November 17, 2025 14:24
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.

4 participants