Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove temp dir #575

Closed
goldzahn opened this issue Apr 14, 2015 · 3 comments
Closed

remove temp dir #575

goldzahn opened this issue Apr 14, 2015 · 3 comments
Assignees
Labels
enhancement Adaptions and new features
Milestone

Comments

@goldzahn
Copy link
Contributor

goldzahn commented Apr 14, 2015

Hi,

on every server I have the problem that
/tmp/rear.XXXXXXXXX/outputfs/servername/ is not empty,
because of the file ".lockfile", so rmdir is never successful (see #298)

The solution of #298 was to add rm -Rf $BUILD_DIR/outputfs
in function cleanup_build_area_and_end_program()
in usr/share/rear/lib/framework-functions.sh
but this lead to problems mentioned in #465,
so it was changed to rmdir $v $BUILD_DIR/outputfs >&2

Looking at function cleanup_build_area_and_end_program() in usr/share/rear/lib/framework-functions.sh:

...
   # line below put in comment due to issue #465
   #rm -Rf $BUILD_DIR/outputfs
   rmdir $v $BUILD_DIR/outputfs >&2
   # in worst case it could not umount; so before remove the BUILD_DIR check if above outputfs is  gone
   mount | grep -q "$BUILD_DIR/outputfs"
   if [[ $? -eq 0 ]]; then
      # still mounted it seems
      LogPrint "Directory $BUILD_DIR/outputfs still mounted - trying lazy umount"  
      sleep 2
      umount -f -l $BUILD_DIR/outputfs >&2
      rmdir $v $BUILD_DIR/outputfs >&2
   fi
   rmdir $v $BUILD_DIR >&2
fi
Log "End of program reached"

Wouldn't it be better to drop the first
rmdir $v $BUILD_DIR/outputfs >&2
and to add
rm -Rf $BUILD_DIR/outputfs
in case $BUILD_DIR/outputfs is not mounted?

... 
   # line below put in comment due to issue #465
   #rm -Rf $BUILD_DIR/outputfs
   # in worst case it could not umount; so before remove the BUILD_DIR check if above outputfs is gone
   mount | grep -q "$BUILD_DIR/outputfs"
   if [[ $? -eq 0 ]]; then
        # still mounted it seems
        LogPrint "Directory $BUILD_DIR/outputfs still mounted - trying lazy umount"
        sleep 2
        umount -f -l $BUILD_DIR/outputfs >&2
        rmdir $v $BUILD_DIR/outputfs >&2
   else 
        # not mounted so we can safely delete $BUILD_DIR/outputfs
        rm -Rf $BUILD_DIR/outputfs
   fi
   rmdir $v $BUILD_DIR >&2
fi
Log "End of program reached"

So if $BUILD_DIR/outputfs is not mounted,
then rm -Rf $BUILD_DIR/outputfs can safely be used,
otherwise rmdir $v $BUILD_DIR/outputfs would be used.

What do you think?

Regards
goldzahn

@gdha gdha added the enhancement Adaptions and new features label Apr 20, 2015
@gdha gdha added this to the Rear v1.17.1 milestone Apr 20, 2015
@gdha gdha self-assigned this Apr 20, 2015
@gdha
Copy link
Member

gdha commented Apr 20, 2015

@goldzahn good thinking - why not. Will you prepare a pull request for this? Thank you for your proposal of a proper fix for the issues around the cleanup of the temporary directory

@gdha
Copy link
Member

gdha commented May 31, 2015

@goldzahn Can we close this issue?

@goldzahn goldzahn closed this as completed Jun 2, 2015
@goldzahn
Copy link
Contributor Author

goldzahn commented Jun 2, 2015

@gdha Sure.
Regards
goldzahn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adaptions and new features
Projects
None yet
Development

No branches or pull requests

2 participants