Skip to content

Commit

Permalink
handle PROLOG_MIGRATE_UNKNOWN
Browse files Browse the repository at this point in the history
When we are called in PROLOG_MIGRATE_UNKNOWN LCM state the SRC_HOST
is most probably DOWN so run detach command on DST host.

Hopefully a proposed patch to call tm/mv bofore trying to boot VM
from failed Host will be merged [pull request #70](OpenNebula/one#70)
to utilize this feature
  • Loading branch information
atodorov-storpool committed Aug 31, 2015
1 parent 9f87047 commit adb15b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tm/storpool/mv
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ DST_DIR=`dirname $DST_PATH`
DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}')
IS_DISK=`is_disk $DST_PATH`

#default detach action
DETACH_ACTION="DETACH"

#-------------------------------------------------------------------------------
# Get Datastore information
#-------------------------------------------------------------------------------
Expand All @@ -74,8 +77,17 @@ fi
if [ $LCM_STATE = "30" ]; then
DETACH_ONLY="END (LCM_STATE=$LCM_STATE EPILOG_UNDEPLOY)"
fi
#-------------------------------------------------------------------------------
# run only ATTACH_CMD on PROLOG_UNDEPLOY
#-------------------------------------------------------------------------------
if [ $LCM_STATE = "31" ]; then
ATTACH_ONLY="(LCM_STATE=$LCM_STATE EPILOG_UNDEPLOY)"
ATTACH_ONLY="(LCM_STATE=$LCM_STATE PROLOG_UNDEPLOY)"
fi
#-------------------------------------------------------------------------------
# run DETACH on DST host on PROLOG_MIGRATE_UNKNOWN
#-------------------------------------------------------------------------------
if [ $LCM_STATE = "60" ]; then
DETACH_ACTION="DETACH_VIA_DST"
fi

#-------------------------------------------------------------------------------
Expand All @@ -92,7 +104,7 @@ if [ "$DS_TEMPLATE_TYPE" = "SYSTEM_DS" ]; then
if [ -n "$ATTACH_ONLY" ]; then
splog "$ATTACH_ONLY"
else
storpoolAction "DETACH" "$SRC_HOST" "$DST_HOST" "$SP_VOL"
storpoolAction "$DETACH_ACTION" "$SRC_HOST" "$DST_HOST" "$SP_VOL"
fi
if [ -n "$DETACH_ONLY" ]; then
splog "$DETACH_ONLY"
Expand Down Expand Up @@ -131,7 +143,7 @@ if [ "$DS_TEMPLATE_TYPE" = "SYSTEM_DS" ]; then
if [ -n "$ATTACH_ONLY" ]; then
splog "$ATTACH_ONLY"
else
storpoolAction "DETACH" "$SRC_HOST" "$DST_HOST" "$SP_VOL"
storpoolAction "$DETACH_ACTION" "$SRC_HOST" "$DST_HOST" "$SP_VOL"
fi
if [ -n "$DETACH_ONLY" ]; then
splog "$DETACH_ONLY"
Expand All @@ -147,7 +159,7 @@ else
if [ -n "$ATTACH_ONLY" ]; then
splog "$ATTACH_ONLY"
else
storpoolAction "DETACH" "$SRC_HOST" "$DST_HOST" "$SP_VOL" "$DST_PATH"
storpoolAction "$DETACH_ACTION" "$SRC_HOST" "$DST_HOST" "$SP_VOL" "$DST_PATH"
fi
fi

Expand All @@ -166,6 +178,7 @@ fi

SP_VOL="${SOURCE##*/}"
[ -n "$PERSISTENT" ] || SP_VOL+="-${VM_ID}-${DISK_ID}"

storpoolAction "ATTACH" "$SRC_HOST" "$DST_HOST" "$SP_VOL" "$DST_PATH"

splog "END"
Expand Down
4 changes: 4 additions & 0 deletions tm/storpool/storpool_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ EOF
_HOST="$_SRC_HOST"
_CMD="$_BEGIN$_DETACH_ALL"
;;
DETACH_VIA_DST)
_HOST="$_DST_HOST"
_CMD="$_BEGIN$_DETACH_ALL"
;;
ATTACH)
_HOST="$_DST_HOST"
_CMD="$_BEGIN$_ATTACH$_SYMLINK"
Expand Down

0 comments on commit adb15b8

Please sign in to comment.