engine/schema: fix new systemvm template is not registered during upgrade if hypervisor is not KVM#12952
Conversation
…rade if hypervisor is not KVM
|
@blueorangutan package |
|
@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 17343 |
|
@blueorangutan package |
|
@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
| new Pair<>(Hypervisor.HypervisorType.XenServer, CPU.CPUArch.getDefault()), | ||
| new Pair<>(Hypervisor.HypervisorType.Hyperv, CPU.CPUArch.getDefault()), | ||
| new Pair<>(Hypervisor.HypervisorType.LXC, CPU.CPUArch.getDefault()), | ||
| new Pair<>(Hypervisor.HypervisorType.Ovm3, CPU.CPUArch.getDefault()) |
There was a problem hiding this comment.
@weizhouapache when arch type is null, it's defaulted to amd64, is null arch issue here?
There was a problem hiding this comment.
also, make note of the changes in the below PR in main (no need of forward merging the changes here to main)
There was a problem hiding this comment.
@sureshanaparti
in another place
the arch of MetadataTemplateDetails is from hypervisorType, which is null for non-KVM
NewTemplateMap.put(key, new MetadataTemplateDetails(
hypervisorType.first(),
section.get("templatename"),
section.get("filename"),
section.get("downloadurl"),
section.get("checksum"),
hypervisorType.second(),
section.get("guestos")));
but in hypervisorsInUse, the arch is amd64/x86_64 (default arch of clusters)
cluster arch
mysql> SELECT DISTINCT hypervisor_type,arch from cluster;
+-----------------+--------+
| hypervisor_type | arch |
+-----------------+--------+
| VMware | x86_64 |
+-----------------+--------+
1 row in set (0.00 sec)
so the check always return false (line 1034)
There was a problem hiding this comment.
also, make note of the changes in the below PR in main (no need of forward merging the changes here to main)
good point @sureshanaparti
so the issue should not appear in 4.22, great
There was a problem hiding this comment.
ok @weizhouapache, how about replacing hypervisorType.second() == null ? CPU.CPUArch.amd64.getType() : hypervisorType.second().getType() at
maybe, move it to method and use the call same method here and in getHypervisorArchKey()
private String getCPUArchType(CPU.CPUArch arch) {
if (arch == null) {
return CPU.CPUArch.amd64.getType();
}
return arch.getType();
}
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.20 #12952 +/- ##
=========================================
Coverage 16.26% 16.26%
- Complexity 13433 13434 +1
=========================================
Files 5665 5665
Lines 500530 500530
Branches 60787 60787
=========================================
+ Hits 81395 81417 +22
+ Misses 410044 410021 -23
- Partials 9091 9092 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17344 |
|
@blueorangutan test |
|
@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-15809)
|
There was a problem hiding this comment.
MS Oracle Linux 8 Hypervisor VMware7:
Pre-upgrade template: systemvmtemplate-4.20.0-x86_64-vmware.ova
Post-upgrade Successfully installed log shows 4.20.2 to new directory 202
Secondary storage has new directory 202 with systemvmtemplate-4.20.2 files
DB has new template record systemvm-vmware-4.20.2-x86_64 with 4.20.2 URL
CPVM v-8-VM created from systemvm-vmware-4.20.2-x86_64
SSVM s-9-VM created from systemvm-vmware-4.20.2-x86_64
VR r-15-VM created from systemvm-vmware-4.20.2-x86_64
Directory 8 - systemvmtemplate-4.20.0-x86_64-vmware - initial template, seeded at env build time
Directory 202 - systemvmtemplate-4.20.2-x86_64-vmware - new template registered post-upgrade
[root@sl-nestednfs ~]# tree /acs/secondary/ref-trl-11496-v-Mol8-rositsa-kyuchukova/ref-trl-11496-v-Mol8-rositsa-kyuchukova-sec1/template/tmpl/
/acs/secondary/ref-trl-11496-v-Mol8-rositsa-kyuchukova/ref-trl-11496-v-Mol8-rositsa-kyuchukova-sec1/template/tmpl/
└── 1
├── 202
│ ├── 9cd384be-becd-49aa-9673-5399326f2965.ova
│ ├── systemvmtemplate-4.20.2-x86_64-vmware-disk1.vmdk
│ ├── systemvmtemplate-4.20.2-x86_64-vmware.mf
│ ├── systemvmtemplate-4.20.2-x86_64-vmware.ovf
│ └── template.properties
├── 7
│ ├── 0654e777-1660-3d44-a937-431b53f15ed7.ova
│ ├── centos53-x64.ova
│ ├── centos53-x64.ova.meta
│ ├── CentOS5.3-x86_64-disk1.vmdk
│ ├── CentOS5.3-x86_64.mf
│ ├── CentOS5.3-x86_64.ovf
│ ├── CentOS5.3-x86_64.ovf.orig
│ └── template.properties
└── 8
├── f60c4852-dd50-4251-afdd-ecef5a8c251f.ova
├── systemvmtemplate-4.20.0-x86_64-vmware-disk1.vmdk
├── systemvmtemplate-4.20.0-x86_64-vmware.mf
├── systemvmtemplate-4.20.0-x86_64-vmware.ovf
└── template.properties
4 directories, 18 files
DB results:
mysql> SELECT t.name, t.url, ts.state, ts.download_state, ts.download_pct FROM vm_template t JOIN template_store_ref ts ON t.id = ts.template_id WHERE t.type='SYSTEM' AND t.removed IS NULL AND ts.destroyed=0;
+-------------------------------+-----------------------------------------------------------------------------------------+-------+----------------+--------------+
| name | url | state | download_state | download_pct |
+-------------------------------+-----------------------------------------------------------------------------------------+-------+----------------+--------------+
| SystemVM Template (vSphere) | https://download.cloudstack.org/systemvm/4.20/systemvmtemplate-4.20.0-x86_64-vmware.ova | Ready | DOWNLOADED | 100 |
| systemvm-vmware-4.20.2-x86_64 | https://download.cloudstack.org/systemvm/4.20/systemvmtemplate-4.20.2-x86_64-vmware.ova | Ready | DOWNLOADED | 100 |
+-------------------------------+-----------------------------------------------------------------------------------------+-------+----------------+--------------+
2 rows in set (0.00 sec)
-
SSVMs (recreated post-upgrade):
-
v-8-VM (CPVM)- systemvm-vmware-4.20.2-x86_64 -
s-9-VM (SSVM)- systemvm-vmware-4.20.2-x86_64 -
VR (created post-upgrade):
r-15-VM - systemvm-vmware-4.20.2-x86_64
All three are using the new 4.20.2 template. The fix works correctly - new template registered, new template record created in DB, and all System VMs are being deployed from it.
mysql> SELECT vi.name, vi.type, vi.created, t.name as template_name, t.url
-> FROM vm_instance vi
-> JOIN vm_template t ON vi.vm_template_id = t.id
-> WHERE vi.type IN ('ConsoleProxy', 'SecondaryStorageVm') AND vi.state = 'Running';
+--------+--------------------+---------------------+-------------------------------+-----------------------------------------------------------------------------------------+
| name | type | created | template_name | url |
+--------+--------------------+---------------------+-------------------------------+-----------------------------------------------------------------------------------------+
| v-8-VM | ConsoleProxy | 2026-04-05 16:57:07 | systemvm-vmware-4.20.2-x86_64 | https://download.cloudstack.org/systemvm/4.20/systemvmtemplate-4.20.2-x86_64-vmware.ova |
| s-9-VM | SecondaryStorageVm | 2026-04-05 16:57:07 | systemvm-vmware-4.20.2-x86_64 | https://download.cloudstack.org/systemvm/4.20/systemvmtemplate-4.20.2-x86_64-vmware.ova |
+--------+--------------------+---------------------+-------------------------------+-----------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> SELECT vi.name, vi.type, vi.created, t.name as template_name, t.url
-> FROM vm_instance vi
-> JOIN vm_template t ON vi.vm_template_id = t.id
-> WHERE vi.type = 'DomainRouter' AND vi.state = 'Running';
+---------+--------------+---------------------+-------------------------------+-----------------------------------------------------------------------------------------+
| name | type | created | template_name | url |
+---------+--------------+---------------------+-------------------------------+-----------------------------------------------------------------------------------------+
| r-15-VM | DomainRouter | 2026-04-06 03:53:23 | systemvm-vmware-4.20.2-x86_64 | https://download.cloudstack.org/systemvm/4.20/systemvmtemplate-4.20.2-x86_64-vmware.ova |
+---------+--------------+---------------------+-------------------------------+-----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Results from MS logs:
[root@ref-trl-11496-v-Mol8-rositsa-kyuchukova-mgmt1 ~]# zgrep "Successfully installed system VM template" /var/log/cloudstack/management/management-server.log.2026-04-05.gz
+ echo 'Successfully installed system VM template /usr/share/cloudstack-management/templates/systemvm/systemvmtemplate-4.20.2-x86_64-vmware.ova and template.properties to /tmp/tmp4879423099328784851/template/tmpl/1/202'
Successfully installed system VM template /usr/share/cloudstack-management/templates/systemvm/systemvmtemplate-4.20.2-x86_64-vmware.ova and template.properties to /tmp/tmp4879423099328784851/template/tmpl/1/202
|
@weizhouapache @sureshanaparti |
minor refactor pending, we can deal with it later. all good @abh1sar |
Description
This PR fixes the issue that the new systemvm template is not registered for non-KVM hypervisor types
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?