clean up cinder on an unstack
cinder currently has issues that leave volumes around after tempest tests. Make sure that cinder gets cleaned up to a zero state on an unstack.sh so that we can reset the environment. Change-Id: I448340899bf0fae7d4d16fa26da17feafcef888f
This commit is contained in:
parent
701718a844
commit
252f2f533b
36
lib/cinder
36
lib/cinder
@ -51,8 +51,40 @@ VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
|
|||||||
# cleanup_cinder() - Remove residual data files, anything left over from previous
|
# cleanup_cinder() - Remove residual data files, anything left over from previous
|
||||||
# runs that a clean run would need to clean up
|
# runs that a clean run would need to clean up
|
||||||
function cleanup_cinder() {
|
function cleanup_cinder() {
|
||||||
# This function intentionally left blank
|
# ensure the volume group is cleared up because fails might
|
||||||
:
|
# leave dead volumes in the group
|
||||||
|
TARGETS=$(sudo tgtadm --op show --mode target)
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
# If tgt driver isn't running this won't work obviously
|
||||||
|
# So check the response and restart if need be
|
||||||
|
echo "tgtd seems to be in a bad state, restarting..."
|
||||||
|
if is_ubuntu; then
|
||||||
|
restart_service tgt
|
||||||
|
else
|
||||||
|
restart_service tgtd
|
||||||
|
fi
|
||||||
|
TARGETS=$(sudo tgtadm --op show --mode target)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$TARGETS" ]]; then
|
||||||
|
iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') )
|
||||||
|
for i in "${iqn_list[@]}"; do
|
||||||
|
echo removing iSCSI target: $i
|
||||||
|
sudo tgt-admin --delete $i
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_service_enabled cinder; then
|
||||||
|
sudo rm -rf $CINDER_STATE_PATH/volumes/*
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_ubuntu; then
|
||||||
|
stop_service tgt
|
||||||
|
else
|
||||||
|
stop_service tgtd
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo vgremove -f $VOLUME_GROUP
|
||||||
}
|
}
|
||||||
|
|
||||||
# configure_cinder() - Set config files, create data dirs, etc
|
# configure_cinder() - Set config files, create data dirs, etc
|
||||||
|
31
unstack.sh
31
unstack.sh
@ -71,36 +71,7 @@ SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
|
|||||||
|
|
||||||
# Get the iSCSI volumes
|
# Get the iSCSI volumes
|
||||||
if is_service_enabled cinder; then
|
if is_service_enabled cinder; then
|
||||||
TARGETS=$(sudo tgtadm --op show --mode target)
|
cleanup_cinder
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
# If tgt driver isn't running this won't work obviously
|
|
||||||
# So check the response and restart if need be
|
|
||||||
echo "tgtd seems to be in a bad state, restarting..."
|
|
||||||
if is_ubuntu; then
|
|
||||||
restart_service tgt
|
|
||||||
else
|
|
||||||
restart_service tgtd
|
|
||||||
fi
|
|
||||||
TARGETS=$(sudo tgtadm --op show --mode target)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$TARGETS" ]]; then
|
|
||||||
iqn_list=( $(grep --no-filename -r iqn $SCSI_PERSIST_DIR | sed 's/<target //' | sed 's/>//') )
|
|
||||||
for i in "${iqn_list[@]}"; do
|
|
||||||
echo removing iSCSI target: $i
|
|
||||||
sudo tgt-admin --delete $i
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_service_enabled cinder; then
|
|
||||||
sudo rm -rf $CINDER_STATE_PATH/volumes/*
|
|
||||||
fi
|
|
||||||
|
|
||||||
if is_ubuntu; then
|
|
||||||
stop_service tgt
|
|
||||||
else
|
|
||||||
stop_service tgtd
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$UNSTACK_ALL" ]]; then
|
if [[ -n "$UNSTACK_ALL" ]]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user