Bug #326
tm_ssh removes ${ONE_LOCATION}/var
Status: | Closed | Start date: | 08/24/2010 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | - | % Done: | 100% | |
Category: | - | |||
Target version: | - | |||
Resolution: | fixed | Pull request: | ||
Affected Versions: |
Description
Hello, I just tried to fetch, build and run latest checkout of OpenNebula 2.0 from git. When I try to deploy a VM, something from CLI or OCA removes ${ONE_LOCATION}/var directory, which contains all logs and daemon pids.
This is how I download, compile and install Opennebula:
bash-4.1$ git branch master * one-2.0 -bash-4.1$ git pull Already up-to-date. -bash-4.1$ scons mysql=yes -j8 ... -bash-4.1$ echo $? 0 -bash-4.1$ whoami one -bash-4.1$ pwd /home/one/one.git -bash-4.1$ /sbin/rm -rf ~/local -bash-4.1$ mkdir ~/local -bash-4.1$ ./install.sh -d ~/local
I prepared rm
wrapper:
-bash-4.1$ cat > ~/local/bin/rm <<EOF #!/bin/bash echo "$@" >> /tmp/rmlog /bin/rm "$@" EOF -bash-4.1$ chmod +x ~/local/bin/rm -bash-4.1$ echo $PATH /home/one/local/bin:/home/one/lo/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
This is exact content of my ~/local/etc/oned.conf
:
VM_POLLING_INTERVAL = 600 VM_DIR=/home/one/vms PORT=2633 DB = [ backend = "mysql", server = "localhost", user = "oneadmin", passwd = "censored", db_name = "opennebula" ] VNC_BASE_PORT = 5000 DEBUG_LEVEL=3 NETWORK_SIZE = 254 MAC_PREFIX = "02:00" IMAGE_REPOSITORY_PATH = /home/one/repository DEFAULT_IMAGE_TYPE = "OS" DEFAULT_DEVICE_PREFIX = "hd" IM_MAD = [ name = "im_kvm", executable = "one_im_ssh", arguments = "im_kvm/im_kvm.conf" ] VM_MAD = [ name = "vmm_kvm", executable = "one_vmm_kvm", default = "vmm_kvm/vmm_kvm.conf", type = "kvm" ] TM_MAD = [ name = "tm_ssh", executable = "one_tm", arguments = "tm_ssh/tm_ssh.conf" ] HM_MAD = [ executable = "one_hm" ]
I cleaned up the DB to be sure:
# echo 'drop database opennebula;' | mysql -u root -p Enter password: #
And now, this is the problem:
-bash-4.1$ one start oned and scheduler started -bash-4.1$ ls ~/local/var oned.log oned.pid sched.log sched.pid -bash-4.1$ onehost create tchitchi im_kvm vmm_kvm tm_ssh -bash-4.1$ onevnet create ~/templates/net.lan1 -bash-4.1$ onehost show 0 | grep STATE STATE : MONITORED -bash-4.1$ > /tmp/rmlog -bash-4.1$ onevm submit ~/templates/vm.ubuntu -bash-4.1$ onevm show 0 | grep STATE STATE : ACTIVE LCM_STATE : PROLOG -bash-4.1$ onevm show 0 | grep STATE STATE : FAILED LCM_STATE : LCM_INIT -bash-4.1$ ls ~/local/var ls: cannot access /home/one/local/var: No such file or directory -bash-4.1$ cat /tmp/rmlog -rf /home/one/local//var/ -bash-4.1$
Obviously, something deleted ${ONE_LOCATION}/var directory which should NOT happen. If you need more info for this issue, I gladly help.
Associated revisions
Modified AWK path (#326)
History
#1 Updated by Martin Kopta almost 11 years ago
I placed some probes into lib/tm_commands/ssh/tm_*
and the bad one is tm_context.sh
:
-bash-4.1$ cat /tmp/onelog tm_context.sh: rm -rf /home/one/local//var/
So I placed some more probes into tm_context.sh
and I have got:
-bash-4.1$ cat /tmp/onelog tm_context.sh: DST_PATH = /home/one/vms/4/images/disk.1 tm_context.sh: DST_DIR = /home/one/vms/4/images tm_context.sh: DST_FILE = disk.1 tm_context.sh: DST = tchitchi:/home/one/vms/4/images/disk.1 tm_context.sh: MD5SUM = /usr/bin/md5sum tm_context.sh: AWK = /usr/bin/awk tm_context.sh: DST_HASH = tm_context.sh: TMP_DIR = /home/one/local//var/ tm_context.sh: ISO_DIR = /home/one/local//var//isofiles tm_context.sh: rm -rf /home/one/local//var
The problem is caused by unset DST_HASH
, which is caused by missing AWK
:
-bash-4.1$ /usr/bin/awk -bash: /usr/bin/awk: No such file or directory -bash-4.1$ which awk /bin/awk
Proposed patch:
diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh index 5caba58..df904ad 100644 --- a/src/tm_mad/tm_common.sh +++ b/src/tm_mad/tm_common.sh @@ -23,7 +23,7 @@ else fi # Paths for utilities -AWK=/usr/bin/awk +AWK=$(which awk) BASH=/bin/bash DATE=/bin/date DD=/bin/dd
Or the awk
could be thrown away since its pretty overkill here.
diff --git a/src/tm_mad/ssh/tm_context.sh b/src/tm_mad/ssh/tm_context.sh index b420be3..c20b300 100755 --- a/src/tm_mad/ssh/tm_context.sh +++ b/src/tm_mad/ssh/tm_context.sh @@ -41,7 +41,7 @@ fi DST_PATH=`arg_path $DST` DST_DIR=`dirname $DST_PATH` DST_FILE=`basename $DST_PATH` -DST_HASH=`echo -n $DST | $MD5SUM | $AWK '{print $1}'` +DST_HASH=`echo -n $DST | $MD5SUM | $CUT -d" " -f1 TMP_DIR="$ONE_LOCATION/var/$DST_HASH" ISO_DIR="$TMP_DIR/isofiles" diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh index 5caba58..f443c01 100644 --- a/src/tm_mad/tm_common.sh +++ b/src/tm_mad/tm_common.sh @@ -24,6 +24,7 @@ fi # Paths for utilities AWK=/usr/bin/awk +CUT=$(which cut) BASH=/bin/bash DATE=/bin/date DD=/bin/dd
Program cut
is part of coreutils
and it is also much smaller and does not have bazilions dialects.
Thank you,
Martin Kopta
#2 Updated by Jaime Melis almost 11 years ago
- Priority changed from High to Normal
- % Done changed from 0 to 100
- Resolution set to fixed
Thanks for reporting the bug and proposing the solution. What I did was to remove awk's default path, since it varies from distro to distro. In case someone does not have 'awk' in their path the can modify $ONE_LOCATION/lib/mads/tm_common.sh and set it there, adapted to their distribution.
#3 Updated by Jaime Melis almost 11 years ago
- Status changed from New to Closed