Decision making logic of which Secondary storage to be used
Related to this unresolved issue https://issues.apache.org/jira/browse/CLOUDSTACK-2919 Add proper check for disk space on secondary storage to be used for volume migration across clusters. The current logic does not validate if volume will fit in the destination storage pool, but only checks if whether secondary storage disk utilization has not reached 90%.
ISSUE TYPE
- Improvement Request
- Enhancement Request
COMPONENT NAME
Storage
CLOUDSTACK VERSION
4.9+
CONFIGURATION
2+ Secondary Storage (ImageStore) pools with Zone scope 2+ Clusters
OS / ENVIRONMENT
N/A
SUMMARY
When performing cross-cluster volume migration in multi ImageStore environments within the same Zone. The volume is first copied the secondary storage, attached to a worker VM and then migrated to the destination storage pool. This is procedure is only successful when the following 2 conditions are satisfied
- The ImageStore disk usage should not exceed a hardcoded value of 0.9 (90 %)
- The size of the volume the volume to be migrated should exist the amount of free space available in the ImageStore.

STEPS TO REPRODUCE
- Fill up secondary storage disk up to 90%
- Perform cross-cluster volume migration through UI or API
EXPECTED RESULTS
An exception should be thrown explaining that no suitable secondary storage pool was found for volume migration.
ACTUAL RESULTS
CloudStack selects a random secondary storage pool and attempts to migrate the volume anyways and fails when the size of the volume exceeds the amount of free space within that particular secondary storage.
Throw 'InsufficientCapacityException' when migration fails due to insufficient space in secondary storage
Any chance on getting this into 4.12.0? Otherwise, I would move it to 5.0.0
@dhlaluku any update on this one?
@GabrielBrascher @rafaelweingartner I will pick this up some time next week.
@dhlaluku this one?
@kioie yes
Ping @anuragaw
Refer for duplicate and related case of uploading template/iso/volume: https://github.com/apache/cloudstack/issues/3287 where secondary storage usage exceeds the threshold
what's the next steps on this issue @rhtyd ? Should I investigate and create a fresh PR as needed?
The selection of secondary storage should be refactored (the method) based on usage and throw exception when no available image store is found with enough capacity. @shwstppr can you continue over this, there is an existing PR you can review or extend over.
Related: https://github.com/apache/cloudstack/issues/3041 https://github.com/apache/cloudstack/issues/3287 https://github.com/apache/cloudstack/issues/3478
Related/dupes https://github.com/apache/cloudstack/issues/3478 closing this one.