#1857 Issue closed: Add choice to confirm identical layout mapping only once plus disabling MIGRATION_MODE

Labels: enhancement, cleanup, fixed / solved / done

jsmeix opened issue at 2018-07-11 11:57:

I use the current ReaR master code.

Since https://github.com/rear/rear/pull/1593
"rear recover" goes by default into MIGRATION_MODE
if an ambiguous disk layout is detected i.e. when there is
more than one disk with same size in disklayout.conf

In this case "rear recover" looks like:

Comparing disks
Ambiguous disk layout needs manual configuration (more than one disk with same size used in '/var/lib/rear/layout/disklayout.conf')
Switching to manual disk layout configuration
Using /dev/sda (same name and same size) for recreating /dev/sda
Using /dev/sdb (same name and same size) for recreating /dev/sdb
Current disk mapping table (source -> target):
    /dev/sda /dev/sda
    /dev/sdb /dev/sdb
UserInput -I LAYOUT_MIGRATION_CONFIRM_MAPPINGS needed in /usr/share/rear/layout/prepare/default/300_map_disks.sh line 211
Confirm or edit the disk mapping
1) Confirm disk mapping and continue 'rear recover'
2) Edit disk mapping (/var/lib/rear/layout/disk_mappings)
3) Use Relax-and-Recover shell and return back to here
4) Abort 'rear recover'
(default '1' timeout 300 seconds)

When now the user confirms that proposed identical mapping
he gets still all the other subsequent dialogs in MIGRATION_MODE
regardless that a completely identical layout mapping usually means
that actually no MIGRATION_MODE is wanted.

Therefore that "Confirm or edit the disk mapping" dialog
in layout/prepare/default/300_map_disks.sh
should be enhanced when a completely identical layout mapping is shown
by one more choice where the user can confirm that proposed identical mapping
plus disabling MIGRATION_MODE (i.e. setting MIGRATION_MODE='false').

A quick fast initial hack in layout/prepare/default/300_map_disks.sh
worked o.k. fo me.

But I noticed that there is likely an inconsistency in the ReaR code
how currently is tested whether or not migration mode is active:
Some scripts test

is_true "$MIGRATION_MODE" || return 0

while other scripts - in particular some finalize scripts - test

test -s "$MAPPING_FILE" || return 0

to skip the rest of the script when not in migration mode.
I will also clean up how for migration mode is tested.

FYI:
My primary use case is "rear recover" on a RAID1 system that uses
two disks with same size and same sized partitions where RAID1 arrays
are built from each of the partition pairs on my original system:

# lsblk -i -p -o NAME,KNAME,TYPE,FSTYPE,SIZE,MOUNTPOINT
NAME         KNAME     TYPE  FSTYPE             SIZE MOUNTPOINT
/dev/sda     /dev/sda  disk                      20G 
|-/dev/sda1  /dev/sda1 part  linux_raid_member    2G 
| `-/dev/md0 /dev/md0  raid1 swap                 2G [SWAP]
|-/dev/sda2  /dev/sda2 part  linux_raid_member   10G 
| `-/dev/md1 /dev/md1  raid1 ext4                10G /
`-/dev/sda3  /dev/sda3 part  linux_raid_member    5G 
  `-/dev/md2 /dev/md2  raid1 xfs                  5G /home
/dev/sdb     /dev/sdb  disk                      20G 
|-/dev/sdb1  /dev/sdb1 part  linux_raid_member    2G 
| `-/dev/md0 /dev/md0  raid1 swap                 2G [SWAP]
|-/dev/sdb2  /dev/sdb2 part  linux_raid_member   10G 
| `-/dev/md1 /dev/md1  raid1 ext4                10G /
`-/dev/sdb3  /dev/sdb3 part  linux_raid_member    5G 
  `-/dev/md2 /dev/md2  raid1 xfs                  5G /home
/dev/sr0     /dev/sr0  rom   iso9660            3.6G

There I get during "rear recover" the above shown proposed identical mapping table
that I like to confirm only once plus disabling any further MIGRATION_MODE stuff.

jsmeix commented at 2018-07-11 15:22:

What I get with some enhancements in layout/prepare/default/300_map_disks.sh is:

Current disk mapping table (source => target):
  /dev/sda => /dev/sda
  /dev/sdb => /dev/sdb
UserInput -I LAYOUT_MIGRATION_CONFIRM_MAPPINGS needed in /usr/share/rear/layout/prepare/default/300_map_disks.sh line 246
Confirm or edit the disk mapping
1) Confirm disk mapping and continue 'rear recover'
2) Confirm identical disk mapping and proceed without manual configuration
3) Edit disk mapping (/var/lib/rear/layout/disk_mappings)
4) Use Relax-and-Recover shell and return back to here
5) Abort 'rear recover'
(default '1' timeout 300 seconds)
2
UserInput: Valid choice number result 'Confirm identical disk mapping and proceed without manual configuration'
User confirmed identical disk mapping and proceeding without manual configuration

and from that point it "just works" without any further migration mode dialog.

When there is a non-identical disk mapping the choices are:

1) Confirm disk mapping and continue 'rear recover'
2) n/a
3) Edit disk mapping (/var/lib/rear/layout/disk_mappings)
4) Use Relax-and-Recover shell and return back to here
5) Abort 'rear recover'

jsmeix commented at 2018-07-17 12:08:

With https://github.com/rear/rear/pull/1865 merged
this issue should be done.


[Export of Github issue for rear/rear.]