Skip to content
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

vm-import: fix stopped managed vms listing in unmanaged instances #7606

Merged

Conversation

shwstppr
Copy link
Contributor

@shwstppr shwstppr commented Jun 8, 2023

Description

When listing unmanaged instances for a cluster with multiple hosts, stopped manager VMs are getting listed as well. This PR fixes this behaviour and adds some code refactoring

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

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #7606 (3470230) into 4.18 (29c7b31) will increase coverage by 0.04%.
Report is 70 commits behind head on 4.18.
The diff coverage is 19.77%.

@@             Coverage Diff              @@
##               4.18    #7606      +/-   ##
============================================
+ Coverage     13.02%   13.06%   +0.04%     
- Complexity     9032     9109      +77     
============================================
  Files          2720     2720              
  Lines        257080   257535     +455     
  Branches      40088    40153      +65     
============================================
+ Hits          33476    33654     +178     
- Misses       219400   219654     +254     
- Partials       4204     4227      +23     
Files Coverage Δ
...hestration/service/VolumeOrchestrationService.java 100.00% <ø> (ø)
.../main/java/com/cloud/network/IpAddressManager.java 100.00% <100.00%> (ø)
...ava/com/cloud/network/as/AutoScaleVmProfileVO.java 80.20% <100.00%> (+11.66%) ⬆️
...java/com/cloud/upgrade/DatabaseUpgradeChecker.java 40.89% <100.00%> (+0.64%) ⬆️
...va/com/cloud/upgrade/DatabaseVersionHierarchy.java 85.10% <100.00%> (+1.01%) ⬆️
.../api/command/admin/ratelimit/ResetApiLimitCmd.java 0.00% <ø> (ø)
...oud/hypervisor/kvm/resource/LibvirtConnection.java 0.00% <ø> (ø)
.../hypervisor/kvm/storage/ScaleIOStorageAdaptor.java 10.44% <100.00%> (ø)
...ava/com/cloud/api/commands/StopNetScalerVMCmd.java 0.00% <ø> (ø)
...tungsten/api/command/ListTungstenFabricTagCmd.java 0.00% <ø> (ø)
... and 59 more

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@DaanHoogland
Copy link
Contributor

haven´t looked at the code thouroughly but looks good so far. I wonder about the functionality though @shwstppr ; as a user I would want to be able to import stopped VMs as well. Is this harmful/impossible and is this why you want to prevent the listing?

@shwstppr shwstppr changed the title vm-import: fix stopped vms listing in unmanaged instances vm-import: fix stopped managed vms listing in unmanaged instances Jun 9, 2023
@shwstppr
Copy link
Contributor Author

shwstppr commented Jun 9, 2023

@DaanHoogland maybe the title and description wasn't that clear. This PR is trying to fix an issue where stopped managed VMs are getting listed as unmanaged instances

@DaanHoogland
Copy link
Contributor

@DaanHoogland maybe the title and description wasn't that clear. This PR is trying to fix an issue where stopped managed VMs are getting listed as unmanaged instances

ok, tnx

@weizhouapache weizhouapache added this to the 4.18.1.0 milestone Jun 20, 2023
@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SF] 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6329

@shwstppr
Copy link
Contributor Author

@blueorangutan test rocky8 vmware-67u3

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.

clgtm

UnmanagedInstanceTO unmanagedInstance = unmanagedInstances.get(name);
if (unmanagedInstance == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Unable to retrieve details for unmanaged VM: %s", name));
if (!instanceName.equals(name)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can extract the larger part of this block, from the continue here and the break just before the end of the loop.

@rohityadavcloud
Copy link
Member

@shwstppr - is this ready for review?
@blueorangutan package

@blueorangutan
Copy link

@rohityadavcloud a [SF] 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6709

@shwstppr shwstppr marked this pull request as ready for review August 9, 2023 05:15
@shwstppr
Copy link
Contributor Author

shwstppr commented Aug 9, 2023

@rohityadavcloud yes, marked it as ready for review

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

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

@blueorangutan
Copy link

[SF] Trillian test result (tid-7355)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 42162 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7606-t7355-kvm-centos7.zip
Smoke tests completed. 107 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_migrate_VM_and_root_volume Error 80.83 test_vm_life_cycle.py
test_02_migrate_VM_with_two_data_disks Error 53.39 test_vm_life_cycle.py

@DaanHoogland
Copy link
Contributor

tested manually @shwstppr , there was one circumstance in which a VM was visible both as managed as well as unmanaged:

  • New VM created in cloudstack
  • unmanaged
  • stopped in vcenter
  • imported
    now it is visible on both lists of the dialog:
    image
    after starting it in cloudstack it is no longer visible as unmanaged:
    image
    All other combinations of stop/start seem to display correctly

@shwstppr
Copy link
Contributor Author

@DaanHoogland thanks for the testing. Will have to check. Weird that an unmanaged VM is showing in the managed list

@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor

@blueorangutan test rocky8 vmware-70u3 keepEnv

@blueorangutan
Copy link

@DaanHoogland a [SF] Trillian-Jenkins test job (rocky8 mgmt + vmware-70u3) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-7525)
Environment: vmware-70u3 (x2), Advanced Networking with Mgmt server r8
Total time taken: 42816 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7606-t7525-vmware-70u3.zip
Smoke tests completed. 107 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_02_list_cpvm_vm Failure 0.04 test_ssvm.py
test_04_cpvm_internals Failure 0.04 test_ssvm.py

@DaanHoogland
Copy link
Contributor

@shwstppr still a little snag (I don't know if you already gave that attention)
image
note i-2-431-VM is visible on both sides, This is the case where I stopped on ACS unmanaged and imported again. At first it is not visible on the left side, but on pressing refresh it appears.

@DaanHoogland DaanHoogland removed their assignment Aug 25, 2023
@weizhouapache weizhouapache modified the milestones: 4.18.1.0, 4.18.2.0 Aug 28, 2023
Copy link
Member

@rohityadavcloud rohityadavcloud left a comment

Choose a reason for hiding this comment

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

LGTM didn't test it though

@DaanHoogland
Copy link
Contributor

@shwstppr , is it at all possible to fix the issue I found with this? Should we close and revisit at a later time?

@shwstppr
Copy link
Contributor Author

shwstppr commented Oct 2, 2023

@DaanHoogland will investigate this week and update

@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SF] 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7294

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr
Copy link
Contributor Author

@DaanHoogland issue should be fixed now

post-7606-fix.mp4

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SF] 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.

@DaanHoogland DaanHoogland self-assigned this Oct 10, 2023
@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor

great @shwstppr , the issue is gone indeed.

@DaanHoogland
Copy link
Contributor

@blueorangutan test rocky8 vmware-67u3

@DaanHoogland DaanHoogland removed their assignment Oct 10, 2023
@blueorangutan
Copy link

@DaanHoogland a [SF] Trillian-Jenkins test job (rocky8 mgmt + vmware-67u3) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-7906)
Environment: vmware-67u3 (x2), Advanced Networking with Mgmt server r8
Total time taken: 62455 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7606-t7906-vmware-67u3.zip
Smoke tests completed. 106 look OK, 2 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 980.27 test_kubernetes_clusters.py
test_01_deploy_vm_on_specific_host Error 3602.47 test_vm_deployment_planner.py
test_02_deploy_vm_on_specific_cluster Error 17.75 test_vm_deployment_planner.py
test_03_deploy_vm_on_specific_pod Error 3602.31 test_vm_deployment_planner.py
test_04_deploy_vm_on_host_override_pod_and_cluster Error 18.90 test_vm_deployment_planner.py
test_05_deploy_vm_on_cluster_override_pod Error 3601.95 test_vm_deployment_planner.py

@DaanHoogland
Copy link
Contributor

@blueorangutan test alma8 vmware-70u3

@blueorangutan
Copy link

@DaanHoogland a [SF] Trillian-Jenkins test job (alma8 mgmt + vmware-70u3) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-7915)
Environment: vmware-70u3 (x2), Advanced Networking with Mgmt server a8
Total time taken: 49342 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7606-t7915-vmware-70u3.zip
Smoke tests completed. 108 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@DaanHoogland DaanHoogland merged commit 3e7f21a into apache:4.18 Oct 12, 2023
26 of 27 checks passed
@DaanHoogland DaanHoogland deleted the fix-list-unmanaged-instance-stopped branch October 12, 2023 07:21
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.

None yet

5 participants