You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "sureshanaparti (via GitHub)" <gi...@apache.org> on 2026/03/10 09:35:07 UTC
[PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
sureshanaparti opened a new pull request, #12780:
URL: https://github.com/apache/cloudstack/pull/12780
### Description
This PR fixes duplicate dummy templates, and updates guest os to "Other Linux (64-bit)", id: 99 for dummy template from existing "CentOS 4.5 (32-bit)", id: 1.
<!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
<!-- For new features, provide link to FS, dev ML discussion etc. -->
<!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
<!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
<!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
<!-- Fixes: # -->
<!--- ******************************************************************************* -->
<!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
<!--- PLEASE PUT AN 'X' in only **ONE** box -->
<!--- ******************************************************************************* -->
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] Build/CI
- [ ] Test (unit or integration test code)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [x] Minor
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [x] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
<!-- Please describe in detail how you tested your changes. -->
<!-- Include details of your testing environment, and the tests you ran to -->
#### How did you try to break this feature and the system with this change?
<!-- see how your change affects other areas of the code, etc. -->
<!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4029970141
@sureshanaparti 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4044260495
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4029953354
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4051244894
<b>[SF] Trillian test result (tid-15619)</b>
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 55921 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12780-t15619-kvm-ol8.zip
Smoke tests completed. 145 look OK, 4 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
ContextSuite context=TestListIdsParams>:teardown | `Error` | 1.15 | test_list_ids_parameter.py
test_01_snapshot_root_disk | `Error` | 5.89 | test_snapshots.py
test_02_list_snapshots_with_removed_data_store | `Error` | 50.87 | test_snapshots.py
test_02_list_snapshots_with_removed_data_store | `Error` | 50.87 | test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardown | `Error` | 31.76 | test_snapshots.py
test_05_stop_ssvm | `Failure` | 92.42 | test_ssvm.py
test_01_snapshot_usage | `Error` | 19.70 | test_usage.py
test_01_vpn_usage | `Error` | 1.10 | test_usage.py
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4037483833
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti merged PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti commented on code in PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#discussion_r2916755117
##########
engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql:
##########
@@ -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';
Review Comment:
not needed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti commented on code in PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#discussion_r2916756339
##########
engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql:
##########
@@ -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';
Review Comment:
fine with name
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4044084125
<b>[LL] Trillian Build Failed (tid-7177)<b/>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4030081352
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/12780?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 3.70%. Comparing base ([`7aa0558`](https://app.codecov.io/gh/apache/cloudstack/commit/7aa0558c5b9127ef1633e151baf60ce7172ceaff?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`08cf2be`](https://app.codecov.io/gh/apache/cloudstack/commit/08cf2be96e905e24425484feb13e5c91fb4d2031?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
> :exclamation: There is a different number of reports uploaded between BASE (7aa0558) and HEAD (08cf2be). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (7aa0558) | HEAD (08cf2be) |
>|------|------|------|
>|unittests|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 4.22 #12780 +/- ##
=============================================
- Coverage 17.61% 3.70% -13.91%
=============================================
Files 5917 448 -5469
Lines 531402 38019 -493383
Branches 64971 7035 -57936
=============================================
- Hits 93596 1409 -92187
+ Misses 427252 36423 -390829
+ Partials 10554 187 -10367
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/12780/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/12780/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `3.70% <ø> (ø)` | |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/12780/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/12780?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "sureshanaparti (via GitHub)" <gi...@apache.org>.
sureshanaparti commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4044690549
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4037487574
@sureshanaparti 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4030548535
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17066
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#discussion_r2910865242
##########
server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java:
##########
@@ -1550,9 +1550,11 @@ private ServiceOfferingVO getServiceOfferingForImportInstance(Long serviceOfferi
protected VMTemplateVO getTemplateForImportInstance(Long templateId, Hypervisor.HypervisorType hypervisorType) {
VMTemplateVO template;
if (templateId == null) {
- template = templateDao.findByName(VM_IMPORT_DEFAULT_TEMPLATE_NAME);
+ boolean isKVMHypervisor = Hypervisor.HypervisorType.KVM.equals(hypervisorType);
+ String templateName = (isKVMHypervisor) ? KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME : VM_IMPORT_DEFAULT_TEMPLATE_NAME;
+ template = templateDao.findByName(templateName);
if (template == null) {
- template = createDefaultDummyVmImportTemplate(Hypervisor.HypervisorType.KVM == hypervisorType);
+ template = createDefaultDummyVmImportTemplate(isKVMHypervisor);
if (template == null) {
throw new InvalidParameterValueException(String.format("Default VM import template with unique name: %s for hypervisor: %s cannot be created. Please use templateid parameter for import", VM_IMPORT_DEFAULT_TEMPLATE_NAME, hypervisorType.toString()));
Review Comment:
The exception message always formats the template name using `VM_IMPORT_DEFAULT_TEMPLATE_NAME`, even though the code now conditionally uses `templateName` (e.g., `KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME` for KVM). This will report the wrong template name for KVM and mislead operators. Use `templateName` in the formatted message (and you can pass `hypervisorType` directly instead of `hypervisorType.toString()`).
```suggestion
throw new InvalidParameterValueException(String.format("Default VM import template with unique name: %s for hypervisor: %s cannot be created. Please use templateid parameter for import", templateName, hypervisorType));
```
##########
server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java:
##########
@@ -326,7 +326,7 @@ private VMTemplateVO createDefaultDummyVmImportTemplate(boolean isKVM) {
try {
template = VMTemplateVO.createSystemIso(templateDao.getNextInSequence(Long.class, "id"), templateName, templateName, true,
"", true, 64, Account.ACCOUNT_ID_SYSTEM, "",
- "VM Import Default Template", false, 1);
+ "VM Import Default Template", false, 99);
Review Comment:
The guest OS id `99` is a magic number here, which makes the intent harder to understand and couples behavior to a specific seeded DB id. Prefer using a named constant (e.g., `OTHER_LINUX_64_GUEST_OS_ID`) or resolving the guest OS id via a DAO lookup by a stable key/name, so this remains readable and robust across variations in guest OS seed data.
##########
engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql:
##########
@@ -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';
Review Comment:
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.
```suggestion
-- 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;
```
##########
engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql:
##########
@@ -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';
Review Comment:
This UPDATE targets rows by `name` only. To reduce the risk of unintentionally modifying non-system templates (or future templates) that happen to share the same name, consider narrowing the predicate (e.g., also filter on `type = 'SYSTEM'` and `format = 'ISO'` if that matches the intended rows).
```suggestion
UPDATE `cloud`.`vm_template`
SET guest_os_id = 99
WHERE name = 'kvm-default-vm-import-dummy-template'
AND type = 'SYSTEM'
AND format = 'ISO';
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4044265628
@sureshanaparti 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on code in PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#discussion_r2917389337
##########
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42200to42210.java:
##########
@@ -27,4 +35,46 @@ public String[] getUpgradableVersionRange() {
public String getUpgradedVersion() {
return "4.22.1.0";
}
+
+ @Override
+ public void performDataMigration(Connection conn) {
+ removeDuplicateDummyTemplates(conn);
+ }
+
+ private void removeDuplicateDummyTemplates(Connection conn) {
+ List<Long> templateIds = new ArrayList<>();
+ try (PreparedStatement selectStmt = conn.prepareStatement(String.format("SELECT id FROM cloud.vm_template WHERE name='%s' ORDER BY id ASC", UnmanagedVMsManager.KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME))) {
+ ResultSet rs = selectStmt.executeQuery();
+ while (rs.next()) {
+ templateIds.add(rs.getLong(1));
+ }
+
+ if (templateIds.size() <= 1) {
+ return;
+ }
+
+ Long firstTemplateId = templateIds.get(0);
+
+ String updateTemplateSql = "UPDATE cloud.vm_instance SET vm_template_id = ? WHERE vm_template_id = ?";
+ String deleteTemplateSql = "DELETE FROM cloud.vm_template WHERE id = ?";
+
+ try (PreparedStatement updateTemplateStmt = conn.prepareStatement(updateTemplateSql);
+ PreparedStatement deleteTemplateStmt = conn.prepareStatement(deleteTemplateSql)) {
+ for (int i = 1; i < templateIds.size(); i++) {
+ Long duplicateTemplateId = templateIds.get(i);
+
+ // Update VM references
+ updateTemplateStmt.setLong(1, firstTemplateId);
+ updateTemplateStmt.setLong(2, duplicateTemplateId);
+ updateTemplateStmt.executeUpdate();
+
+ // Delete duplicate dummy template
+ deleteTemplateStmt.setLong(1, duplicateTemplateId);
+ deleteTemplateStmt.executeUpdate();
+ }
+ }
+ } catch (Exception e) {
+ logger.warn("Failed to clean duplicate kvm-default-vm-import-dummy-template entries", e);
Review Comment:
```suggestion
logger.warn("Failed to clean duplicate " + UnmanagedVMsManager.KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME + " entries", e);
```
##########
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42200to42210.java:
##########
@@ -27,4 +35,46 @@ public String[] getUpgradableVersionRange() {
public String getUpgradedVersion() {
return "4.22.1.0";
}
+
+ @Override
+ public void performDataMigration(Connection conn) {
+ removeDuplicateDummyTemplates(conn);
+ }
+
+ private void removeDuplicateDummyTemplates(Connection conn) {
Review Comment:
```suggestion
private void removeDuplicateKVMImportTemplates(Connection conn) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez closed pull request #12780: Fix duplicate dummy templates, and update guest os for dummy template
URL: https://github.com/apache/cloudstack/pull/12780
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4044625532
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17113
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4038036758
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17090
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4044692578
@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix duplicate dummy templates, and update guest os for dummy template [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12780:
URL: https://github.com/apache/cloudstack/pull/12780#issuecomment-4052471650
<b>[LL] Trillian Build Failed (tid-7179)<b/>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org