How to Clean Up Storage Volumes
Storage volumes are sometimes left behind when compute instances are removed. Fix Inventory can find and delete these unused storage volumes.
Fix Inventory's cleanup-volumes infrastructure app can find and delete these orphaned storage volumes.
Prerequisites​
This guide assumes that you have already installed and configured Fix Inventory to collect your cloud resources.
Directions​
-
Execute the following command in Fix Inventory Shell to open the Fix Inventory Worker configuration for editing:
> config edit fix.worker -
Enable cleanup by modifying the
fixworkersection of the configuration as follows:fixworker:
# Enable cleanup of resources
cleanup: true
# Do not actually cleanup resources, just create log messages
cleanup_dry_run: false
# How many cleanup threads to run in parallel
cleanup_pool_size: 16When cleanup is enabled, marked resources will be deleted as a part of the
collect_and_cleanupworkflow, which runs each hour by default.tipSet
cleanup_dry_runtotrueto simulate cleanup without actually deleting resources. -
Use the
app installcommand to install thecleanup-volumesapp:> app install cleanup-volumesinfoFix Inventory will create a default config
fix.apps.cleanup_volumes. -
Execute the following command in Fix Inventory Shell to open the infrastructure app configuration for editing:
> config edit fix.apps.cleanup_volumes -
Update the configuration with the desired volume age threshold:
cleanup_volumes configurationmin_age: 14d -
Run the app using the
app runcommand:> app run cleanup-volumestipAdd the optional
--dry-runflag to see what commands the app would perform, without actually executing them. -
Create an event-based job to run the app automatically:
> jobs create --name "Clean Up Storage Volumes" --wait-for-event cleanup_plan 'app run cleanup_volumes'infoThe
cleanup-volumesinfrastructure app will now run each time Fix Inventory emits thecleanup_planevent. Thepost_cleanup_planevent is emitted in thecleanupphase of thecollect_and_cleanupworkflow.
Each time the cleanup-volumes infrastructure app runs, unused storage volumes will be flagged for removal during the next cleanup run.