Bug #1044

ssh tm - image should not be deleted after mv failure

Added by Grzegorz Kocur over 9 years ago. Updated over 9 years ago.

Status:ClosedStart date:12/27/2011
Priority:NormalDue date:
Assignee:Javi Fontan% Done:

0%

Category:Drivers - Auth
Target version:Release 3.2
Resolution:worksforme Pull request:
Affected Versions:OpenNebula 3.0

Description

If using persistent images and ssh TM the image is transferred to destination host, and transferred back to ONE host after undeploy. If something goes wrong while moving the image back the image is deleted on destination host and all changes in image are lost.

I think this small hack should work.


--- tm_mv.sh.org    2011-12-27 11:32:55.888460191 +0100
+++ tm_mv.sh    2011-12-27 11:36:14.860457937 +0100
@@ -40,4 +40,9 @@
     "Unable to create directory $DST_DIR" 
 exec_and_log "$SCP -r $SRC $DST" \
     "Could not copy $SRC to $DST" 
-exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH" 
+code=$?
+    if [ "x$code" != "x0" ]; then
+    exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH" 
+else
+    log "Moving $SRC_PATH failed. Move $SRC_PATH manually:" 
+fi

History

#1 Updated by Grzegorz Kocur over 9 years ago

There should be "=" instead "!=" in the test of course.

#2 Updated by Ruben S. Montero over 9 years ago

  • Status changed from New to Assigned
  • Assignee set to Javi Fontan
  • Target version set to Release 3.2

#3 Updated by Javi Fontan over 9 years ago

  • Status changed from Assigned to Closed
  • Resolution set to worksforme

exec_and_log exits the script if there are error executing the command so that check is not needed.

Also available in: Atom PDF