fixed adopt tests - still need hand-holding
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 26 Jun 2014 12:41:45 +0000 (14:41 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 26 Jun 2014 12:41:45 +0000 (14:41 +0200)
README
bin/adopt
sbin/lvrename

diff --git a/README b/README
index 06e1006..fbd7e81 100644 (file)
--- a/README
+++ b/README
@@ -57,4 +57,6 @@ KNOWN BUGS for extstorage
 KNOWN BUGS for using -t plain on top of zfs
 
 - cron/daily-block-snapshot snapshots are not correctly renamed
 KNOWN BUGS for using -t plain on top of zfs
 
 - cron/daily-block-snapshot snapshots are not correctly renamed
+- bin/adopt will create new zvol using send/receive to break dependency on origin
+  but vm disks should be promoted, and adopt zvol deleted manually
 
 
index 7de0f50..030a56c 100755 (executable)
--- a/bin/adopt
+++ b/bin/adopt
@@ -2,4 +2,6 @@
 
 . /usr/share/ganeti/extstorage/zfs/defaults.sh
 
 
 . /usr/share/ganeti/extstorage/zfs/defaults.sh
 
-./bin/snap | iselect -p 2 -a -n 'adopt snapshot' | awk '{ print $1 }' | xargs -i sh -cx 'zfs clone {} '$EXTP_ZFS'/adopt && zfs set ganeti:originstname=`zfs get ganeti:originstname -o value -p -H {}`+adopt '$EXTP_ZFS'/adopt'
+zfs list -t snapshot -r -r $EXTP_ZFS -o name -H \
+| iselect -p 1 -a -n 'adopt snapshot' \
+| xargs -i sh -cx 'zfs send -R {} | zfs receive '$EXTP_ZFS'/adopt && zfs set ganeti:originstname="`zfs get ganeti:originstname -o value -p -H {}`+adopt" '$EXTP_ZFS'/adopt && zfs set lv:a="-" '$EXTP_ZFS'/adopt'
index ae39a4e..8a10502 100755 (executable)
@@ -1,12 +1,17 @@
-#!/bin/sh -e
+#!/bin/sh -ex
 
 . /usr/share/ganeti/extstorage/zfs/defaults.sh
 
 # lvrename ffzgvg cc9b16d9-7d14-452a-9150-74521bd8e721.disk0 d275c91f-70a7-4270-972c-b020fde9580b.disk0_data
 
 if [ "$EXTP_VG" = "$1" ] ; then
 
 . /usr/share/ganeti/extstorage/zfs/defaults.sh
 
 # lvrename ffzgvg cc9b16d9-7d14-452a-9150-74521bd8e721.disk0 d275c91f-70a7-4270-972c-b020fde9580b.disk0_data
 
 if [ "$EXTP_VG" = "$1" ] ; then
-       zfs rename $EXTP_ZFS/$2 $EXTP_ZFS/$3
-       # FIXME handle renaming of desceding snapshots
+       # delete snapshots which can't be renamed
+
+       zfs rename $EXTP_ZFS/$2 $EXTP_ZFS/$3 || (
+               # rename filesystems with snapshots using clone/promote
+               zfs snap  $EXTP_ZFS/$2@$3
+               zfs clone $EXTP_ZFS/$2@$3 $EXTP_ZFS/$3
+       )
 else
        /sbin/lvm lvrename $*
 fi
 else
        /sbin/lvm lvrename $*
 fi