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: add deprecation warning about future replacement of Is_Slave and Is_Master return values, add alternatives #147

Merged
merged 2 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
major_changes:
- mysql_replication - add deprecation warning that the ``Is_Slave`` and ``Is_Master`` return values will be replaced with ``Is_Primary`` and ``Is_Replica`` in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/pull/147).

minor_changes:
- mysql_replication - add the ``Is_Primary`` and ``Is_Replica`` alternatives to the ``Is_Slave`` and ``Is_Master`` return values as a preparation for replacement in ``community.mysql`` 3.0.0 (https://github.com/ansible-collections/community.mysql/pull/147).
23 changes: 17 additions & 6 deletions plugins/modules/mysql_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,17 @@ def main():
if mode in "getmaster":
status = get_master_status(cursor)
if not isinstance(status, dict):
status = dict(Is_Master=False, msg="Server is not configured as mysql master")
status = dict(Is_Master=False, Is_Primary=False,
msg="Server is not configured as mysql master")
else:
status['Is_Master'] = True
status['Is_Primary'] = True

module.deprecate('"Is_Master" and "Is_Slave" return values are deprecated '
'and will be replaced with "Is_Primary" and "Is_Replica" '
'in the next major release. Use "Is_Primary" and "Is_Replica" instead.',
version='3.0.0', collection_name='community.mysql')

module.exit_json(queries=executed_queries, **status)

elif mode in ("getreplica", "getslave"):
Expand All @@ -536,13 +544,16 @@ def main():

status = get_replica_status(cursor, connection_name, channel, replica_term)
if not isinstance(status, dict):
# TODO: announce it and replace with Replica
# in the next major release. Maybe a warning?
status = dict(Is_Slave=False, msg="Server is not configured as mysql replica")
status = dict(Is_Slave=False, Is_Replica=False, msg="Server is not configured as mysql replica")
else:
# TODO: announce it and replace with Replica
# in the next major release. Maybe a warning?
status['Is_Slave'] = True
status['Is_Replica'] = True

module.deprecate('"Is_Master" and "Is_Slave" return values are deprecated '
'and will be replaced with "Is_Primary" and "Is_Replica" '
'in the next major release. Use "Is_Primary" and "Is_Replica" instead.',
version='3.0.0', collection_name='community.mysql')

module.exit_json(queries=executed_queries, **status)

elif mode in "changemaster":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

- assert:
that:
- replica_status.Is_Slave == true
- replica_status.Is_Replica == true
- replica_status.Master_Host == '{{ mysql_host }}'
- replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position
- replica_status.Master_Port == {{ mysql_primary_port }}
Expand All @@ -73,7 +73,7 @@

- assert:
that:
- replica_status.Is_Slave == true
- replica_status.Is_Replica == true
- replica_status.Source_Host == '{{ mysql_host }}'
- replica_status.Exec_Source_Log_Pos == mysql_primary_status.Position
- replica_status.Source_Port == {{ mysql_primary_port }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

- assert:
that:
- mysql_primary_status.Is_Master == true
- mysql_primary_status.Is_Primary == true
- mysql_primary_status.Position != 0
- mysql_primary_status is not changed

Expand Down Expand Up @@ -148,7 +148,7 @@

- assert:
that:
- replica_status.Is_Slave == true
- replica_status.Is_Replica == true
- replica_status.Master_Host == '{{ mysql_host }}'
- replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position
- replica_status.Master_Port == {{ mysql_primary_port }}
Expand Down