Blame SOURCES/rear-bz1843809-skip-longhorn.patch

a63dfb
From 2dbd93153df83aef0d413c104335b4e035a81c02 Mon Sep 17 00:00:00 2001
a63dfb
From: Gratien D'haese <gratien.dhaese@gmail.com>
a63dfb
Date: Thu, 16 Apr 2020 16:54:18 +0200
a63dfb
Subject: [PATCH] skip Longhorn Engine replica devices
a63dfb
a63dfb
Resolves: https://github.com/rear/rear/issues/2365
a63dfb
a63dfb
Signed-off-by: Gratien D'haese <gratien.dhaese@gmail.com>
a63dfb
---
a63dfb
 .../save/GNU/Linux/230_filesystem_layout.sh   | 31 ++++++++++++++++++-
a63dfb
 1 file changed, 30 insertions(+), 1 deletion(-)
a63dfb
a63dfb
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
a63dfb
index 60306718..afc658a6 100644
a63dfb
--- a/usr/share/rear/layout/save/GNU/Linux/230_filesystem_layout.sh
a63dfb
+++ b/usr/share/rear/layout/save/GNU/Linux/230_filesystem_layout.sh
a63dfb
@@ -111,10 +111,39 @@ fi
a63dfb
             # but ensure docker_root_dir is not empty (otherwise any mountpoint string matches "^" which
a63dfb
             # would skip all mountpoints), see https://github.com/rear/rear/issues/1989#issuecomment-456054278
a63dfb
             if test "$docker_root_dir" ; then
a63dfb
-                if echo "$mountpoint" | grep -q "^$docker_root_dir" ; then
a63dfb
+                if echo "$mountpoint" | grep -q "^${docker_root_dir}/" ; then
a63dfb
                     Log "Filesystem $fstype on $device mounted at $mountpoint is below Docker Root Dir $docker_root_dir, skipping."
a63dfb
                     continue
a63dfb
                 fi
a63dfb
+                # In case Longhorn is rebuilding a replica device it will show up as a pseudo-device and when that is the
a63dfb
+                # case then you would find traces of it in the /var/lib/rear/layout/disklayout.conf file, which would
a63dfb
+                # break the recovery as Longhorn Engine replica's are under control of Rancher Longhorn software and these are
a63dfb
+                # rebuild automatically via kubernetes longhorn-engine pods.
a63dfb
+                # Issue where we discovered this behavior was #2365
a63dfb
+                # In normal situations you will find traces of longhorn in the log saying skipping non-block devices.
a63dfb
+                # For example an output of the 'df' command:
a63dfb
+                # /dev/longhorn/pvc-ed09c0f2-c086-41c8-a38a-76ee8c289792   82045336    4500292   77528660   6% /var/lib/kubelet/pods/7f47aa55-30e2-4e7b-8fec-ec9a1e761352/volumes/kubernetes.io~csi/pvc-ed09c0f2-c086-41c8-a38a-76ee8c289792/mount
a63dfb
+                # lsscsi shows it as:
a63dfb
+                # [34:0:0:0]   storage IET      Controller       0001  -
a63dfb
+                # [34:0:0:1]   disk    IET      VIRTUAL-DISK     0001  /dev/sdf
a63dfb
+                # ls -l /dev/sdf /dev/longhorn/pvc-ed09c0f2-c086-41c8-a38a-76ee8c289792
a63dfb
+                # brw-rw---- 1 root disk 8, 80 Apr 17 12:02 /dev/sdf
a63dfb
+                # brw-rw---- 1 root root 8, 64 Apr 17 10:36 /dev/longhorn/pvc-ed09c0f2-c086-41c8-a38a-76ee8c289792
a63dfb
+                # and parted says:
a63dfb
+                # parted /dev/longhorn/pvc-ed09c0f2-c086-41c8-a38a-76ee8c289792 print
a63dfb
+                # Model: IET VIRTUAL-DISK (scsi)
a63dfb
+                # Disk /dev/longhorn/pvc-ed09c0f2-c086-41c8-a38a-76ee8c289792: 85.9GB
a63dfb
+                # Sector size (logical/physical): 512B/512B
a63dfb
+                # Partition Table: loop
a63dfb
+                # Disk Flags:
a63dfb
+                # Number  Start  End     Size    File system  Flags
a63dfb
+                # 1      0.00B  85.9GB  85.9GB  ext4
a63dfb
+                # => as result (without the next if clausule) we would end up with an entry in the disklayout.conf file:
a63dfb
+                # fs /dev/longhorn/pvc-ed09c0f2-c086-41c8-a38a-76ee8c289792 /var/lib/kubelet/pods/61ed399a-d51b-40b8-8fe8-a78e84a1dd0b/volumes/kubernetes.io~csi/pvc-c65df331-f1c5-466a-9731-b2aa5e6da714/mount ext4 uuid=4fafdd40-a9ae-4b62-8bfb-f29036dbe3b9 label= blocksize=4096 reserved_blocks=0% max_mounts=-1 check_interval=0d bytes_per_inode=16384 default_mount_options=user_xattr,acl options=rw,relatime,data=ordered
a63dfb
+                if echo "$device" | grep -q "^/dev/longhorn/pvc-" ; then
a63dfb
+                    Log "Longhorn Engine replica $device, skipping."
a63dfb
+                    continue
a63dfb
+                fi
a63dfb
             fi
a63dfb
         fi
a63dfb
         # Replace a symbolic link /dev/disk/by-uuid/a1b2c3 -> ../../sdXn
a63dfb
-- 
a63dfb
2.25.4
a63dfb