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
Conversation
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); |
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.
@shwstppr, it will fail here if the URL is not valid. Also, the Storpool plugin doesn't use the managed tag
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.
May check the first characters of url instead of the managed parameter
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.
@slavkap @weizhouapache thanks for the pointers. I'll make the change
Codecov ReportAttention:
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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()); |
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.
@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"))
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.
thanks @shwstppr, code LGTM
tested with NFS, StorPool and Ceph primary storage
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
@shwstppr ready for review and merge? |
@weizhouapache it should be ready now. Add some more changes to check for a possible NPE |
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 |
@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. |
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8048 |
@blueorangutan test |
@shwstppr a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
[SF] Trillian test result (tid-8585)
|
@blueorangutan package |
@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. |
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8065 |
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.
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
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?