Skip to content

Conversation

nvazquez
Copy link
Contributor

@nvazquez nvazquez commented Sep 17, 2025

Description

This PR fixes the VM import naming mismatch with the internal VM ID on database as described on #11658

Fixes: #11658

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • 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
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

After the fix:

  • Using cmk: Send an import command with the wrong zoneid parameter. After the failure, import the VM correctly setting the zoneid parameter

How did you try to break this feature and the system with this change?

Copy link

codecov bot commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 21.42857% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.17%. Comparing base (0cbebbd) to head (f3340e9).
⚠️ Report is 5 commits behind head on 4.20.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 23 Missing ⚠️
.../apache/cloudstack/vm/UnmanagedVMsManagerImpl.java 47.36% 9 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #11659      +/-   ##
============================================
- Coverage     16.17%   16.17%   -0.01%     
+ Complexity    13297    13296       -1     
============================================
  Files          5656     5656              
  Lines        498151   498144       -7     
  Branches      60441    60441              
============================================
- Hits          80588    80569      -19     
- Misses       408591   408605      +14     
+ Partials       8972     8970       -2     
Flag Coverage Δ
uitests 4.00% <ø> (ø)
unittests 17.02% <21.42%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nvazquez nvazquez closed this Sep 17, 2025
@nvazquez nvazquez reopened this Sep 17, 2025
Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

code lgtm

@weizhouapache
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@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.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15062

@nvazquez
Copy link
Contributor Author

@blueorangutan test

1 similar comment
@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

should do the job (clgtm)

@DaanHoogland
Copy link
Contributor

@NuxRo @rajujith , can you test?

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

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

I feel the problem is not the lack of transaction but we are we are using UserVmDao.getNextSequence twice. First to find the internal name and then at the time of actual commit
https://github.com/apache/cloudstack/blob/main/server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java#L2871-L2877
Maybe we can move the ^^ code inside importVm method or also start passing id to the importVm method

@blueorangutan
Copy link

[SF] Trillian test result (tid-14374)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 55329 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11659-t14374-kvm-ol8.zip
Smoke tests completed. 141 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Copy link

@rajujith rajujith left a comment

Choose a reason for hiding this comment

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

Looks like not fixed:

mysql> select id,instance_name,created from vm_instance where removed is null;
+----+---------------+---------------------+
| id | instance_name | created             |
+----+---------------+---------------------+
|  1 | s-1-VM        | 2025-08-26 08:25:12 |
|  2 | v-2-VM        | 2025-08-26 08:25:07 |
|  4 | r-4-VM        | 2025-08-26 13:00:49 |
| 45 | i-2-45-VM     | 2025-09-18 08:54:38 |
| 49 | i-2-48-VM     | 2025-09-18 08:56:11 |
+----+---------------+---------------------+

@nvazquez
Copy link
Contributor Author

Thanks @shwstppr - I have refactored based on your suggestion

@blueorangutan package

@blueorangutan
Copy link

@nvazquez 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.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15082

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-14381)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 51969 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11659-t14381-kvm-ol8.zip
Smoke tests completed. 141 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

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

Code looks good. One comment on redundant code

Comment on lines +8993 to +8996
String instanceSuffix = _configDao.getValue(Config.InstanceName.key());
if (instanceSuffix == null) {
instanceSuffix = "DEFAULT";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is already done in the configure method

@weizhouapache
Copy link
Member

@nvazquez
have you tested it ? is this ready for review and testing ?

@nvazquez
Copy link
Contributor Author

Hi @weizhouapache - yes I have tested and verified the fix, it is ready for review and testing.

I'm updating the PR description, have applied the fix on the environment where @rajujith detected the issue and could verify the fix after VM ID = 50.

mysql> select id,instance_name,created from vm_instance where removed is null;
+----+---------------+---------------------+
| id | instance_name | created             |
+----+---------------+---------------------+
|  1 | s-1-VM        | 2025-08-26 08:25:12 |
|  2 | v-2-VM        | 2025-08-26 08:25:07 |
|  4 | r-4-VM        | 2025-08-26 13:00:49 |
| 45 | i-2-45-VM     | 2025-09-18 08:54:38 |
| 49 | i-2-48-VM     | 2025-09-18 08:56:11 |
| 50 | i-2-50-VM     | 2025-09-19 17:47:38 |
| 51 | i-2-51-VM     | 2025-09-19 17:52:47 |
+----+---------------+---------------------+
7 rows in set (0.00 sec)

Copy link

@rajujith rajujith left a comment

Choose a reason for hiding this comment

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

LGTM.


mysql> select id,instance_name,created from vm_instance where removed is null;
+----+---------------+---------------------+
| id | instance_name | created             |
+----+---------------+---------------------+
|  1 | s-1-VM        | 2025-08-26 08:25:12 |
|  2 | v-2-VM        | 2025-08-26 08:25:07 |
|  4 | r-4-VM        | 2025-08-26 13:00:49 |
| 49 | i-2-48-VM     | 2025-09-18 08:56:11 |
| 50 | i-2-50-VM     | 2025-09-19 17:47:38 |
| 51 | i-2-51-VM     | 2025-09-19 17:52:47 |
| 52 | i-2-52-VM     | 2025-09-23 06:26:19 |
+----+---------------+---------------------+

@weizhouapache
Copy link
Member

merging based on approvals and manual testing by @rajujith

thanks all

@weizhouapache weizhouapache merged commit 1a223fd into apache:4.20 Sep 23, 2025
25 of 26 checks passed
@DaanHoogland DaanHoogland deleted the 420-importvm-vmid-fix branch September 24, 2025 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent id and internal name in DB after failed import VM attempts
6 participants