abhishek misra
2009-Nov-10 13:41 UTC
[Ovirt-devel] [RFC][PATCH] ovirt-node-image : edit-livecd : fail on error in arbitrary code
Purpose : fail iso build on encountering error in arbitrary code '$CODE' 1. export 'WDIR' , for 'CODE' to pick-up location to create 'fail' file to indicate failure, note that it may not always be possible to return some error code on failure in 'CODE' 2. 'set' commands enclosing 'CODE' will not be required 3. 'CODE' is expected to use 'set -e and trap signals like EXIT (which are generated when some command fails ) and write a 'fail' file 4. look for 'fail' file once 'CODE' has completed if positive then unmount proc ( note that if 'CODE', proc still remains mounted; this is not unmounted by existing trap in edit-livecd script ) rest of the cleanup is taken care off by existing trap statement Signed-off-by: Abhishek Misra <fishy at linux.vnet.ibm.com> --- --- a/edit-livecd 2009-11-10 17:23:21.000000000 +0530 +++ b/edit-livecd 2009-11-10 18:39:11.000000000 +0530 @@ -159,13 +159,14 @@ cp -pr $WDIR/sq $WDIR/sq-w # mount root filesystem mnt "-t ext2 $WDIR/sq-w/LiveOS/ext3fs.img -o rw,loop" ex +# exporting for tarp in 'CODE' +# $CODE can 'trap' EXIT signal and touch '$WDIR/fail' to notify this script of its failure + echo ">>> Updating CD content" if [ -n "$CODE" ]; then ( cd $WDIR/ex - set +e eval "$CODE" - set -e ) else echo "***" @@ -174,6 +175,14 @@ else read fi +# exit if $CODE failed. Look if '$WDIR/fail' exists +if [ -a $WDIR/fail ] ; then + rm $WDIR/fail + # need to explictly look for proc as failure in $CODE leaves it mounted causing 'umount $WDIR/ex-rw' to fail + mount | grep livecd | grep proc && addExit "umount -v $WDIR/ex-rw/proc" + exit +fi + # Try to unmount. But this is likely to fail, so let the user retry, # e.g., if he forgot to "cd" out of $WDIR/ex. while :; do
David Huff
2009-Nov-11 21:46 UTC
[Ovirt-devel] [RFC][PATCH] ovirt-node-image : edit-livecd : fail on error in arbitrary code
I took a look at this today, I am not sure that a requirement for 'CODE' to touch a "fail" file is the best way to address this. I assume your script is mounting proc inside the ext filesystem, ie to use yum or something. And using trap and a similar mnt function, like what is in edit-livecd, is not cleaning up all the mounts in this case? A fix may be to use /proc/mounts instead of df when adding the Exits in the mnt function. Also can you clarify the statement, "note that it may not always be possible to return some error code on failure in 'CODE'" I am not really sure what you mean here. Does this make sense? -D On 11/10/2009 08:41 AM, abhishek misra wrote:> Purpose : fail iso build on encountering error in arbitrary code '$CODE' > > 1. export 'WDIR' , for 'CODE' to pick-up location to create 'fail' > file to indicate failure, note that it may not always be possible to > return some error code on failure in 'CODE' > 2. 'set' commands enclosing 'CODE' will not be required > 3. 'CODE' is expected to use 'set -e and trap signals like EXIT > (which are generated when some command fails ) and write a 'fail' file > 4. look for 'fail' file once 'CODE' has completed > if positive then unmount proc ( note that if 'CODE', proc still > remains mounted; this is not unmounted by existing trap in edit-livecd > script ) > rest of the cleanup is taken care off by existing trap statement > > Signed-off-by: Abhishek Misra <fishy at linux.vnet.ibm.com> > > --- > > --- a/edit-livecd 2009-11-10 17:23:21.000000000 +0530 > +++ b/edit-livecd 2009-11-10 18:39:11.000000000 +0530 > @@ -159,13 +159,14 @@ cp -pr $WDIR/sq $WDIR/sq-w > # mount root filesystem > mnt "-t ext2 $WDIR/sq-w/LiveOS/ext3fs.img -o rw,loop" ex > > +# exporting for tarp in 'CODE' > +# $CODE can 'trap' EXIT signal and touch '$WDIR/fail' to notify this > script of its failure > + > echo ">>> Updating CD content" > if [ -n "$CODE" ]; then > ( > cd $WDIR/ex > - set +e > eval "$CODE" > - set -e > ) > else > echo "***" > @@ -174,6 +175,14 @@ else > read > fi > > +# exit if $CODE failed. Look if '$WDIR/fail' exists > +if [ -a $WDIR/fail ] ; then > + rm $WDIR/fail > + # need to explictly look for proc as failure in $CODE leaves it > mounted causing 'umount $WDIR/ex-rw' to fail > + mount | grep livecd | grep proc && addExit "umount -v > $WDIR/ex-rw/proc" > + exit > +fi > + > # Try to unmount. But this is likely to fail, so let the user retry, > # e.g., if he forgot to "cd" out of $WDIR/ex. > while :; do > > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-devel
Alan Pevec
2009-Dec-21 08:45 UTC
[Ovirt-devel] [RFC][PATCH v2] edit-livecd : fail on error in arbitrary code
Hi, On Sun, Dec 20, 2009 at 6:50 AM, fishy <fishy at linux.vnet.ibm.com> wrote:> Thank You Alan, I however did not find the said patch in here > http://git.et.redhat.com/?p=ovirt-node-image.git;a=summary > > Is there some place else its supposed to go ?two things: - we moved oVirt GIT repositories to Fedorahosted, mapping is http://git.et.redhat.com/?p=ovirt-<SUBREPO>.git;a=summary -> <http://git.et.redhat.com/?p=ovirt-node-image.git;a=summary> http://git.fedorahosted.org/git/ovirt/?p=ovirt/<SUBREPO>.git;a=summary i.e. node repositories: http://git.fedorahosted.org/git/ovirt/?p=ovirt/node.git;a=summary http://git.fedorahosted.org/git/ovirt/?p=ovirt/node-image.git;a=summary - node-image scripts are now in http://git.fedorahosted.org/git/ovirt/?p=ovirt/node.git;a=tree;f=tools;hb=next node-image.git is now just a wrapper to include oVirt node image: http://git.fedorahosted.org/git/ovirt/?p=ovirt/node-image.git;a=blob;f=README;hb=next Please bear with us while we're updating documentation to reflect those changes. Thanks, Alan Pevec -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20091221/f2c15807/attachment.htm>
Reasonably Related Threads
- [PATCH ovirt-node-image] fixes for edit-livecd
- [PATCH] edit-livecd in python
- [PATCH node-image] Fix edit-livecd to re-create ext2 filesystem each time
- Refactor ovirt-node-image code base for inclusion in Fedora
- Refactor ovirt-node code base for inclusion in Fedora