progetti:cloud-areapd:operations:manual_delete_cinder_volumes
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| progetti:cloud-areapd:operations:manual_delete_cinder_volumes [2015/06/18 07:07] – dorigoa@infn.it | progetti:cloud-areapd:operations:manual_delete_cinder_volumes [2017/05/22 15:09] (current) – fanzago@infn.it | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Manual delete Cinder Volumes ====== | ||
| + | Author: | ||
| + | * Alvise Dorigo (INFN Padova) | ||
| + | |||
| + | |||
| + | There are cases, not easily reproducible, | ||
| + | |||
| + | The following procedure (a perl script) erases any information about a problematic volume by "brute force", | ||
| + | |||
| + | **Note1**: the procedure isn't flawless; it only touches the cinder' | ||
| + | Of course, the script checks that non-negative values are put in the '' | ||
| + | So the suggestion is to do a precautionary backup of the '' | ||
| + | |||
| + | **Note2**: the script doesn' | ||
| + | |||
| + | **Note3**: in the script pasted below, the DB_HOSTNAME, | ||
| + | |||
| + | **Note4**: to run the script you need to install '' | ||
| + | |||
| + | <code perl> | ||
| + | #/ | ||
| + | |||
| + | use DBI; | ||
| + | |||
| + | $VOLUME_UUID = $ARGV[0]; | ||
| + | if($VOLUME_UUID eq "" | ||
| + | { | ||
| + | print " | ||
| + | exit 1; | ||
| + | }; | ||
| + | |||
| + | $dsn = " | ||
| + | |||
| + | $dbh = DBI-> | ||
| + | |||
| + | # | ||
| + | # Get the project ID and size of the volume to delete | ||
| + | # | ||
| + | $query_get_project_id_from_volume = " | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | $ref = $sth-> | ||
| + | $size = $ref-> | ||
| + | $tenant = $ref-> | ||
| + | $volname = $ref-> | ||
| + | $status = $ref-> | ||
| + | $deleted = $ref-> | ||
| + | if($status eq " | ||
| + | print "The volume [$VOLUME_UUID] seems already deleted. Stop.\n"; | ||
| + | exit 0; | ||
| + | } | ||
| + | |||
| + | print " | ||
| + | $sth-> | ||
| + | |||
| + | # | ||
| + | # Get the number of snapshots related to the current volume to delete (they must be deleted also) | ||
| + | # | ||
| + | $count_snap_related_to_volume_query = " | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | @rows = $sth-> | ||
| + | $num_of_snapshots = $rows[0]; | ||
| + | $sth-> | ||
| + | |||
| + | # | ||
| + | # Prepare delete and quota update queries | ||
| + | # | ||
| + | $mark_voldeleted_query | ||
| + | $mark_snapdeleted_query | ||
| + | $get_quota_usage_gb_query | ||
| + | $get_quota_usage_vol_query | ||
| + | $get_quota_usage_snaps_query = " | ||
| + | print "Going to modify cinder_prod.volumes and cinder_prod.snapshots tables. Are you sure ? Press < | ||
| + | my $resp = < | ||
| + | # | ||
| + | # First delete snapshot | ||
| + | # | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | $sth-> | ||
| + | |||
| + | # | ||
| + | # Second delete volume | ||
| + | # | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | $sth-> | ||
| + | |||
| + | # | ||
| + | # Get info about Volume GB quota usage (which includes the snapshots) | ||
| + | # | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | @result = $sth-> | ||
| + | $in_use_gb = $result[0]; | ||
| + | $sth-> | ||
| + | |||
| + | # | ||
| + | # Get the number of volumes | ||
| + | # | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | @result = $sth-> | ||
| + | $in_use_vol = $result[0]; | ||
| + | $sth-> | ||
| + | |||
| + | # | ||
| + | # Get the number of snapshots | ||
| + | # | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | @result = $sth-> | ||
| + | $in_use_snaps= $result[0]; | ||
| + | $sth-> | ||
| + | |||
| + | #print " | ||
| + | |||
| + | $in_use_vol--; | ||
| + | $in_use_gb -= $size + ($size*$num_of_snapshots); | ||
| + | $in_use_snaps -= $num_of_snapshots; | ||
| + | |||
| + | if($in_use_vol< | ||
| + | $in_use_vol = 0; | ||
| + | } | ||
| + | if($in_use_gb< | ||
| + | $in_use_gb = 0; | ||
| + | } | ||
| + | if($in_use_snaps< | ||
| + | $in_use_snaps = 0; | ||
| + | } | ||
| + | |||
| + | #print " | ||
| + | |||
| + | $update_quota_vol | ||
| + | $update_quota_gb | ||
| + | $update_quota_snaps = " | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | $sth-> | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | $sth-> | ||
| + | $sth = $dbh-> | ||
| + | $sth-> | ||
| + | $sth-> | ||
| + | |||
| + | $dbh-> | ||
| + | </ | ||
