Skip to content

Conversation

@goldzahn
Copy link
Contributor

Hi,

this is the pull request for #575 to delete $BUILD_DIR/outputfs if it is not mounted anymore.

regards
goldzahn

@gdha gdha added the enhancement Adaptions and new features label Apr 22, 2015
@gdha gdha added this to the Rear v1.17.1 milestone Apr 22, 2015
@gdha gdha self-assigned this Apr 22, 2015
gdha added a commit that referenced this pull request Apr 22, 2015
rm -Rf $BUILD_DIR/outputfs if it is not mounted anymore
@gdha gdha merged commit 2e654a4 into rear:master Apr 22, 2015
@pcahyna
Copy link
Member

pcahyna commented May 26, 2021

I am curious how this can happen. If the filesystem is unmounted, there should not be any file left under the mountpoint, unless $BUILD_DIR/outputfs has not been a mountpoint at all and .lockfile got created in the local filesystem, which would indicate a bug (if $BUILD_DIR/outputfs is not a mounted filesystem and we put files under it, the files will just get lost).

@pcahyna
Copy link
Member

pcahyna commented May 26, 2021

What is actually the purpose of .lockfile? The only use seems to be to prevent double moves of the result directory if $OUTPUT_URL == $BACKUP_URL and NETFS_KEEP_OLD_BACKUP_COPY and KEEP_OLD_OUTPUT_COPY are used (and what will hapen if the former is set and the latter is unset?).

@jsmeix
Copy link
Member

jsmeix commented May 27, 2021

@pcahyna
I don't know what the actual purpose of .lockfile is.
I would have to reverse engineer it by digging its actual usage in the code.
At first glance I found
https://github.com/rear/rear/blob/master/usr/share/rear/output/default/250_create_lock.sh
see the initial comment therein.
I never used KEEP_OLD_OUTPUT_COPY.
I only tried out NETFS_KEEP_OLD_BACKUP_COPY at some longer time ago
cf. what I wrote about "Regarding NETFS_KEEP_OLD_BACKUP_COPY" in
https://en.opensuse.org/SDB:Disaster_Recovery

@pcahyna
Copy link
Member

pcahyna commented May 27, 2021

@jsmeix I saw that comment and I don't understand it, because here

[[ -f ${opath}/.lockfile ]] && rm -f ${opath}/.lockfile >&2
the lockfile gets just removed if it exists, so I don't see how can it avoid anything.

pcahyna added a commit to pcahyna/rear that referenced this pull request May 28, 2021
Instead of special code in cleanup_build_area_and_end_program(), use the
shared helper to remove $BUILD_DIR/outputfs. This translates to using
rmdir always instead of using rm -Rf in case the filesystem is not
mounted. This is simpler and safer (disaster could arise if the
mointpoint command fails for any unexpected reason, for example).

It intentionally reverts PR rear#578 (commit
606d8ce). It is not clear why was
.lockfile present in the unmounted outputfs (this was the reason for the
change). According to my understanding of the code, this should not
happen. Even if this happens, it means that some part of the code is
using outputfs incorrectly (it should be used only if mounted, otherwise
data put there are lost) andf it is better to be warned about the
problem rather than ignore it by blindly removing the whole directory.
pcahyna added a commit to pcahyna/rear that referenced this pull request Jun 4, 2021
Instead of special code in cleanup_build_area_and_end_program(), use the
shared helper to remove $BUILD_DIR/outputfs. This translates to using
rmdir always instead of using rm -Rf in case the filesystem is not
mounted. This is simpler and safer (disaster could arise if the
mountpoint command fails for any unexpected reason, for example).

It intentionally reverts PR rear#578 (commit
606d8ce). It is not clear why was
.lockfile present in the unmounted outputfs (this was the reason for the
change). According to my understanding of the code, this should not
happen. Even if this happens, it means that some part of the code is
using outputfs incorrectly (it should be used only if mounted, otherwise
data put there are lost) and it is better to be warned about the
problem rather than ignoring it by blindly removing the whole directory.
@gdha
Copy link
Member

gdha commented Jun 11, 2021

@pcahyna

What is actually the purpose of .lockfile? The only use seems to be to prevent double moves of the result directory if $OUTPUT_URL == $BACKUP_URL and NETFS_KEEP_OLD_BACKUP_COPY and KEEP_OLD_OUTPUT_COPY are used (and what will hapen if the former is set and the latter is unset?).

I guess that this is the use case indeed to prevent overwriting of logs. The KEEP_OLD_OUTPUT_COPY variable I never used (and to be honest did not know it existed which proofs that even I is out-of-sync ;-) with all the ReaR attributes). Sig...

In script https://github.com/rear/rear/blob/master/usr/share/rear/output/default/150_save_copy_of_prefix_dir.sh I think it would be wiser to remove the lines

# an old lockfile from a previous run not cleaned up by output is possible
[[ -f ${opath}/.lockfile ]] && rm -f ${opath}/.lockfile >&2

Or, at least comment it out.

pcahyna added a commit to pcahyna/rear that referenced this pull request Jun 18, 2021
Instead of special code in cleanup_build_area_and_end_program(), use the
shared helper to remove $BUILD_DIR/outputfs. This translates to using
rmdir always instead of using rm -Rf in case the filesystem is not
mounted. This is simpler and safer (disaster could arise if the
mountpoint command fails for any unexpected reason, for example).

It intentionally reverts PR rear#578 (commit
606d8ce). It is not clear why was
.lockfile present in the unmounted outputfs (this was the reason for the
change). According to my understanding of the code, this should not
happen. Even if this happens, it means that some part of the code is
using outputfs incorrectly (it should be used only if mounted, otherwise
data put there are lost) and it is better to be warned about the
problem rather than ignoring it by blindly removing the whole directory.
pcahyna added a commit to pcahyna/rear that referenced this pull request Jun 18, 2021
Instead of special code in cleanup_build_area_and_end_program(), use the
shared helper to remove $BUILD_DIR/outputfs. This translates to using
rmdir always instead of using rm -Rf in case the filesystem is not
mounted. This is simpler and safer (disaster could arise if the
mountpoint command fails for any unexpected reason, for example).

It intentionally reverts PR rear#578 (commit
606d8ce). It is not clear why was
.lockfile present in the unmounted outputfs (this was the reason for the
change). According to my understanding of the code, this should not
happen. Even if this happens, it means that some part of the code is
using outputfs incorrectly (it should be used only if mounted, otherwise
data put there are lost) and it is better to be warned about the
problem rather than ignoring it by blindly removing the whole directory.
jsmeix added a commit that referenced this pull request Jun 18, 2021
…-updated

Fix backup removal in exit task and cleanup handling of URL mountpoints:
Cleanup of temporary mount point handling, particularly for output.
Unification of mount point umount and cleanup move
to the mount_url() and umount_url() functions.
Replaced the various "rm -rf" of the mountpoint by "rmdir" which fixes
#2611
Added lazy umount in case normal umount does not succeed.
If build dir is kept (cf. KEEP_BUILD_DIR), propose a safe way to remove it
to the user via "rm -Rf --one-file-system" instead of just "rm -Rf" where
the user risks to remove everything below that mountpoint if still mounted.
Fixes also some other bugs noted in the process:
Filesystem-specific umount command not called
20359a9#r51319634
Unknown schemes considered invalid, see the discussion under
#932
Identical scripts under DUPLICITY and YUM replaced by symlinks.
Reverted
#782
that had reintroduced
#465
which got re-reported as
#2611
Reverted
#578
because it is not clear how .lockfile can exist in the
unmounted filesystem, and if it does, it is a bug.
Reverted 
d850c40
because it became meanwhile obsoleted by
a8fdc44
pcahyna added a commit to pcahyna/rear that referenced this pull request Feb 17, 2023
Instead of special code in cleanup_build_area_and_end_program(), use the
shared helper to remove $BUILD_DIR/outputfs. This translates to using
rmdir always instead of using rm -Rf in case the filesystem is not
mounted. This is simpler and safer (disaster could arise if the
mountpoint command fails for any unexpected reason, for example).

It intentionally reverts PR rear#578 (commit
606d8ce). It is not clear why was
.lockfile present in the unmounted outputfs (this was the reason for the
change). According to my understanding of the code, this should not
happen. Even if this happens, it means that some part of the code is
using outputfs incorrectly (it should be used only if mounted, otherwise
data put there are lost) and it is better to be warned about the
problem rather than ignoring it by blindly removing the whole directory.
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

Successfully merging this pull request may close these issues.

4 participants