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

Fix reorder/list pools when cluster details are not set, while deploying vm / attaching volume #8373

Merged

Conversation

sureshanaparti
Copy link
Contributor

Description

This PR fixes reorder/list pools when cluster details are not set, while deploying vm / attaching volume.

Problem:
Attach volume to a VM fails, on infra with zone-wide pools & vm.allocation.algorithm=userdispersing as the cluster details are not set (passed as null) while reordering / listing pools by volumes.

Solution:
Ignore cluster details when not set, while reordering / listing pools by volumes.

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

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?

Manually tested Deploy VM, and Attach Volume operations on infra with zone-wide pools & vm.allocation.algorithm=userdispersing

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

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (6d916ca) 30.85% compared to head (4634aaf) 30.85%.
Report is 4 commits behind head on main.

Files Patch % Lines
...main/java/com/cloud/storage/dao/VolumeDaoImpl.java 78.94% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8373   +/-   ##
=========================================
  Coverage     30.85%   30.85%           
- Complexity    34048    34054    +6     
=========================================
  Files          5341     5341           
  Lines        374861   374871   +10     
  Branches      54518    54521    +3     
=========================================
+ Hits         115659   115676   +17     
  Misses       243973   243973           
+ Partials      15229    15222    -7     
Flag Coverage Δ
simulator-marvin-tests 24.75% <0.00%> (-0.01%) ⬇️
uitests 4.39% <ø> (ø)
unit-tests 16.47% <78.94%> (+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.

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

need manual testing

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 - refactoring the sql query to evoke based on passed parameter (when not null) makes it super clear why NPE could happen and why it makes the code more defensive.

@sureshanaparti sureshanaparti force-pushed the attachvolume-issue-with-vm-alloc-userdispersing branch 2 times, most recently from 6dbe9f2 to 2f35795 Compare December 20, 2023 18:29
@shwstppr
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@shwstppr 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]: ✖️ el7 ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 8113

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@sureshanaparti sureshanaparti force-pushed the attachvolume-issue-with-vm-alloc-userdispersing branch from 2f35795 to 4634aaf Compare December 21, 2023 12:27
@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_05_list_volumes_isrecursive Failure 0.03 test_list_volumes.py
test_07_list_volumes_listall Failure 0.03 test_list_volumes.py

Copy link
Contributor

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

LGTM, Tested manually by creating a zone wide storage and creating and attaching a data volume to a running vm

Before the fix there was sql exception

2024-01-03 04:16:06,397 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (Work-Job-Executor-15:ctx-61717f63 job-64/job-65) (logid:fc47afe3) Done executing com.cloud.vm.VmWorkAttachVolume for job-65
2024-01-03 04:16:06,398 INFO  [o.a.c.f.j.i.AsyncJobMonitor] (Work-Job-Executor-15:ctx-61717f63 job-64/job-65) (logid:fc47afe3) Remove job-65 from job monitoring
2024-01-03 04:16:06,414 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-11:ctx-24c62e2f job-64) (logid:fc47afe3) Unexpected exception while executing org.apache.cloudstack.api.command.admin.volume.AttachVolumeCmdByAdmin
com.cloud.utils.exception.CloudRuntimeException: Caught: SELECT pool.id, SUM(IF(vol.state='Ready' AND vol.account_id = ?, 1, 0)) FROM `cloud`.`storage_pool` pool LEFT JOIN `cloud`.`volumes` vol ON pool.id = vol.pool_id WHERE pool.data_center_id = ?  AND pool.pod_id = ? AND pool.cluster_id = ?  GROUP BY pool.id ORDER BY 2 ASC
	at com.cloud.storage.dao.VolumeDaoImpl.listPoolIdsByVolumeCount(VolumeDaoImpl.java:613)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

After the fix there was no sql error observed and the volume got attached

2024-01-03 06:50:22,550 DEBUG [c.c.s.StorageManagerImpl] (Work-Job-Executor-4:ctx-48decd5c job-50/job-51 ctx-5d9c474b) (logid:8aea532a) Checking pool: 2 for storage allocation , maxSize : (3.9980 TB) 4395899027456, totalAllocatedSize : (22.65 GB) 24318968832, askingSize : (5.00 GB) 5368709120, allocated disable threshold: 0.95
2024-01-03 06:50:22,550 DEBUG [o.a.c.s.a.AbstractStoragePoolAllocator] (Work-Job-Executor-4:ctx-48decd5c job-50/job-51 ctx-5d9c474b) (logid:8aea532a) ZoneWideStoragePoolAllocator is returning [1] suitable storage pools [[{"name":"test","uuid":"4fe5cbe5-ab56-37a4-8727-9d9795164ca7"}]].
2024-01-03 06:50:22,552 DEBUG [o.a.c.e.o.VolumeOrchestrator] (Work-Job-Executor-4:ctx-48decd5c job-50/job-51 ctx-5d9c474b) (logid:8aea532a) VM [VM instance {"id":3,"instanceName":"i-2-3-VM","type":"User","uuid":"922e5659-38fe-4fb7-b10e-9df3ffadb1dc"}] does not have a preferred storage pool or it cannot be used. Volume Orchestrator will use the available Storage Pool [{"name":"test","uuid":"4fe5cbe5-ab56-37a4-8727-9d9795164ca7"}], which was discovered using Storage Pool Allocator [ZoneWideStoragePoolAllocator].

2024-01-03 06:50:22,818 DEBUG [c.c.a.t.Request] (Work-Job-Executor-4:ctx-48decd5c job-50/job-51 ctx-5d9c474b) (logid:8aea532a) Seq 1-5166191722547380285: Received:  { Ans: , MgmtId: 32988620391433, via: 1(ref-trl-6114-k-M7-kiran-chavala-kvm1), Ver: v1, Flags: 10, { AttachAnswer } }
2024-01-03 06:50:22,827 DEBUG [c.c.s.VolumeApiServiceImpl] (Work-Job-Executor-4:ctx-48decd5c job-50/job-51 ctx-5d9c474b) (logid:8aea532a) Volume: vb successfully attached to VM: i-2-3-VM
2024-01-03 06:50:22,834 DEBUG [c.c.v.VmWorkJobHandlerProxy] (Work-Job-Executor-4:ctx-48decd5c job-50/job-51 ctx-5d9c474b) (logid:8aea532a) Done executing VM work job: com.cloud.vm.VmWorkAttachVolume{"volumeId":8,"userId":2,"accountId":2,"vmId":3,"handlerName":"VolumeApiServiceImpl"}

@rohityadavcloud rohityadavcloud added this to the 4.19.1.0 milestone Jan 3, 2024
@rohityadavcloud
Copy link
Member

cc @shwstppr this is a bug fix should we merge it, or is main frozen for others?
@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_05_list_volumes_isrecursive Failure 0.04 test_list_volumes.py
test_07_list_volumes_listall Failure 0.03 test_list_volumes.py
test_08_migrate_vm Error 0.05 test_vm_life_cycle.py

@shwstppr
Copy link
Contributor

shwstppr commented Jan 4, 2024

@rohityadavcloud it can be merged if it is ready. We will need to cut a new RC so we can accept bug fixes now.

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 LGTM

@shwstppr
Copy link
Contributor

shwstppr commented Jan 4, 2024

Packages are 2 weeks old, returning more errors - test_list_volumes.py
@blueorangutan package

@blueorangutan
Copy link

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

@sureshanaparti
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

[SF] Trillian test result (tid-8722)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 49111 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8373-t8722-kvm-centos7.zip
Smoke tests completed. 121 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

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

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

LGTM

@shwstppr
Copy link
Contributor

Looks good to include in 4.19RC2. Moving to the milestone and merging

@shwstppr shwstppr modified the milestones: 4.19.1.0, 4.19.0.0 Jan 10, 2024
@shwstppr shwstppr merged commit e87ce0c into apache:main Jan 10, 2024
26 checks passed
@shwstppr shwstppr deleted the attachvolume-issue-with-vm-alloc-userdispersing branch January 10, 2024 12:43
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Jan 12, 2024
…ing vm / attaching volume (apache#8373)

This PR fixes reorder/list pools when cluster details are not set, while deploying vm / attaching volume.

Problem:
Attach volume to a VM fails, on infra with zone-wide pools & vm.allocation.algorithm=userdispersing as the cluster details are not set (passed as null) while reordering / listing pools by volumes.

Solution:
Ignore cluster details when not set, while reordering / listing pools by volumes.
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

8 participants