Uploaded image for project: 'Ambari'
  1. Ambari
  2. AMBARI-18824

MOTD Can Prevent WebHCat From Shutting Down

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 2.4.0
    • 2.4.2
    • ambari-server
    • None

    Description

      There was code added in AMBARI-12695 (later corrected by AMBARI-18684) which tries to kill WebHCat if it doesn't stop with its own stop command.

      Both patches use the as_user function to wrap the call in a bash login:

      ps -p `su hcat -l -s /bin/bash -c 'cat /var/run/webhcat/webhcat.pid'` >/dev/null 2>&1
      

      This, however, causes problems where there is a MOTD:

      ERROR: Process ID list syntax error.
      ********* simple selection *********  ********* selection by list *********
      -A all processes                      -C by command name
      -N negate selection                   -G by real group ID (supports names)
      -a all w/ tty except session leaders  -U by real user ID (supports names)
      -d all except session leaders         -g by session OR by effective group name
      -e all processes                      -p by process ID
                                            -q by process ID (unsorted & quick)
      T  all processes on this terminal     -s processes in the sessions given
      a  all w/ tty, including other users  -t by tty
      g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)
      r  only running processes             U  processes for specified users
      x  processes w/o controlling ttys     t  by tty
      *********** output format **********  *********** long options ***********
      -o,o user-defined  -f full            --Group --User --pid --cols --ppid
      -j,j job control   s  signal          --group --user --sid --rows --info
      -O,O preloaded -o  v  virtual memory  --cumulative --format --deselect
      -l,l long          u  user-oriented   --sort --tty --forest --version
      -F   extra full    X  registers       --heading --no-heading --context
                                            --quick-pid
                          ********* misc options *********
      -V,V  show version      L  list format codes  f  ASCII art forest
      -m,m,-L,-T,H  threads   S  children in sum    -y change -l format
      -M,Z  security data     c  true command name  -c scheduling class
      -w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy
      

      That's not good - why is it giving us back a bad command syntax? Here's the reason:

      [root@ijzs-c229todgsecha-r6-re1-3 ~]# su hcat -l -s /bin/bash -c 'cat /var/run/webhcat/webhcat.pid'
      This is MOTD message :)
      25672
      

      The MOTD is messing up the output from commands for the hcat user. Because we rely on the error code of ps, the same non-zero code is used for a bad command and a missing process ID.

      Since the PID is world-readable, we don't need to run the only_if checks as a separate user.

      Attachments

        1. AMBARI-18824.patch
          9 kB
          Jonathan Hurley

        Issue Links

          Activity

            People

              jonathanhurley Jonathan Hurley
              jonathanhurley Jonathan Hurley
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: