Skip to content

Address assignVm regression #10875

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

Merged
merged 3 commits into from
May 21, 2025

Conversation

winterhazel
Copy link
Member

@winterhazel winterhazel commented May 15, 2025

Description

This PR fixes #10825 by moving the creation of the network to outside the transaction, right before the updates start happening. This way, if an error happens while creating the network, nothing will have been updated yet. And, if an error happens while updating the virtual machine, the changes will be rolledback.

Also closes #10854.

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)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

I verified that the issue does not happen anymore:

  • I tried to assign the VM to an account without any network: ACS created a new isolated network for the VM and assigned it successfully.

Also, I simulated errors during the VM assignment to verify what would happen:

  • I tried to assign the VM to an account without any network, and forced an error before the creation of the network: the VM remained in its original state, and no network was created;
  • I tried to assign the VM to an account without any network, and forced an error during the creation of the network: the VM remained in its original state, and the creation was rolled-back;
  • I tried to assign the VM to an account without any network, and forced an error while updating the VM's information: the VM was rolled-back to its original state, and the created network was deleted.

And verified the behavior for some other situations:

  • I tried to assign the VM to an account with a single network without selecting the network: the VM was assigned to this single network successfully;
  • I tried to assign the VM to an account with multiple networks without selecting a network: an exception was thrown because I had not selected any network (expected);
  • I tried to assign the VM to an account with multiple networks by selecting one of its networks: the VM was assigned successfully;
  • I moved the VM to a domain-shared network, and tried to assign it to an account from the same domain without any isolated networks: the VM was assigned successfully and remained in the shared network;
  • I moved the VM to an isolated network, and tried to assign it to an account from the same domain that had access only to a domain-shared network: ACS created a new isolated network for the VM and assigned it successfully.

@winterhazel winterhazel requested a review from Pearl1594 May 15, 2025 14:08
@winterhazel
Copy link
Member Author

@Pearl1594 while testing this, I found that there are some problems with the network creation/deletion events in this process. For example, when an isolated network is automatically created by ACS during VM assignment, no creation event is published. However, we can address this issue separately.

@winterhazel
Copy link
Member Author

@blueorangutan package

@winterhazel winterhazel added this to the 4.20.1 milestone May 15, 2025
@blueorangutan
Copy link

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

Copy link

codecov bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 36.20690% with 37 lines in your changes missing coverage. Please review.

Project coverage is 16.14%. Comparing base (5444261) to head (0306aac).
Report is 1 commits behind head on 4.20.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 36.20% 36 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #10875   +/-   ##
=========================================
  Coverage     16.13%   16.14%           
- Complexity    13239    13241    +2     
=========================================
  Files          5656     5656           
  Lines        497579   497615   +36     
  Branches      60333    60339    +6     
=========================================
+ Hits          80297    80316   +19     
- Misses       408333   408348   +15     
- Partials       8949     8951    +2     
Flag Coverage Δ
uitests 4.00% <ø> (ø)
unittests 16.99% <36.20%> (+<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.

@blueorangutan
Copy link

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

@shwstppr
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@shwstppr 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-13325)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 60000 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10875-t13325-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
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

All CI tests assed 👍

Co-authored-by: Wei Zhou <weizhou@apache.org>
@winterhazel
Copy link
Member Author

@blueorangutan package

@blueorangutan
Copy link

@winterhazel 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 ✔️ debian ✔️ suse15. SL-JID 13421

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@weizhouapache 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-13334)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 106335 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10875-t13334-kvm-ol8.zip
Smoke tests completed. 114 look OK, 27 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestDeployVirtioSCSIVM>:setup Error 0.00 test_deploy_virtio_scsi_vm.py
test_10_bgp_peers Error 3.33 test_ipv4_routing.py
test_11_isolated_network_with_dynamic_routed_mode Error 124.87 test_ipv4_routing.py
test_12_vpc_and_tier_with_dynamic_routed_mode Error 124.06 test_ipv4_routing.py
test_03_update_vm_with_extraconfig_kvm Error 145.69 test_deploy_vm_extra_config_data.py
test_05_basic_lifecycle_kubernetes_cluster Failure 135.01 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 3669.50 test_kubernetes_clusters.py
test_03_network_operations_on_created_vm_of_otheruser Failure 175.93 test_network_permissions.py
test_03_network_operations_on_created_vm_of_otheruser Error 175.94 test_network_permissions.py
test_04_deploy_vm_for_other_user_and_test_vm_operations Failure 48.88 test_network_permissions.py
ContextSuite context=TestNetworkPermissions>:teardown Error 1.67 test_network_permissions.py
test_reboot_router Error 264.49 test_network.py
test_01_non_strict_host_anti_affinity Error 159.17 test_nonstrict_affinity_group.py
test_02_non_strict_host_affinity Error 101.55 test_nonstrict_affinity_group.py
test_01_primary_storage_nfs Error 0.26 test_primary_storage.py
ContextSuite context=TestStorageTags>:setup Error 0.43 test_primary_storage.py
test_01_primary_storage_scope_change Error 0.15 test_primary_storage_scope.py
test_10_project_activation Error 6.55 test_projects.py
test_08_start_router Error 1.14 test_routers.py
test_09_reboot_router Error 1.15 test_routers.py
test_10_reboot_router_forced Error 1.12 test_routers.py
test_04_change_offering_small Error 102.77 test_service_offerings.py
test_resize_shared_fs Error 6.58 test_sharedfs_lifecycle.py
test_01_list_sec_storage_vm Failure 0.04 test_ssvm.py
test_03_ssvm_internals Failure 0.06 test_ssvm.py
test_05_stop_ssvm Failure 0.04 test_ssvm.py
test_06_stop_cpvm Failure 921.42 test_ssvm.py
test_07_reboot_ssvm Failure 0.05 test_ssvm.py
test_08_reboot_cpvm Failure 0.04 test_ssvm.py
test_09_reboot_ssvm_forced Failure 0.04 test_ssvm.py
test_10_reboot_cpvm_forced Failure 0.05 test_ssvm.py
test_11_destroy_ssvm Failure 0.04 test_ssvm.py
ContextSuite context=TestVMWareStoragePolicies>:setup Error 0.00 test_storage_policy.py
test_01_create_template Error 13.64 test_templates.py
test_CreateTemplateWithDuplicateName Error 23.19 test_templates.py
test_02_create_template_with_checksum_sha1 Error 65.71 test_templates.py
test_03_create_template_with_checksum_sha256 Error 65.70 test_templates.py
test_04_create_template_with_checksum_md5 Error 65.69 test_templates.py
test_05_create_template_with_no_checksum Error 65.69 test_templates.py
test_03_delete_template Error 1.11 test_templates.py
test_04_extract_template Error 1.12 test_templates.py
test_09_list_templates_download_details Failure 0.14 test_templates.py
ContextSuite context=TestISOUsage>:setup Error 0.00 test_usage.py
test_01_template_usage Error 11.63 test_usage.py
test_01_volume_usage Error 188.00 test_usage.py
test_02_start_vm Error 4.17 test_vm_life_cycle.py
test_03_reboot_vm Error 0.08 test_vm_life_cycle.py
test_04_reboot_vm_forced Failure 1.09 test_vm_life_cycle.py
test_10_attachAndDetach_iso Failure 1513.41 test_vm_life_cycle.py
test_05_vmschedule_test_e2e Failure 362.31 test_vm_schedule.py
ContextSuite context=TestMigrateVMStrictTags>:setup Error 0.00 test_vm_strict_host_tags.py
ContextSuite context=TestRestoreVMStrictTags>:setup Error 0.00 test_vm_strict_host_tags.py
ContextSuite context=TestScaleVMStrictTags>:setup Error 0.00 test_vm_strict_host_tags.py
ContextSuite context=TestVMDeploymentPlannerStrictTags>:setup Error 0.00 test_vm_strict_host_tags.py
test_04_deploy_vnf_appliance Error 312.14 test_vnf_templates.py
test_02_attach_volume Error 80.06 test_volumes.py
test_03_download_attached_volume Error 11.70 test_volumes.py
test_04_delete_attached_volume Error 9.54 test_volumes.py
test_05_detach_volume Error 100.71 test_volumes.py
test_06_download_detached_volume Error 189.84 test_volumes.py
test_06_download_detached_volume Error 189.84 test_volumes.py
test_07_resize_fail Error 7.49 test_volumes.py
test_08_resize_volume Error 11.82 test_volumes.py
test_09_delete_detached_volume Error 10.84 test_volumes.py
test_10_list_volumes Failure 378.00 test_volumes.py
test_10_list_volumes Error 378.02 test_volumes.py
test_11_attach_volume_with_unstarted_vm Error 107.22 test_volumes.py
test_12_resize_volume_with_only_size_parameter Error 12.82 test_volumes.py
test_13_migrate_volume_and_change_offering Error 17.22 test_volumes.py
test_13_migrate_volume_and_change_offering Error 17.22 test_volumes.py
test_14_delete_volume_delete_protection Error 10.82 test_volumes.py
ContextSuite context=TestIpv6Vpc>:setup Error 0.00 test_vpc_ipv6.py
ContextSuite context=TestVPCRedundancy>:setup Error 0.00 test_vpc_redundant.py
ContextSuite context=TestVPCNics>:setup Error 0.00 test_vpc_router_nics.py
ContextSuite context=TestRVPCSite2SiteVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVPCSite2SiteVPNMultipleOptions>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVpcRemoteAccessVpn>:setup Error 0.00 test_vpc_vpn.py
ContextSuite context=TestVpcSite2SiteVpn>:setup Error 0.00 test_vpc_vpn.py
test_disable_oobm_ha_state_ineligible Error 1517.34 test_hostha_kvm.py

@Pearl1594
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

Copy link
Contributor

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

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-13338)

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

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

@weizhouapache
Copy link
Member

@blueorangutan package

@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 ✔️ debian ✔️ suse15. SL-JID 13451

@rohityadavcloud
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@rohityadavcloud 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-13354)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 55316 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10875-t13354-kvm-ol8.zip
Smoke tests completed. 140 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_create_pvlan_network Error 0.14 test_pvlan.py

@weizhouapache
Copy link
Member

verified ok
(same steps in the desciption)

@blueorangutan
Copy link

[SF] Trillian test result (tid-13355)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 57251 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10875-t13355-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

@Pearl1594 Pearl1594 merged commit 34896a1 into apache:4.20 May 21, 2025
26 checks passed
@blueorangutan
Copy link

[SF] Trillian test result (tid-13364)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 57648 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10875-t13364-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

dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Jun 19, 2025
* Address assignVm regression
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.

Assign VM operation fails to rollback on network error Failure to assign VM to another account
7 participants