[PATCH] ctdb-scripts: Invoke pstree with -l option (bug 13531)

Martin Schwenke martin at meltin.net
Wed Jul 18 06:23:27 UTC 2018


On Tue, 17 Jul 2018 14:45:53 +1000, Martin Schwenke via samba-technical
<samba-technical at lists.samba.org> wrote:

> On Tue, 17 Jul 2018 13:15:23 +1000, Amitay Isaacs <amitay at gmail.com>
> wrote:
> 
> > On Mon, Jul 16, 2018 at 10:27 PM, Martin Schwenke <martin at meltin.net> wrote:  
> > > Hi Amitay,
> > >
> > > On Mon, 16 Jul 2018 14:24:05 +1000, Amitay Isaacs
> > > <amitay at gmail.com> wrote:
> > >    
>  [...]  
> >  [...]    
>  [...]  
> > >
> > > Hmmm... I thought that the version of pstree in, say, FreeBSD would be
> > > this one:
> > >
> > >   http://www.pell.portland.or.us/~orc/Code/ps-etc/
> > >
> > > But it turns out that it is probably this one:
> > >
> > >   https://www.freshports.org/sysutils/pstree
> > >
> > > where -l means something else entirely.
> > >    
>  [...]  
> > >
> > > I wouldn't like to lose all of the pstree output.  If for some reason
> > > something changes and the test fails then that output almost certainly
> > > provides enough information to understand why.    
> > 
> > I don't want to lose pstree output. Just filter it out in the tests.
> > For eventd test, we are not really testing pstree.  We have other
> > output from the debug-script.sh that proves the correctness of the
> > behaviour.
> >   
> > > Perhaps something like the following is good enough to show the event
> > > script and immediate children?
> > >
> > > $ ps -e -o pid,ppid,args | awk -v pid=$$ '$1 == pid || $2 == pid { print }'
> > >  9115  1642 bash
> > > 10487  9115 ps -e -o pid,ppid,args
> > > 10488  9115 awk -v pid=9115 $1 == pid || $2 == pid { print }
> > >
> > > I've used $$, which illustrates it well, but we would obviously use
> > > "$pid" or similar.
> > >
> > > As far as I can tell the above is completely POSIX-complaint.
> > >
> > > I've tried adding -f.  With both that and -e Linux ps prints the
> > > environment along with each command, which doesn't make sense, since -e
> > > is only supposed to influence process selection.    
> > 
> > Let's not re-invent the wheel.  I am all for keeping pstree in the
> > debug-hung-script.sh in the current form (pstree -a -p <pid>).  It's
> > been most useful for tracking down issues with timing out event
> > scripts.
> >   
> > > Do you think the above gives us what we need and is sufficiently
> > > portable?    
> > 
> > Let's fix the test without jumping through many hoops.
> > 
> > Here's my suggestion:
> > 
> > 1. For eventd tests, we can compress the output (drop -a)  
> 
> Yeah, I think this gives us everything we need.  Although pstree(1)
> says -a causes it to print args, it also makes it print full path to
> executable, which is completely unnecessary.
> 
> > 2. For simple test, simply filter the pstree output and make sure we
> > see "sleep 9999" in the output.  
> 
> Sold!  :-)

As discussed offline, for the eventd tests we can also drop the -p
option because we don't use the PIDs and need to filter them out anyway.
For the simple test I just match less of the line (only the script
name) so it doesn't matter if the pstree output is truncated.

Please review and maybe push...

peace & happiness,
martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctdb.patch
Type: text/x-patch
Size: 4750 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180718/2e3db873/ctdb.bin>


More information about the samba-technical mailing list