Re: [Pacemaker] pcs: Return code handling not clean

2013-04-16 Thread Andreas Mock
Hi Chris,

just seen in the github repo - which I found after posting here -
that you made a fix.

Thank you for the very fast reaction.

Best regards
Andreas

-Ursprüngliche Nachricht-
Von: Chris Feist [mailto:cfe...@redhat.com] 
Gesendet: Mittwoch, 17. April 2013 00:34
An: The Pacemaker cluster resource manager; Andreas Mock
Betreff: Re: [Pacemaker] pcs: Return code handling not clean

On 04/16/13 06:46, Andreas Mock wrote:
> Hi all,
>
> as I don't really know, where to address this issue, I do post it 
> here. On the one handside as an information for guys scripting with 
> the help of 'pcs' and on the other handside with the hope that one 
> maintainer is listening and will have a look at this.
>
> Problem: When cluster is down a 'pcs resource'
> shows an error message coming from a subprocess call of 'crm_resource 
> -L' but exits with an error code of 0. That's something which can be 
> improved. Especially while the python code does have error handling in 
> other paces.
>
> So I guess it is a simple oversight.
>
> Look at the following piece of code in
> pcs/resource.py:
>
> 915 if len(argv) == 0:
> 916 args = ["crm_resource","-L"]
> 917 output,retval = utils.run(args)
> 918 preg = re.compile(r'.*(stonith:.*)')
> 919 for line in output.split('\n'):
> 920 if not preg.match(line) and line != "":
> 921 print line
> 922 return
>
> retval is totally ignored, while being handled on other places. That 
> leads to the fact that the script returns with status 0.

This is an oversight on my part, I've updated the code to check retval and
return an error.  Currently I'm not passing through the full error code (I'm
only returning 0 on success and 1 on failure).  However, if you think it
would be useful to have this information I would be happy to look at it and
see what I can do.  I'm planning on eventually having pcs interpret the
crm_resource error code and provide a more user friendly output instead of
just a return code.

Thanks,
Chris

>
> Interestingly the error handling of the utils.run call used all over 
> the module is IMHO a little bit inconsistent.
> If I remember correctly Andrew did some efforts in the past to have a 
> set of return codes comming from the base cibXXX and crm_XXX tools. (I 
> really don't know how much they are differentiated). Why not pass them 
> through?
>
> Best regards
> Andreas Mock
>
>
>
>
> ___
> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org 
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
>
> Project Home: http://www.clusterlabs.org Getting started: 
> http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://bugs.clusterlabs.org
>



___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://bugs.clusterlabs.org


Re: [Pacemaker] pcs: Return code handling not clean

2013-04-16 Thread Andrew Beekhof

On 17/04/2013, at 8:33 AM, Chris Feist  wrote:

> On 04/16/13 06:46, Andreas Mock wrote:
>> Hi all,
>> 
>> as I don't really know, where to address this
>> issue, I do post it here. On the one handside
>> as an information for guys scripting with the
>> help of 'pcs' and on the other handside with
>> the hope that one maintainer is listening
>> and will have a look at this.
>> 
>> Problem: When cluster is down a 'pcs resource'
>> shows an error message coming from a subprocess
>> call of 'crm_resource -L' but exits with an
>> error code of 0. That's something which can
>> be improved. Especially while the python code
>> does have error handling in other paces.
>> 
>> So I guess it is a simple oversight.
>> 
>> Look at the following piece of code in
>> pcs/resource.py:
>> 
>> 915 if len(argv) == 0:
>> 916 args = ["crm_resource","-L"]
>> 917 output,retval = utils.run(args)
>> 918 preg = re.compile(r'.*(stonith:.*)')
>> 919 for line in output.split('\n'):
>> 920 if not preg.match(line) and line != "":
>> 921 print line
>> 922 return
>> 
>> retval is totally ignored, while being handled on
>> other places. That leads to the fact that the script
>> returns with status 0.
> 
> This is an oversight on my part, I've updated the code to check retval and 
> return an error.  Currently I'm not passing through the full error code (I'm 
> only returning 0 on success and 1 on failure).  However, if you think it 
> would be useful to have this information I would be happy to look at it and 
> see what I can do.  I'm planning on eventually having pcs interpret the 
> crm_resource error code and provide a more user friendly output instead of 
> just a return code.

there is a crm_perror binary that might be useful for this

> 
> Thanks,
> Chris
> 
>> 
>> Interestingly the error handling of the utils.run call
>> used all over the module is IMHO a little bit inconsistent.
>> If I remember correctly Andrew did some efforts in the
>> past to have a set of return codes comming from the
>> base cibXXX and crm_XXX tools. (I really don't know
>> how much they are differentiated). Why not pass them
>> through?
>> 
>> Best regards
>> Andreas Mock
>> 
>> 
>> 
>> 
>> ___
>> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
>> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
>> 
>> Project Home: http://www.clusterlabs.org
>> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
>> Bugs: http://bugs.clusterlabs.org
>> 
> 
> 
> ___
> Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://bugs.clusterlabs.org


___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://bugs.clusterlabs.org


Re: [Pacemaker] pcs: Return code handling not clean

2013-04-16 Thread Chris Feist

On 04/16/13 06:46, Andreas Mock wrote:

Hi all,

as I don't really know, where to address this
issue, I do post it here. On the one handside
as an information for guys scripting with the
help of 'pcs' and on the other handside with
the hope that one maintainer is listening
and will have a look at this.

Problem: When cluster is down a 'pcs resource'
shows an error message coming from a subprocess
call of 'crm_resource -L' but exits with an
error code of 0. That's something which can
be improved. Especially while the python code
does have error handling in other paces.

So I guess it is a simple oversight.

Look at the following piece of code in
pcs/resource.py:

915 if len(argv) == 0:
916 args = ["crm_resource","-L"]
917 output,retval = utils.run(args)
918 preg = re.compile(r'.*(stonith:.*)')
919 for line in output.split('\n'):
920 if not preg.match(line) and line != "":
921 print line
922 return

retval is totally ignored, while being handled on
other places. That leads to the fact that the script
returns with status 0.


This is an oversight on my part, I've updated the code to check retval and 
return an error.  Currently I'm not passing through the full error code (I'm 
only returning 0 on success and 1 on failure).  However, if you think it would 
be useful to have this information I would be happy to look at it and see what I 
can do.  I'm planning on eventually having pcs interpret the crm_resource error 
code and provide a more user friendly output instead of just a return code.


Thanks,
Chris



Interestingly the error handling of the utils.run call
used all over the module is IMHO a little bit inconsistent.
If I remember correctly Andrew did some efforts in the
past to have a set of return codes comming from the
base cibXXX and crm_XXX tools. (I really don't know
how much they are differentiated). Why not pass them
through?

Best regards
Andreas Mock




___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://bugs.clusterlabs.org




___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://bugs.clusterlabs.org


[Pacemaker] pcs: Return code handling not clean

2013-04-16 Thread Andreas Mock
Hi all,

as I don't really know, where to address this
issue, I do post it here. On the one handside
as an information for guys scripting with the
help of 'pcs' and on the other handside with
the hope that one maintainer is listening
and will have a look at this.

Problem: When cluster is down a 'pcs resource'
shows an error message coming from a subprocess
call of 'crm_resource -L' but exits with an
error code of 0. That's something which can
be improved. Especially while the python code
does have error handling in other paces.

So I guess it is a simple oversight.

Look at the following piece of code in
pcs/resource.py:

915 if len(argv) == 0:
916 args = ["crm_resource","-L"]
917 output,retval = utils.run(args)
918 preg = re.compile(r'.*(stonith:.*)')
919 for line in output.split('\n'):
920 if not preg.match(line) and line != "":
921 print line
922 return

retval is totally ignored, while being handled on
other places. That leads to the fact that the script
returns with status 0.

Interestingly the error handling of the utils.run call
used all over the module is IMHO a little bit inconsistent.
If I remember correctly Andrew did some efforts in the
past to have a set of return codes comming from the
base cibXXX and crm_XXX tools. (I really don't know
how much they are differentiated). Why not pass them
through?

Best regards
Andreas Mock




___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://bugs.clusterlabs.org