-
Notifications
You must be signed in to change notification settings - Fork 1.3k
server: fix volume migration on user vm scale #6704
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ce956b8
server: fix volume migration on user vm scale
shwstppr b1fb6e8
Added Global/zone setting allow.diskOffering.change.during.scale.vm t…
harikrishna-patnala c2bdbd3
Fixed marvin tests
harikrishna-patnala 94db086
Merge branch '4.17' into fix-user-scalevm-vol-migration
shwstppr 2c7f27f
test fixes
shwstppr e75446e
Update server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
yadvr 08a5769
fix import
yadvr 1860068
Update server/src/main/java/com/cloud/vm/UserVmManager.java
yadvr 24e7cb2
Update server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
yadvr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,6 +96,7 @@ | |
| import org.apache.cloudstack.utils.volume.VirtualMachineDiskInfo; | ||
| import org.apache.commons.collections.CollectionUtils; | ||
| import org.apache.commons.collections.MapUtils; | ||
| import org.apache.commons.lang3.ObjectUtils; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| import org.apache.commons.lang3.builder.ToStringStyle; | ||
|
|
@@ -1767,14 +1768,14 @@ private Volume changeDiskOfferingForVolumeInternal(VolumeVO volume, Long newDisk | |
| return volume; | ||
| } | ||
|
|
||
| if (currentSize != newSize || newMaxIops != volume.getMaxIops() || newMinIops != volume.getMinIops()) { | ||
| if (currentSize != newSize || !compareEqualsIncludingNullOrZero(newMaxIops, volume.getMaxIops()) || !compareEqualsIncludingNullOrZero(newMinIops, volume.getMinIops())) { | ||
| volumeResizeRequired = true; | ||
| validateVolumeReadyStateAndHypervisorChecks(volume, currentSize, newSize); | ||
| } | ||
|
|
||
| StoragePoolVO existingStoragePool = _storagePoolDao.findById(volume.getPoolId()); | ||
|
|
||
| Pair<List<? extends StoragePool>, List<? extends StoragePool>> poolsPair = managementService.listStoragePoolsForMigrationOfVolumeInternal(volume.getId(), newDiskOffering.getId(), newSize, newMinIops, newMaxIops, true, false); | ||
| Pair<List<? extends StoragePool>, List<? extends StoragePool>> poolsPair = managementService.listStoragePoolsForSystemMigrationOfVolume(volume.getId(), newDiskOffering.getId(), newSize, newMinIops, newMaxIops, true, false); | ||
| List<? extends StoragePool> suitableStoragePools = poolsPair.second(); | ||
|
|
||
| if (!suitableStoragePools.stream().anyMatch(p -> (p.getId() == existingStoragePool.getId()))) { | ||
|
|
@@ -1823,6 +1824,21 @@ private Volume changeDiskOfferingForVolumeInternal(VolumeVO volume, Long newDisk | |
| return volume; | ||
| } | ||
|
|
||
| /** | ||
| * This method is to compare long values, in miniops and maxiops a or b can be null or 0. | ||
| * Use this method to treat 0 and null as same | ||
| * | ||
| * @param a | ||
| * @param b | ||
| * @return true if a and b are equal excluding 0 and null values. | ||
| */ | ||
| private boolean compareEqualsIncludingNullOrZero(Long a, Long b) { | ||
| a = ObjectUtils.defaultIfNull(a, 0L); | ||
| b = ObjectUtils.defaultIfNull(b, 0L); | ||
|
|
||
| return a.equals(b); | ||
| } | ||
|
Comment on lines
+1835
to
+1840
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shwstppr, we could move this method to |
||
|
|
||
| /** | ||
| * Returns true if the new disk offering is the same than current offering, and the respective Service offering is a custom (constraint or unconstraint) offering. | ||
| */ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, what do you think about renaming the method to
compareLongsDefaultingNullToZero?