Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql_replication: terminology updates, "SLAVE" is deprecated #70

Closed
klingac opened this issue Dec 7, 2020 · 9 comments · Fixed by #71
Closed

mysql_replication: terminology updates, "SLAVE" is deprecated #70

klingac opened this issue Dec 7, 2020 · 9 comments · Fixed by #71

Comments

@klingac
Copy link

klingac commented Dec 7, 2020

SUMMARY

Since terminology updates in MySQL(from version 8) and MariaDB(from version 10.5.1) expresions, that contain "SLAVE" are deprecated.
E.g. SHOW SLAVE STATUS is changing to SHOW REPLICA STATUS.

If we use PyMysql on the server side (only option for non-deprecated pyhton3), we get this error

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: pymysql.err.Warning: (1287, "'SHOW SLAVE STATUS' is deprecated and will be removed in a future release. Please use SHOW REPLICA STATUS instead")

This makes us unable to use mysql_replication module with python3.
Same problem is for modul modes startslave, stopslave, resetslave and resetslaveall.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mysql_replication

ANSIBLE VERSION
ansible 2.10.3
  config file = ansible.cfg
  configured module search path = ['/usr/share/ansible/plugins/modules']
  ansible python module location = $HOME/bin/ansible2.10/lib/python3.8/site-packages/ansible
  executable location = $HOME/bin/ansible2.10/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
CONFIGURATION
ANSIBLE_NOCOWS = True
DEFAULT_CALLBACK_WHITELIST = ['timer', 'profile_roles', 'actionable', 'counter_enabled', 'selective']
DEFAULT_LOAD_CALLBACK_PLUGINS = True
DEFAULT_LOG_PATH = /home/klingac/projects/devel/ETN/LOGIO/logio-ansible/logs/ansible.log
DEFAULT_MANAGED_STR = Ansible managed, do not edit directly
DEFAULT_ROLES_PATH = ['./roles']
DEFAULT_STDOUT_CALLBACK = default
DEFAULT_VAULT_PASSWORD_FILE = vault_pass.txt
DEFAULT_VERBOSITY = 2
DIFF_ALWAYS = True
DISPLAY_SKIPPED_HOSTS = True
ENABLE_TASK_DEBUGGER = False
HOST_KEY_CHECKING = False
SHOW_CUSTOM_STATS = False
OS / ENVIRONMENT
$ uname -a

Linux ****** 5.4.0-56-generic #62-Ubuntu SMP Mon Nov 23 19:20:19 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
STEPS TO REPRODUCE

Run playbook below against servers with e.g. Ubuntu 20.04 LTS with replicated MySQL. It will result to error.

- name: Ensure MySQL packages are installed.
  vars:
    mysql_packages:
      - mysql-common
      - mysql-server-8.0
      - python3-pymysql
  apt:
    name: "{{ mysql_packages }}"
    state: present

- name: Get slave replication status
  mysql_replication:
    mode: getslave
EXPECTED RESULTS

We expect something like this (shortened output)

TASK [Get slave replication status] ***************************************************************************                                                                                                                                        
task path: mysql.replication/tasks/get_replication_status.yml:2                                                                                                                                                  
ok: [host1] => {"Auto_Position": 0, "Channel_Name": "", "Connect_Retry": 60, ... "Replica_IO_Running": "Yes", "Replica_IO_State": "Waiting for master to send event", "Replica_SQL_Running": "Yes",.... "changed": false} 
ACTUAL RESULTS
TASK [Get slave replication status] ********************************************************************************************************************************************************************************************************************
task path: mysql.replication/tasks/get_replication_status.yml:10                                                                                                                                                 
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1607376073.271708-390396-261438469596099/AnsiballZ_mysql_replication.py", line 102, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1607376073.271708-390396-261438469596099/AnsiballZ_mysql_replication.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1607376073.271708-390396-261438469596099/AnsiballZ_mysql_replication.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.database.mysql.mysql_replication', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_mysql_replication_payload_x4ivv87j/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py", line 373, in <module>
  File "/tmp/ansible_mysql_replication_payload_x4ivv87j/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py", line 279, in main
  File "/tmp/ansible_mysql_replication_payload_x4ivv87j/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py", line 148, in get_slave_status
  File "/usr/lib/python3/dist-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/usr/lib/python3/dist-packages/pymysql/cursors.py", line 329, in _query
    self._do_get_result()
  File "/usr/lib/python3/dist-packages/pymysql/cursors.py", line 391, in _do_get_result
    super(DictCursorMixin, self)._do_get_result()
  File "/usr/lib/python3/dist-packages/pymysql/cursors.py", line 353, in _do_get_result
    self._show_warnings()
  File "/usr/lib/python3/dist-packages/pymysql/cursors.py", line 369, in _show_warnings
    warnings.warn(err.Warning(*w[1:3]), stacklevel=4)
pymysql.err.Warning: (1287, "'SHOW SLAVE STATUS' is deprecated and will be removed in a future release. Please use SHOW REPLICA STATUS instead")
fatal: [logio-pp-stage-keycloak-2.lgo.etn]: FAILED! => {
    "changed": false,
    "module_stderr": "OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data ./ssh.cfg\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 384398\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to logio-pp-stage-keycloak-2.lgo.etn closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1607376073.271708-390396-261438469596099/AnsiballZ_mysql_replication.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1607376073.271708-390396-261438469596099/AnsiballZ_mysql_replication.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1607376073.271708-390396-261438469596099/AnsiballZ_mysql_replication.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.database.mysql.mysql_replication', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_mysql_replication_payload_x4ivv87j/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py\", line 373, in <module>\r\n  File \"/tmp/ansible_mysql_replication_payload_x4ivv87j/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py\", line 279, in main\r\n  File \"/tmp/ansible_mysql_replication_payload_x4ivv87j/ansible_mysql_replication_payload.zip/ansible/modules/database/mysql/mysql_replication.py\", line 148, in get_slave_status\r\n  File \"/usr/lib/python3/dist-packages/pymysql/cursors.py\", line 170, in execute\r\n    result = self._query(query)\r\n  File \"/usr/lib/python3/dist-packages/pymysql/cursors.py\", line 329, in _query\r\n    self._do_get_result()\r\n  File \"/usr/lib/python3/dist-packages/pymysql/cursors.py\", line 391, in _do_get_result\r\n    super(DictCursorMixin, self)._do_get_result()\r\n  File \"/usr/lib/python3/dist-packages/pymysql/cursors.py\", line 353, in _do_get_result\r\n    self._show_warnings()\r\n  File \"/usr/lib/python3/dist-packages/pymysql/cursors.py\", line 369, in _show_warnings\r\n    warnings.warn(err.Warning(*w[1:3]), stacklevel=4)\r\npymysql.err.Warning: (1287, \"'SHOW SLAVE STATUS' is deprecated and will be removed in a future release. Please use SHOW REPLICA STATUS instead\")\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
@klingac klingac changed the title mysql_replication: terminology updates, "SLAVE" ise deprecated mysql_replication: terminology updates, "SLAVE" is deprecated Dec 7, 2020
@Andersson007
Copy link
Collaborator

@klingac thanks for reporting the issue!
I hope the community will fix this soon. Would be happy to provide a review

@Andersson007
Copy link
Collaborator

cc @banyek

@Andersson007
Copy link
Collaborator

@Andersson007
Copy link
Collaborator

I created a PR #71
Despite having the integration and unit tests, @klingac would be great if you (or anybody else) try this in your test environment with 8.0.21 (or earlier) and 8.0.22 and confirm that this solves. The changes are significant, so would be safer to test it manually before merging (i don't have infrastructure for that)

@Andersson007
Copy link
Collaborator

Closed via #71 (merged).

@Andersson007
Copy link
Collaborator

@klingac thanks for reporting the issue!

I've just released community.mysql 1.1.2 containing the fix which tarbal is available here to download and use. The changes will also appear in the Ansible package patch release. How to install in manually, refer to this document

If you have any issues related to the changes made by me in #71 , please use the previous release and let me know. Thanks!

@klingac
Copy link
Author

klingac commented Dec 27, 2020

@Andersson007 thank you very much for your work here.
I just tested this on my environment and everything seems to be OK. I have two points to this:

  1. Will be this changes backported even to ansible 2.9 or older?
  2. May I suggest to make these changes to be "more complete"? I mean could we unify mysql_replication module's params with terminology updates? E.g. startslave param could change to startreplica, getslave to getreplica etc. Old params (startslave, getslave,..) could stay as aliases until older MySQL versions (<8.0.22) will be outdated.

@Andersson007
Copy link
Collaborator

Andersson007 commented Dec 28, 2020

@klingac thanks for the feedback!

  1. It can technically be backported to 2.9 (to earlier versions only security fixes are allowed) but i wouldn't do it because it's not so flexible there as it is with collections. Moreover 2.9 supports collections and users can install the fixed version of community.mysql from Galaxy and use.
  2. I also thought of adding the aliases, thanks for reminding, will see. If you like to add the aliases yourself, feel free to do it, I'll be happy to review

Thanks!

@Andersson007
Copy link
Collaborator

Not to forget, I created the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants