Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,37 @@ public boolean migrateToObjectStore(DataStore store) {

@Override
public void updateStoragePool(StoragePool storagePool, Map<String, String> details) {
StoragePoolVO poolVO = storagePoolDao.findById(storagePool.getId());
Comment thread
sathvikaragi marked this conversation as resolved.
if (poolVO == null) {
throw new CloudRuntimeException("updateStoragePool: storage pool not found: " + storagePool.getId());
}
String strNewCapacityBytes = details.get(PrimaryDataStoreLifeCycle.CAPACITY_BYTES);
Comment thread
sathvikaragi marked this conversation as resolved.
if (strNewCapacityBytes == null) {
logger.debug("updateStoragePool: no capacityBytes change requested, skipping ONTAP resize");
Comment thread
sathvikaragi marked this conversation as resolved.
return;
}
long newCapacityBytes = Long.parseLong(strNewCapacityBytes);

Map<String, String> poolDetails = storagePoolDetailsDao.listDetailsKeyPairs(storagePool.getId());
StorageStrategy storageStrategy = OntapStorageUtils.getStrategyByStoragePoolDetails(poolDetails);

logger.info("updateStoragePool: resizing ONTAP FlexVolume for pool '{}'", storagePool.getId());
Volume volume = new Volume();
volume.setUuid(poolDetails.get(OntapStorageConstants.VOLUME_UUID));
volume.setName(poolDetails.get(OntapStorageConstants.VOLUME_NAME));
try {
if (volume.getUuid() == null || volume.getUuid().isEmpty() || volume.getName() == null || volume.getName().isEmpty()) {
logger.error("updateStoragePool: Volume UUID/Name not found in details for pool: {}, cannot resize", storagePool.getName());
throw new CloudRuntimeException("Volume UUID/Name not found in details, cannot resize ONTAP FlexVolume");
}
storageStrategy.updateStorageVolume(volume, newCapacityBytes);
logger.info("updateStoragePool: Successfully resized ONTAP FlexVolume '{}' (UUID: {}) for pool '{}'",
Comment thread
sathvikaragi marked this conversation as resolved.
volume.getName(), volume.getUuid(), storagePool.getName());
} catch (Exception e) {
logger.error("updateStoragePool: Exception while resizing FlexVolume for pool: {}. Error: {}",
Comment thread
sathvikaragi marked this conversation as resolved.
storagePool.getName(), e.getMessage(), e);
throw new CloudRuntimeException("Failed to resize ONTAP FlexVolume for pool: " + storagePool.getName() + ". " + e.getMessage(), e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,26 @@ public Volume createStorageVolume(String volumeName, Long size) {
* @param volume the volume to update
* @return the updated Volume object
*/
public Volume updateStorageVolume(Volume volume) {
return null;
public Volume updateStorageVolume(Volume volume, Long newSizeBytes) {
logger.info("Resizing ONTAP volume by name: " + volume.getName() + " and uuid: " + volume.getUuid());
String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword());
Volume resizeRequest = new Volume();
resizeRequest.setSize(newSizeBytes);
try {
JobResponse jobResponse = volumeFeignClient.updateVolumeRebalancing(authHeader, volume.getUuid(), resizeRequest);
Boolean jobSucceeded = jobPollForSuccess(jobResponse.getJob().getUuid(), 10, 1000);
if (!jobSucceeded) {
logger.error("resizeStorageVolume: resize job failed for FlexVolume: " + volume.getName());
throw new CloudRuntimeException("resizeStorageVolume: resize job failed for FlexVolume: " + volume.getName());
Comment thread
sathvikaragi marked this conversation as resolved.
}
} catch (FeignException e) {
logger.error("Exception while resizing FlexVolume: " + volume.getName(), e);
throw new CloudRuntimeException("Failed to resize ONTAP FlexVolume: " + e.getMessage(), e);
}
logger.info("resizeStorageVolume: FlexVolume {} resized successfully to {} bytes", volume.getName(), newSizeBytes);
Comment thread
sathvikaragi marked this conversation as resolved.
return volume;
}

/**
/**
* Delete ONTAP Flex-Volume
* Eligible only for Unified ONTAP storage
* throw exception in case of disaggregated ONTAP storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,6 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I
StoragePoolVO storagePool = _storagePoolDao.findById(id);
DataStoreProvider dataStoreProvider = _dataStoreProviderMgr.getDataStoreProvider(storagePool.getStorageProviderName());
DataStoreLifeCycle dataStoreLifeCycle = dataStoreProvider.getDataStoreLifeCycle();

if (dataStoreLifeCycle instanceof PrimaryDataStoreLifeCycle) {
if (updatedCapacityBytes != null) {
details.put(PrimaryDataStoreLifeCycle.CAPACITY_BYTES, updatedCapacityBytes != null ? String.valueOf(updatedCapacityBytes) : null);
Expand All @@ -1302,6 +1301,7 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I
if (cmd.getUrl() != null) {
details.put("url", cmd.getUrl());
}
((PrimaryDataStoreLifeCycle)dataStoreLifeCycle).updateStoragePool(pool, details);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to handle exceptions here? Maybe a try-catch block over this is needed.

_storagePoolDao.update(id, storagePool);
_storagePoolDao.updateDetails(id, details);
Comment thread
sathvikaragi marked this conversation as resolved.
}
Expand Down
Loading