crmsh icon indicating copy to clipboard operation
crmsh copied to clipboard

Fix: sbd: Ask if overwrite when given sbd device on interactive mode

Open liangxin1300 opened this issue 2 years ago • 0 comments

Problem

When sbd device already created, running crm cluster init -s <sbd_device>, that's on the interactive mode, but the existing sbd device will be overwritten

Solution

Check if the given sbd device already initialized, if on the interactive mode, ask user if overwrite, input 'n', no overwrite for sbd device

Test cases

Case 1

  • sbd device already initialized BUT not configured in /etc/sysconfig/sbd
  • Run crm cluster init, specify the same sbd device
  • crmsh ask "SBD is already configured to use - overwrite (y/n)?", input n
  • Then this device will NOT be overwritten
  • /etc/sysconfig/sbd will be configured (SBD_DEVICE=)

Case 2

  • sbd device already initialized BUT not configured in /etc/sysconfig/sbd
  • Run crm cluster init -s <device>, use -s to specify the same sbd device
  • crmsh ask "SBD is already configured to use - overwrite (y/n)?", input n
  • Then this device will NOT be overwritten
  • /etc/sysconfig/sbd will be configured (SBD_DEVICE=)

Case 3

  • sbd device already initialized AND configured in /etc/sysconfig/sbd
  • Run crm cluster init
  • crmsh ask "SBD is already configured to use - overwrite (y/n)?", input n
  • Then this device will NOT be overwritten

Case 4

  • sbd device already initialized AND configured in /etc/sysconfig/sbd
  • Run crm cluster init -s <device>
  • crmsh ask "SBD is already configured to use - overwrite (y/n)?", input n
  • Then this device will NOT be overwritten

Case 5

  • sbd device already initialized AND configured in /etc/sysconfig/sbd
  • A running cluster without SBD
  • Run crm cluster init sbd
INFO: Do you wish to use SBD (y/n)? y
INFO: SBD is already configured to use /dev/sda1 - overwrite (y/n)? n
INFO: Restarting cluster service
INFO: Waiting for cluster...............done
  • Then this device will NOT be overwritten

Case 6

  • sbd device already initialized AND configured in /etc/sysconfig/sbd
  • Run crm cluster init
  • crmsh ask "SBD is already configured to use - overwrite (y/n)?", input y
INFO: SBD is already configured to use /dev/sda1 - overwrite (y/n)? y
INFO: Path to storage device (e.g. /dev/disk/by-id/...), or "none" for diskless sbd, use ";" as separator for multi path []/dev/sda1
WARNING: All data on /dev/sda1 will be destroyed!
INFO: Are you sure you wish to use this device (y/n)? y

Case 7 multi device

tbw-1:~ # sbd dump -d /dev/sda1 -d /dev/sda2
==Dumping header on disk /dev/sda1
Header version     : 2.1
UUID               : 8d43b8a0-ec0e-46d8-a526-533d356d830d
Number of slots    : 255
Sector size        : 512
Timeout (watchdog) : 15
Timeout (allocate) : 2
Timeout (loop)     : 1
Timeout (msgwait)  : 30
==Header on disk /dev/sda1 is dumped
==Dumping header on disk /dev/sda2
Header version     : 2.1
UUID               : 60febbe5-ce35-4459-a1d3-ea00d67cb5c2
Number of slots    : 255
Sector size        : 512
Timeout (watchdog) : 15
Timeout (allocate) : 2
Timeout (loop)     : 1
Timeout (msgwait)  : 30
==Header on disk /dev/sda2 is dumped
tbw-1:~ # crm cluster stop
INFO: Cluster services stopped on tbw-1
tbw-1:~ # crm cluster init
INFO: Loading "default" profile from /etc/crm/profiles.yml
INFO: Configuring csync2
INFO: csync2 is already configured - overwrite (y/n)? y
INFO: Generating csync2 shared key (this may take a while)...done
INFO: csync2 checking files...done
INFO: /etc/corosync/authkey already exists - overwrite (y/n)? n
INFO: /etc/corosync/corosync.conf already exists - overwrite (y/n)? n
INFO: /etc/pacemaker/authkey already exists - overwrite (y/n)? n
INFO: Configure SBD:
  If you have shared storage, for example a SAN or iSCSI target,
  you can use it avoid split-brain scenarios by configuring SBD.
  This requires a 1 MB partition, accessible to all nodes in the
  cluster.  The device path must be persistent and consistent
  across all nodes in the cluster, so /dev/disk/by-id/* devices
  are a good choice.  Note that all data on the partition you
  specify here will be destroyed.
INFO: Do you wish to use SBD (y/n)? y
INFO: SBD is already configured to use /dev/sda1 - overwrite (y/n)? n
INFO: SBD is already configured to use /dev/sda2 - overwrite (y/n)? y
INFO: Path to storage device (e.g. /dev/disk/by-id/...), or "none" for diskless sbd, use ";" as separator for multi path []/dev/sda1;/dev/sda2
WARNING: All data on /dev/sda2 will be destroyed!
INFO: Are you sure you wish to use this device (y/n)? y
INFO: Initializing SBD
WARNING: Hawk not installed - not configuring web management interface.
INFO: Starting pacemaker...done
INFO: Waiting for cluster...............done
INFO: Loading initial cluster configuration
INFO: Done (log saved to /var/log/crmsh/crmsh.log)
tbw-1:~ # sbd dump -d /dev/sda1 -d /dev/sda2
==Dumping header on disk /dev/sda1
Header version     : 2.1
UUID               : 8d43b8a0-ec0e-46d8-a526-533d356d830d
Number of slots    : 255
Sector size        : 512
Timeout (watchdog) : 15
Timeout (allocate) : 2
Timeout (loop)     : 1
Timeout (msgwait)  : 30
==Header on disk /dev/sda1 is dumped
==Dumping header on disk /dev/sda2
Header version     : 2.1
UUID               : 04604568-43c6-4a1a-bd12-be1492dc21fd
Number of slots    : 255
Sector size        : 512
Timeout (watchdog) : 15
Timeout (allocate) : 2
Timeout (loop)     : 1
Timeout (msgwait)  : 30
==Header on disk /dev/sda2 is dumped

liangxin1300 avatar Jul 13 '22 07:07 liangxin1300