-
Notifications
You must be signed in to change notification settings - Fork 0
CSTACKEX-234: Enabling storage pool resize (grow and shrink) #87
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
base: main
Are you sure you want to change the base?
Changes from all commits
dd1844c
0ab1f68
b1f78c1
67913b0
d68200e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -526,7 +526,34 @@ public boolean migrateToObjectStore(DataStore store) { | |
|
|
||
| @Override | ||
| public void updateStoragePool(StoragePool storagePool, Map<String, String> details) { | ||
| String newCapacityStr = details.get(PrimaryDataStoreLifeCycle.CAPACITY_BYTES); | ||
| if (newCapacityStr == null) { | ||
| logger.debug("No capacity change requested for pool: {}, skipping FlexVolume resize", storagePool.getName()); | ||
| return; | ||
| } | ||
|
|
||
| long currentCapacityBytes = storagePool.getCapacityBytes(); | ||
| long newCapacityBytes = Long.parseLong(newCapacityStr); | ||
| StorageStrategy storageStrategy = OntapStorageUtils.getStrategyByStoragePoolDetails(details); | ||
|
|
||
| String volumeUuid = details.get(OntapStorageConstants.VOLUME_UUID); | ||
| if (volumeUuid == null || volumeUuid.isEmpty()) { | ||
| logger.error("Volume UUID or name not found in details for pool: {}, cannot resize", storagePool.getName()); | ||
| throw new CloudRuntimeException("Volume UUID or name not found in details, cannot resize ONTAP FlexVolume"); | ||
| } | ||
|
|
||
| Volume volume = new Volume(); | ||
| volume.setUuid(volumeUuid); | ||
| volume.setName(details.get(OntapStorageConstants.VOLUME_NAME)); | ||
|
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. why volume name is required? |
||
| volume.setSize(newCapacityBytes); | ||
| try { | ||
| storageStrategy.updateStorageVolume(volume); | ||
| logger.info("Successfully resized ONTAP FlexVolume '{}' (UUID: {}) for pool '{}' from {} bytes to {} bytes", | ||
| volume.getName(), volume.getUuid(), storagePool.getName(), currentCapacityBytes, newCapacityBytes); | ||
| } catch (Exception e) { | ||
| logger.error("Exception while resizing FlexVolume for pool: {}. Error: {}", storagePool.getName(), e.getMessage(), e); | ||
| throw new CloudRuntimeException("Failed to resize ONTAP FlexVolume for pool: " + storagePool.getName() + ". " + e.getMessage(), e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -368,7 +368,24 @@ public Volume createStorageVolume(String volumeName, Long size) { | |
| * @return the updated Volume object | ||
| */ | ||
| public Volume updateStorageVolume(Volume volume) { | ||
| return null; | ||
| logger.info("Resizing ONTAP FlexVolume '{}' (UUID: {}) to {} bytes", volume.getName(), volume.getUuid(), volume.getSize()); | ||
| String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword()); | ||
| try { | ||
| Volume resizeRequest = new Volume(); | ||
| resizeRequest.setSize(volume.getSize()); | ||
| JobResponse jobResponse = volumeFeignClient.updateVolume(authHeader, volume.getUuid(), resizeRequest); | ||
| pollJobIfPresent(jobResponse, "resize FlexVolume [" + volume.getUuid() + "]", 10, 1000); | ||
| logger.info("FlexVolume '{}' (UUID: {}) resized successfully to {} bytes", volume.getName(), volume.getUuid(), volume.getSize()); | ||
| } catch (FeignException e) { | ||
|
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. This method should handle other exception also, bcz job polling can get time out and throw cloudRuntime Exception |
||
| if (OntapStorageUtils.isOntapObjectNotFoundError(e)) { | ||
| String msg = String.format("Cannot resize FlexVolume '%s' (UUID: %s): volume not found on ONTAP (404). ", volume.getName(), volume.getUuid()); | ||
| logger.error(msg); | ||
| throw new CloudRuntimeException(msg, e); | ||
| } | ||
| logger.error("Exception while resizing FlexVolume '{}' (UUID: {}): {}", volume.getName(), volume.getUuid(), e.getMessage(), e); | ||
| throw new CloudRuntimeException("Failed to resize ONTAP FlexVolume: " + e.getMessage(), e); | ||
| } | ||
| return volume; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
Add sufficient unit test cases for this functionality