Description:
Four (4) arguments are passed to the before-script during both failover and switchover.
Four (4) arguments are passed to the after-script during failover but only two (2) arguments are passed to the after-script during switchover.
During switchover, the before script is called with parameters [master host/port and candidate host/port] but the after script is called only with parameters [new master host/port].
During failover both scripts are called with parameters [old host/port, host/port].
As a result, the after script is missing information during switchover and the same set of scripts can't be used for both failover and switchover.
How to repeat:
Execute a switchover using the mysqlrpladmin utility
mysqlrpladmin switchover --verbose --discover-slaves-login=.mysqlrpladmin.cnf[white-fog] --master=.mysqlrpladmin.cnf[white-fog] --new-master=.mysqlrpladmin.cnf[calm-shape] --demote-master --rpl-user=SUSR_Repl:redacted --log=mysqlrpladmin.log --timeout=5 --exec-before $HOME/test.sh --exec-after $HOME/test.sh
# SCRIPT EXECUTED: ['test.sh', 'white-fog', '3306', 'calm-shape', '3306']
...
# SCRIPT EXECUTED: ['test.sh', 'calm-shape', '3306']
Suggested fix:
Pass the same four (4) arguments to both scripts - master and slave host/port.
Here is the current code.
switchover
# Call exec_before script - display output if verbose on
self.run_script(self.before_script, False,
[self.master.host, self.master.port,
m_candidate.host, m_candidate.port])
# Call exec_after script - display output if verbose on
self.run_script(self.after_script, False,
[self.master.host, self.master.port])
failover
# Call exec_before script - display output if verbose on
self.run_script(self.before_script, False,
[old_host, old_port, host, port])
# Call exec_after script - display output if verbose on
self.run_script(self.after_script, False,
[old_host, old_port, host, port])