Bug #79278 mysqlrpladmin returns 0 exit status on failure
Submitted: 13 Nov 2015 19:56 Modified: 23 Nov 2016 10:40
Reporter: monty solomon Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Utilities Severity:S2 (Serious)
Version:1.5, 1.6 OS:CentOS
Assigned to: CPU Architecture:Any

[13 Nov 2015 19:56] monty solomon
Description:
After aborting a switchover, mysqlrpladmin returns an exit status of 0 instead of 1.

How to repeat:
Execute mysqlrpladmin switchover twice in a row using the same options.

Check the exist status after each run.

$ mysqlrpladmin switchover --verbose --discover-slaves-login=.myrpladmin.cnf[white-fog] --master=.myrpladmin.cnf[white-fog] --new-master=.myrpladmin.cnf[calm-shape] --demote-master --rpl-user=SUSR_Repl:redacted --log=mysqlrpladmin.log --timeout=5

# Checking eligibility of slave white-fog:3306 for candidate.
#   Slave connected to master ... FAIL
Candidate is not connected to the correct master.
ERROR: Candidate is not connected to the correct master.
# Errors found. Switchover aborted.

$ echo $?
0

Suggested fix:
The _switchover() and _failover() functions return False on error but the returned False value is ignored by the execute_command() function.

The execute_command() function should check for any False return value, handle it, and return it to its caller.
[13 Nov 2015 22:08] Miguel Solorzano
Thank you for the bug report. This was already filed and discussed for other command clients and the answer from development was won't fix, please see the last comment of bug https://bugs.mysql.com/bug.php?id=62877 which explains why.
[15 Nov 2015 3:53] monty solomon
That comment was from three (3) years ago and should be revisited.

In this case, the _switchover() and _failover() functions know they failed and they return False but the return code is ignored by the execute_command() function.

It is not possible to create a script that executes mysqlrpladmin switchover and then changes the DNS CNAMEs only if the switchover succeeds.
[23 Nov 2016 10:40] Chiranjeevi Battula
Hello monty solomon,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.