Mailing List Archive

[PATCH] Fix ha.cf node parsing in ha_propagate
# HG changeset patch
# User Philippe Alcoy <philippe@alcoy.co.uk>
# Date 1340188944 -25200
# Node ID f6ce2daddba6234643f715c46b28d5562940eb1f
# Parent add12b838ef461b20eec223e551bf508038dc640
Fix ha.cf node parsing in ha_propagate

diff -r add12b838ef4 -r f6ce2daddba6 heartbeat/lib/ha_propagate.in
--- a/heartbeat/lib/ha_propagate.in Mon Apr 09 17:50:27 2012 +0200
+++ b/heartbeat/lib/ha_propagate.in Wed Jun 20 17:42:24 2012 +0700
@@ -27,9 +27,8 @@
for line in f:
if line.startswith("node"):
toks = line.split()
- if (len(toks) == 2):
- nodeName = toks[1]
- nodes.append(nodeName)
+ if (len(toks) > 0):
+ nodes = toks[1:]
f.close()

thisnode = os.uname()[1]
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
Re: [PATCH] Fix ha.cf node parsing in ha_propagate [ In reply to ]
On Wed, Jun 20, 2012 at 06:29:43PM +0700, Philippe Alcoy wrote:
> # HG changeset patch
> # User Philippe Alcoy <philippe@alcoy.co.uk>
> # Date 1340188944 -25200
> # Node ID f6ce2daddba6234643f715c46b28d5562940eb1f
> # Parent add12b838ef461b20eec223e551bf508038dc640
> Fix ha.cf node parsing in ha_propagate

Someone is actually *using* this?
and even with multiple nodes per "node" line in ha.cf?

> diff -r add12b838ef4 -r f6ce2daddba6 heartbeat/lib/ha_propagate.in
> --- a/heartbeat/lib/ha_propagate.in Mon Apr 09 17:50:27 2012 +0200
> +++ b/heartbeat/lib/ha_propagate.in Wed Jun 20 17:42:24 2012 +0700
> @@ -27,9 +27,8 @@
> for line in f:
> if line.startswith("node"):
> toks = line.split()
> - if (len(toks) == 2):
> - nodeName = toks[1]
> - nodes.append(nodeName)
> + if (len(toks) > 0):

I'd suggest to use > 1.

> + nodes = toks[1:]
> f.close()
>
> thisnode = os.uname()[1]

--
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
Re: [PATCH] Fix ha.cf node parsing in ha_propagate [ In reply to ]
On 22 June 2012 17:20, Lars Ellenberg <lars.ellenberg@linbit.com> wrote:
>
> On Wed, Jun 20, 2012 at 06:29:43PM +0700, Philippe Alcoy wrote:
> > # HG changeset patch
> > # User Philippe Alcoy <philippe@alcoy.co.uk>
> > # Date 1340188944 -25200
> > # Node ID f6ce2daddba6234643f715c46b28d5562940eb1f
> > # Parent  add12b838ef461b20eec223e551bf508038dc640
> > Fix ha.cf node parsing in ha_propagate
>
> Someone is actually *using* this?
> and even with multiple nodes per "node" line in ha.cf?

Probably not. I was just curious and tested it in the lab.

> > diff -r add12b838ef4 -r f6ce2daddba6 heartbeat/lib/ha_propagate.in
> > --- a/heartbeat/lib/ha_propagate.in   Mon Apr 09 17:50:27 2012 +0200
> > +++ b/heartbeat/lib/ha_propagate.in   Wed Jun 20 17:42:24 2012 +0700
> > @@ -27,9 +27,8 @@
> >  for line in f:
> >      if line.startswith("node"):
> >         toks = line.split()
> > -       if (len(toks) == 2):
> > -       nodeName = toks[1]
> > -       nodes.append(nodeName)
> > +       if (len(toks) > 0):
>
> I'd suggest to use > 1.

If you decide to keep ha_propagate, I would recommend > 0.
The script would work even if for some unknown reasons there is only
one node in the list.
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
Re: [PATCH] Fix ha.cf node parsing in ha_propagate [ In reply to ]
On Tue, Jun 26, 2012 at 05:46:44PM +0700, Philippe Alcoy wrote:
> On 22 June 2012 17:20, Lars Ellenberg <lars.ellenberg@linbit.com> wrote:
> >
> > On Wed, Jun 20, 2012 at 06:29:43PM +0700, Philippe Alcoy wrote:
> > > # HG changeset patch
> > > # User Philippe Alcoy <philippe@alcoy.co.uk>
> > > # Date 1340188944 -25200
> > > # Node ID f6ce2daddba6234643f715c46b28d5562940eb1f
> > > # Parent  add12b838ef461b20eec223e551bf508038dc640
> > > Fix ha.cf node parsing in ha_propagate
> >
> > Someone is actually *using* this?
> > and even with multiple nodes per "node" line in ha.cf?
>
> Probably not. I was just curious and tested it in the lab.
>
> > > diff -r add12b838ef4 -r f6ce2daddba6 heartbeat/lib/ha_propagate.in
> > > --- a/heartbeat/lib/ha_propagate.in   Mon Apr 09 17:50:27 2012 +0200
> > > +++ b/heartbeat/lib/ha_propagate.in   Wed Jun 20 17:42:24 2012 +0700
> > > @@ -27,9 +27,8 @@
> > >  for line in f:
> > >      if line.startswith("node"):
> > >         toks = line.split()
> > > -       if (len(toks) == 2):
> > > -       nodeName = toks[1]
> > > -       nodes.append(nodeName)
> > > +       if (len(toks) > 0):
> >
> > I'd suggest to use > 1.
>
> If you decide to keep ha_propagate, I would recommend > 0.
> The script would work even if for some unknown reasons there is only
> one node in the list.

python -c 'print len("node".split())'
1

The first token in toks is "node".
A "node" line without node names is invalid.


Lars
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
Re: [PATCH] Fix ha.cf node parsing in ha_propagate [ In reply to ]
On 26 June 2012 18:51, Lars Ellenberg <lars.ellenberg@linbit.com> wrote:
> On Tue, Jun 26, 2012 at 05:46:44PM +0700, Philippe Alcoy wrote:
>> On 22 June 2012 17:20, Lars Ellenberg <lars.ellenberg@linbit.com> wrote:
>> >
>> > On Wed, Jun 20, 2012 at 06:29:43PM +0700, Philippe Alcoy wrote:
>> > > # HG changeset patch
>> > > # User Philippe Alcoy <philippe@alcoy.co.uk>
>> > > # Date 1340188944 -25200
>> > > # Node ID f6ce2daddba6234643f715c46b28d5562940eb1f
>> > > # Parent  add12b838ef461b20eec223e551bf508038dc640
>> > > Fix ha.cf node parsing in ha_propagate
>> >
>> > Someone is actually *using* this?
>> > and even with multiple nodes per "node" line in ha.cf?
>>
>> Probably not. I was just curious and tested it in the lab.
>>
>> > > diff -r add12b838ef4 -r f6ce2daddba6 heartbeat/lib/ha_propagate.in
>> > > --- a/heartbeat/lib/ha_propagate.in   Mon Apr 09 17:50:27 2012 +0200
>> > > +++ b/heartbeat/lib/ha_propagate.in   Wed Jun 20 17:42:24 2012 +0700
>> > > @@ -27,9 +27,8 @@
>> > >  for line in f:
>> > >      if line.startswith("node"):
>> > >         toks = line.split()
>> > > -       if (len(toks) == 2):
>> > > -       nodeName = toks[1]
>> > > -       nodes.append(nodeName)
>> > > +       if (len(toks) > 0):
>> >
>> > I'd suggest to use > 1.
>>
>> If you decide to keep ha_propagate, I would recommend > 0.
>> The script would work even if for some unknown reasons there is only
>> one node in the list.
>
> python -c 'print len("node".split())'
> 1
>
> The first token in toks is "node".
> A "node" line without node names is invalid.

You're right. I just found out that I had used a wrong config file
when I tested it.
My mistake. Thanks Lars.
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/