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

NAS-133766 / 25.04 / Improve validation for virt volumes #15474

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

Qubad786
Copy link
Contributor

Context

We improve validation when creating/importing virt volumes here so that we can raise errors in a meaningful way.

@Qubad786 Qubad786 added the jira label Jan 24, 2025
@Qubad786 Qubad786 requested a review from a team January 24, 2025 07:58
@bugclerk
Copy link
Contributor

@bugclerk bugclerk changed the title Improve validation for virt volumes NAS-133766 / 25.04 / Improve validation for virt volumes Jan 24, 2025
@bugclerk
Copy link
Contributor

@Qubad786 Qubad786 merged commit 348bff7 into master Jan 24, 2025
2 checks passed
@Qubad786 Qubad786 deleted the mrehan/iso-import-validatoin branch January 24, 2025 10:22
@bugclerk
Copy link
Contributor

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Jan 24, 2025
@@ -46,6 +48,11 @@ async def query(self, filters, options):
async def do_create(self, data):
await self.middleware.call('virt.global.check_initialized')

verrors = ValidationErrors()
if await self.middleware.call('virt.volume.query', [['id', '=', data['name']]]):
verrors.add('virt_volume_create.name', 'Volume with this name already exists')
Copy link
Contributor

Choose a reason for hiding this comment

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

Just import ValidationError and raise it here instead of creating a verrors object

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants