-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix duplicate dummy templates, and update guest os for dummy template #12780
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
Changes from 4 commits
cb9cc53
08cf2be
5d88f30
a02e455
026bd09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,3 +33,5 @@ UPDATE `cloud`.`alert` SET type = 34 WHERE name = 'ALERT.VR.PRIVATE.IFACE.MTU'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -- Update configuration 'kvm.ssh.to.agent' description and is_dynamic fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UPDATE `cloud`.`configuration` SET description = 'True if the management server will restart the agent service via SSH into the KVM hosts after or during maintenance operations', is_dynamic = 1 WHERE name = 'kvm.ssh.to.agent'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UPDATE `cloud`.`vm_template` SET guest_os_id = 99 WHERE name = 'kvm-default-vm-import-dummy-template'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UPDATE `cloud`.`vm_template` SET guest_os_id = 99 WHERE name = 'kvm-default-vm-import-dummy-template'; | |
| UPDATE `cloud`.`vm_template` | |
| SET guest_os_id = 99 | |
| WHERE name = 'kvm-default-vm-import-dummy-template' | |
| AND type = 'SYSTEM' | |
| AND format = 'ISO'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine with name
Copilot
AI
Mar 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description shows many duplicate rows for kvm-default-vm-import-dummy-template. This migration updates guest_os_id but does not address the existing duplicates, so the system can continue operating with ambiguous data (and findByName may pick an arbitrary row depending on query ordering). Consider adding a migration step to de-duplicate (e.g., keep a single canonical row and mark others removed/unused) to make behavior deterministic and align with the PR’s stated goal of fixing duplicates.
| UPDATE `cloud`.`vm_template` SET guest_os_id = 99 WHERE name = 'kvm-default-vm-import-dummy-template'; | |
| -- De-duplicate 'kvm-default-vm-import-dummy-template' entries and update guest_os_id | |
| -- Keep the template with the smallest id as the canonical one and mark others as removed | |
| UPDATE `cloud`.`vm_template` t | |
| JOIN ( | |
| SELECT MIN(id) AS keep_id | |
| FROM `cloud`.`vm_template` | |
| WHERE name = 'kvm-default-vm-import-dummy-template' | |
| ) k ON t.id != k.keep_id | |
| SET t.removed = NOW() | |
| WHERE t.name = 'kvm-default-vm-import-dummy-template' | |
| AND t.removed IS NULL; | |
| -- Update guest_os_id only for the canonical template | |
| UPDATE `cloud`.`vm_template` t | |
| JOIN ( | |
| SELECT MIN(id) AS keep_id | |
| FROM `cloud`.`vm_template` | |
| WHERE name = 'kvm-default-vm-import-dummy-template' | |
| AND removed IS NULL | |
| ) k ON t.id = k.keep_id | |
| SET t.guest_os_id = 99; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
Uh oh!
There was an error while loading. Please reload this page.