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

server: fix url check for storages without a valid url #8353

Merged
merged 6 commits into from Dec 15, 2023

Conversation

shwstppr
Copy link
Contributor

Description

Fixes #8352
Some managed storages may not need a valid URL to be passed. We can skip check and extraction of host or path from url of such storages.

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?

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

Fixes apache#8352
Some managed storages may not need a valid URL to be passed. We can skip
check and extraction of host or path from url of such storages

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@@ -923,42 +924,47 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource
return (PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(store.getId(), DataStoreRole.Primary);
}

private Map<String,String> extractUriParamsAsMap(String url){
protected Map<String,String> extractUriParamsAsMap(String url, boolean managed) {
Map<String,String> uriParams = new HashMap<>();
UriUtils.UriInfo uriInfo = UriUtils.getUriInfo(url);
Copy link
Contributor

Choose a reason for hiding this comment

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

@shwstppr, it will fail here if the URL is not valid. Also, the Storpool plugin doesn't use the managed tag

Copy link
Member

Choose a reason for hiding this comment

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

May check the first characters of url instead of the managed parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@slavkap @weizhouapache thanks for the pointers. I'll make the change

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

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

Comparison is base (82f7abd) 28.91% compared to head (cb2442e) 30.74%.
Report is 2 commits behind head on main.

Files Patch % Lines
...ain/java/com/cloud/storage/StorageManagerImpl.java 33.33% 21 Missing and 7 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8353      +/-   ##
============================================
+ Coverage     28.91%   30.74%   +1.82%     
- Complexity    31419    33884    +2465     
============================================
  Files          5329     5341      +12     
  Lines        373594   374775    +1181     
  Branches      54319    54515     +196     
============================================
+ Hits         108027   115220    +7193     
+ Misses       250807   244288    -6519     
- Partials      14760    15267     +507     
Flag Coverage Δ
simulator-marvin-tests 24.65% <14.28%> (-0.07%) ⬇️
uitests 4.40% <ø> (-0.03%) ⬇️
unit-tests 16.44% <26.19%> (+1.60%) ⬆️

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.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@@ -808,7 +809,7 @@ protected String createLocalStoragePoolName(Host host, StoragePoolInfo storagePo
@Override
public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException, UnknownHostException, ResourceUnavailableException {
String providerName = cmd.getStorageProviderName();
Map<String,String> uriParams = extractUriParamsAsMap(cmd.getUrl());
Map<String,String> uriParams = extractUriParamsAsMap(cmd.getUrl(), cmd.isManaged());
Copy link
Contributor

Choose a reason for hiding this comment

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

@shwstppr, sorry github doesn't allow you to comment on lines without any changes. On lines 825 and 897 there will be null pointer if the uriParams is empty.

 825       ScopeType scopeType = uriParams.get("scheme").toString().equals("file") ? ScopeType.HOST : ScopeType.CLUSTER;

 897       if (params.get("scheme").toString().equals("file")) 

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

@slavkap slavkap left a comment

Choose a reason for hiding this comment

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

thanks @shwstppr, code LGTM
tested with NFS, StorPool and Ceph primary storage

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

@shwstppr ready for review and merge?

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

@shwstppr ready for review and merge?

@weizhouapache it should be ready now. Add some more changes to check for a possible NPE

@shwstppr shwstppr marked this pull request as ready for review December 14, 2023 06:11
@shwstppr shwstppr changed the title server: fix url check for managed storages server: fix url check for storages without a valid url Dec 14, 2023
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.

code LGTM

@shwstppr
Copy link
Contributor Author

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

@shwstppr
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

@shwstppr shwstppr modified the milestones: 4.19.1.0, 4.19.0.0 Dec 14, 2023
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@blueorangutan
Copy link

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

@shwstppr
Copy link
Contributor Author

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

@shwstppr shwstppr merged commit de095ba into apache:main Dec 15, 2023
25 of 26 checks passed
@DaanHoogland DaanHoogland deleted the fix-storagepool-urlcheck branch December 15, 2023 11:35
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Dec 27, 2023
Fixes apache#8352
Some managed storages may not need a valid URL to be passed. We can skip check and extraction of host or path from url of such storages.
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.

Cannot create primary on StorPool
6 participants