Bug #79175 mysqlrpladmin scripts are not called with the same arguments
Submitted: 8 Nov 2015 5:44 Modified: 16 Sep 2016 6:41
Reporter: monty solomon Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Utilities Severity:S2 (Serious)
Version:1.5, 1.6 OS:Any
Assigned to: CPU Architecture:Any

[8 Nov 2015 5:44] monty solomon
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])
[16 Sep 2016 5:29] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=81997 marked as duplicate of this one.
[16 Sep 2016 6:41] Chiranjeevi Battula
Hello monty solomon,

Thank you for the bug report.

Thanks,
Chiranjeevi.