Blame SOURCES/rear-bz1711123.patch

b650a9
diff --git a/usr/share/rear/layout/save/GNU/Linux/230_filesystem_layout.sh b/usr/share/rear/layout/save/GNU/Linux/230_filesystem_layout.sh
b650a9
index 2fc8ccd3..60306718 100644
b650a9
--- a/usr/share/rear/layout/save/GNU/Linux/230_filesystem_layout.sh
b650a9
+++ b/usr/share/rear/layout/save/GNU/Linux/230_filesystem_layout.sh
b650a9
@@ -50,13 +50,28 @@ fi
b650a9
 # so that in particular what is mounted at '/' is output before other stuff.
b650a9
 read_filesystems_command="$read_filesystems_command | sort -t ' ' -k 1,1 -u"
b650a9
 
b650a9
-# docker daemon mounts file systems for its docker containers
b650a9
-# see also https://docs.docker.com/storage/storagedriver/device-mapper-driver/#configure-direct-lvm-mode-for-production
b650a9
-# As it is for container usage only we do not to backup these up or recreate as this disk device is completely under
b650a9
-# control by docker itself (even the recreation of it incl, the creation of the volume group). Usually this is
b650a9
-# done via a kind of cookbook (Chef, puppet or ansible)
b650a9
+# The Docker daemon mounts file systems for its Docker containers, see also
b650a9
+# https://docs.docker.com/storage/storagedriver/device-mapper-driver/#configure-direct-lvm-mode-for-production
b650a9
+# As it is for container usage only we do not to backup these up or recreate as this disk device is completely
b650a9
+# under control by Docker itself (even the recreation of it incl, the creation of the volume group).
b650a9
+# Usually this is done via a kind of cookbook (Chef, puppet or ansible).
b650a9
 docker_is_running=""
b650a9
-service docker status >/dev/null 2>&1 && docker_is_running="yes"
b650a9
+docker_root_dir=""
b650a9
+if service docker status &>/dev/null ; then
b650a9
+    docker_is_running="yes"
b650a9
+    # When the Docker daemon/service is running, try to get its 'Docker Root Dir':
b650a9
+    # Kill 'docker info' with SIGTERM after 5 seconds and with SIGKILL after additional 2 seconds
b650a9
+    # because there are too many crippled Docker installations, cf. https://github.com/rear/rear/pull/2021
b650a9
+    docker_root_dir=$( timeout -k 2s 5s docker info | grep 'Docker Root Dir' | awk '{print $4}' )
b650a9
+    # Things may go wrong in the 'Docker specific exclude part' below
b650a9
+    # when Docker is used but its 'Docker Root Dir' cannot be determined
b650a9
+    # cf. https://github.com/rear/rear/issues/1989
b650a9
+    if test "$docker_root_dir" ; then
b650a9
+        LogPrint "Docker is running, skipping filesystems mounted below Docker Root Dir $docker_root_dir"
b650a9
+    else
b650a9
+        LogPrintError "Cannot determine Docker Root Dir - things may go wrong - check $DISKLAYOUT_FILE"
b650a9
+    fi
b650a9
+fi
b650a9
 
b650a9
 # Begin writing output to DISKLAYOUT_FILE:
b650a9
 (
b650a9
@@ -64,9 +79,10 @@ service docker status >/dev/null 2>&1 && docker_is_running="yes"
b650a9
     echo "# Format: fs <device> <mountpoint> <fstype> [uuid=<uuid>] [label=<label>] [<attributes>]"
b650a9
     # Read the output of the read_filesystems_command:
b650a9
     while read device mountpoint fstype options junk ; do
b650a9
+        Log "Processing filesystem '$fstype' on '$device' mounted at '$mountpoint'"
b650a9
         # Empty device or mountpoint or fstype may may indicate an error. In this case be verbose and inform the user:
b650a9
         if test -z "$device" -o -z "$mountpoint" -o -z "$fstype" ; then
b650a9
-            LogPrint "Empty device='$device' or mountpoint='$mountpoint' or fstype='$fstype', skipping saving filesystem layout for it."
b650a9
+            LogPrintError "Empty device='$device' or mountpoint='$mountpoint' or fstype='$fstype', skipping saving filesystem layout for it."
b650a9
             continue
b650a9
         fi
b650a9
         # FIXME: I (jsmeix@suse.de) have no idea what the reason for the following is.
b650a9
@@ -88,15 +104,18 @@ service docker status >/dev/null 2>&1 && docker_is_running="yes"
b650a9
             Log "$device is CD/DVD type device [fstype=$fstype], skipping."
b650a9
             continue
b650a9
         fi
b650a9
-        # docker specific exclude part
b650a9
+        # Docker specific exclude part:
b650a9
         if is_true $docker_is_running ; then
b650a9
-            # docker daemon/service is running
b650a9
-            docker_root_dir=$( docker info 2>/dev/null | grep 'Docker Root Dir' | awk '{print $4}' )
b650a9
-            # If $docker_root_dir is in the beginning of the $mountpoint string then FS is under docker control
b650a9
-            # and we better exclude from saving the layout,
b650a9
-            # see https://github.com/rear/rear/issues/1749
b650a9
-            Log "$device is mounted below $docker_root_dir (mount point $mountpoint is under docker control), skipping."
b650a9
-            echo "$mountpoint" | grep -q "^$docker_root_dir" && continue
b650a9
+            # If docker_root_dir is the beginning of the mountpoint string then the filesystem is under Docker control
b650a9
+            # and we better exclude it from saving the layout, see https://github.com/rear/rear/issues/1749
b650a9
+            # but ensure docker_root_dir is not empty (otherwise any mountpoint string matches "^" which
b650a9
+            # would skip all mountpoints), see https://github.com/rear/rear/issues/1989#issuecomment-456054278
b650a9
+            if test "$docker_root_dir" ; then
b650a9
+                if echo "$mountpoint" | grep -q "^$docker_root_dir" ; then
b650a9
+                    Log "Filesystem $fstype on $device mounted at $mountpoint is below Docker Root Dir $docker_root_dir, skipping."
b650a9
+                    continue
b650a9
+                fi
b650a9
+            fi
b650a9
         fi
b650a9
         # Replace a symbolic link /dev/disk/by-uuid/a1b2c3 -> ../../sdXn
b650a9
         # by the fully canonicalized target of the link e.g. /dev/sdXn
b650a9
@@ -232,7 +251,7 @@ service docker status >/dev/null 2>&1 && docker_is_running="yes"
b650a9
             test -z "$btrfs_default_subvolume_path" && btrfs_default_subvolume_path="/"
b650a9
             # Empty btrfs_default_subvolume_ID may may indicate an error. In this case be verbose and inform the user:
b650a9
             if test -z "$btrfs_default_subvolume_ID" ; then
b650a9
-                LogPrint "Empty btrfs_default_subvolume_ID, no btrfs default subvolume stored for $btrfs_device at $btrfs_mountpoint"
b650a9
+                LogPrintError "Empty btrfs_default_subvolume_ID, no btrfs default subvolume stored for $btrfs_device at $btrfs_mountpoint"
b650a9
             else
b650a9
                 echo "btrfsdefaultsubvol $btrfs_device $btrfs_mountpoint $btrfs_default_subvolume_ID $btrfs_default_subvolume_path"
b650a9
             fi