Bug 209792 - sys-block/vblade: /etc/init.d/vblade.vblade0 script doesn't stop vblades (egrep parsing error)
Bug#: 209792 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: robbat2@gentoo.org Reported By: agoins@arces.net
Component: Applications
URL: 
Summary: sys-block/vblade: /etc/init.d/vblade.vblade0 script doesn't stop vblades (egrep parsing error)
Keywords:  
Status Whiteboard: 
Opened: 2008-02-12 09:15 0000
Description:   Opened: 2008-02-12 09:15 0000
the init script was changed as a result of 137016 to do some egrep parsing to
find the vblade pid and stop it.  this syntax looks like the following:

ps -Ao pid,args | egrep "^[[:space:]]*[[:digit:]]+ /usr/sbin/vbladed ${shelf}
${slot} ${netif} ${src}" | awk '{print $1}' | xargs kill

this syntax fails because the actual process looks like the following:

5602 /bin/sh /usr/sbin/vbladed 0 3 eth0 /dev/ar/gauntlet-root

the egrep is missing the following:

* /bin/sh
* /usr/sbin/vbladed (instead of /usr/sbin/vblade)

additionally, it gets the full string it's looking for from /etc/conf.d/vblade,
which means that if /etc/conf.d/vblade is modified before the particular vblade
in question is stopped, the process it's looking for is wrong.  for example, if
i change /etc/conf.d/vblade to have 0,3 running on eth1 instead of eth0 and
then try to stop vblade 0,3 it will look for the process with 'eth1' in the
string instead of 'eth0'.  the process will not be stopped.



Reproducible: Always

Steps to Reproduce:
1. run /etc/init.d/vblade.vblade0_0 to stop a running vblade
2. run /etc/init.d/vblade.vblade0_0 to stop a running vblade after changing
/etc/conf.d/vblade


Actual Results:  
the egrep fails and xargs isn't passed anything to kill, causing it to exit
with errors.

Expected Results:  
it should have stopped the vblade.

the correct syntax for the egrep (tested valid on my system) is:

ps -Ao pid,args | egrep "^[[:space:]]*[[:digit:]]+ /bin/sh /usr/sbin/vbladed
${shelf} ${slot}" | awk '{ print $1 }' | xargs kill

this looks for the bare minimum unique information (shelf/slot) to stop the
process, without looking at information that may have changed in the
configuration file (interface, physical partition).

------- Comment #1 From Adrian Goins 2008-02-12 09:22:09 0000 -------
Created an attachment (id=143290) [details]
patch to /etc/init.d/vblade.vblade0_0

this is a unified diff of my modified init script

------- Comment #2 From Adrian Goins 2008-02-13 06:42:37 0000 -------
after further research yesterday i realized that my initial report wasn't 100%
accurate.  the /bin/sh...vbladed line is actually controlled by the line that
the original egrep text looks for, and my patch and modification to vbladed0_0
doesn't work properly.

the problem of the script getting its information from /etc/conf.d/vblade is
still correct - if this file has changed then an existing vblade cannot be
stopped.  i've changed the init script and have an updated patch that does work
correctly.

------- Comment #3 From Adrian Goins 2008-02-13 06:43:23 0000 -------
Created an attachment (id=143395) [details]
(corrected) patch for /etc/init.d/vblade0_0

updated patch that identifies the correct process for signalling

------- Comment #4 From Robin Johnson 2008-07-05 09:53:50 0000 -------
incvs.

please open a stabilization bug in 1 week if it works fine.