-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix VM import DB sequence issue on import failure #11659
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
Conversation
Codecov Report❌ Patch coverage is 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
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:
|
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.
code lgtm
@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 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15062 |
@blueorangutan test |
1 similar comment
@blueorangutan test |
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
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.
should do the job (clgtm)
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.
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
[SF] Trillian test result (tid-14374)
|
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.
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 |
+----+---------------+---------------------+
Thanks @shwstppr - I have refactored based on your suggestion @blueorangutan package |
@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. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15082 |
@blueorangutan test |
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-14381)
|
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.
Code looks good. One comment on redundant code
String instanceSuffix = _configDao.getValue(Config.InstanceName.key()); | ||
if (instanceSuffix == null) { | ||
instanceSuffix = "DEFAULT"; | ||
} |
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.
This is already done in the configure method
@nvazquez |
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.
|
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.
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 |
+----+---------------+---------------------+
merging based on approvals and manual testing by @rajujith thanks all |
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
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
After the fix:
How did you try to break this feature and the system with this change?