Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-38912

ETCD disk migration procedure script is showing non bash-escaped variables

XMLWordPrintable

    • Moderate
    • None
    • 3
    • OSDOCS Sprint 259, OSDOCS Sprint 260
    • 2
    • False
    • Hide

      None

      Show
      None

      Description of problem:

      The script provided at Step #2 in [0] is not linted with [shellcheck](https://github.com/koalaman/shellcheck)

      Version-Release number of selected component (if applicable):

      4.12+

      How reproducible:

      Check the script with [shellcheck](https://github.com/koalaman/shellcheck)

      Steps to Reproduce:

          1. Take [0] Step#2 script into a file
          2. Install [shellcheck](https://github.com/koalaman/shellcheck) in your environment
          3. Replacing the <device_type_glob> placeholder with a proper device filepath
          4. Run `shellcheck` against the script
          5. See results

      Actual results:

      The following is shown:
      
      $ shellcheck script.sh 
      
      In script.sh line 5:
      /usr/sbin/blkid $device &> /dev/null
                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
      
      Did you mean: 
      /usr/sbin/blkid "$device" &> /dev/null
      
      
      In script.sh line 9:
          mkfs.xfs -L var-lib-etcd -f $device &> /dev/null
                                      ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
      
      Did you mean: 
          mkfs.xfs -L var-lib-etcd -f "$device" &> /dev/null
      
      For more information:
        https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
      
      
      

      Expected results:

      $ shellcheck script.sh
      < no output >

      Additional info: 

      A proposal for fix is as follows:
      
      #!/bin/bash
      set -uo pipefail
      
      for device in <device_type_glob>; do
        /usr/sbin/blkid "${device}" &> /dev/null
        if [ $? == 2  ]; then
          echo "secondary device found ${device}"
          echo "creating filesystem for etcd mount"
          mkfs.xfs -L var-lib-etcd -f "${device}" &> /dev/null
          udevadm settle
          touch /etc/var-lib-etcd-mount
          exit
        fi
        done
      echo "Couldn't find secondary block device!" >&2
      exit 77
      
      [0] https://docs.openshift.com/container-platform/4.12/scalability_and_performance/recommended-performance-scale-practices/recommended-etcd-practices.html#move-etcd-different-disk_recommended-etcd-practices

              rhn-support-tlove Tami Love
              rh-ee-sizucchi Simone Massimo Zucchi
              Sandeep Kundu Sandeep Kundu
              Tami Love Tami Love
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: