Skip to content

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

Merged
shwstppr merged 6 commits into
apache:mainfrom
shapeblue:fix-storagepool-urlcheck
Dec 15, 2023
Merged

server: fix url check for storages without a valid url#8353
shwstppr merged 6 commits into
apache:mainfrom
shapeblue:fix-storagepool-urlcheck

Conversation

@shwstppr

Copy link
Copy Markdown
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?

Fixesapache#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>
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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

codecovBot commented Dec 13, 2023

Copy link
Copy Markdown

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.

FilesPatch %Lines
...ain/java/com/cloud/storage/StorageManagerImpl.java33.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 
FlagCoverage Δ
simulator-marvin-tests24.65% <14.28%> (-0.07%)⬇️
uitests4.40% <ø> (-0.03%)⬇️
unit-tests16.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>
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
Copy Markdown
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>

@slavkapslavkap left a comment

Copy link
Copy Markdown
Contributor

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

@weizhouapacheweizhouapache left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@shwstppr ready for review and merge?

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

Copy link
Copy Markdown
ContributorAuthor

@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
@shwstpprshwstppr changed the title server: fix url check for managed storagesserver: fix url check for storages without a valid urlDec 14, 2023

@harikrishna-patnalaharikrishna-patnala left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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
Copy Markdown

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

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

Comment threadserver/src/main/java/com/cloud/storage/StorageManagerImpl.java Outdated
@shwstpprshwstppr modified the milestones: 4.19.1.0, 4.19.0.0Dec 14, 2023
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@blueorangutan

Copy link
Copy Markdown

[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:

TestResultTime (s)Test File

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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
Copy Markdown

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

@shwstppr
shwstppr merged commit de095ba into apache:mainDec 15, 2023
@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
Fixesapache#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 freeto 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

@shwstppr@weizhouapache@blueorangutan@DaanHoogland@harikrishna-patnala@slavkap