Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 853db5a

Browse files
authored
mysql_replication: add deprecation warning about future replacement of Is_Slave and Is_Master return values, add alternatives (ansible-collections#147)
* mysql_replication: add deprecation warning about future replacement of Is_Slave and Is_Master return values, add alternatives * Add changelog fragment
1 parent f7c84a7 commit 853db5a

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
major_changes:
2+
- 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).
3+
4+
minor_changes:
5+
- 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).

plugins/modules/mysql_replication.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,17 @@ def main():
524524
if mode in "getmaster":
525525
status = get_master_status(cursor)
526526
if not isinstance(status, dict):
527-
status = dict(Is_Master=False, msg="Server is not configured as mysql master")
527+
status = dict(Is_Master=False, Is_Primary=False,
528+
msg="Server is not configured as mysql master")
528529
else:
529530
status['Is_Master'] = True
531+
status['Is_Primary'] = True
532+
533+
module.deprecate('"Is_Master" and "Is_Slave" return values are deprecated '
534+
'and will be replaced with "Is_Primary" and "Is_Replica" '
535+
'in the next major release. Use "Is_Primary" and "Is_Replica" instead.',
536+
version='3.0.0', collection_name='community.mysql')
537+
530538
module.exit_json(queries=executed_queries, **status)
531539

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

537545
status = get_replica_status(cursor, connection_name, channel, replica_term)
538546
if not isinstance(status, dict):
539-
# TODO: announce it and replace with Replica
540-
# in the next major release. Maybe a warning?
541-
status = dict(Is_Slave=False, msg="Server is not configured as mysql replica")
547+
status = dict(Is_Slave=False, Is_Replica=False, msg="Server is not configured as mysql replica")
542548
else:
543-
# TODO: announce it and replace with Replica
544-
# in the next major release. Maybe a warning?
545549
status['Is_Slave'] = True
550+
status['Is_Replica'] = True
551+
552+
module.deprecate('"Is_Master" and "Is_Slave" return values are deprecated '
553+
'and will be replaced with "Is_Primary" and "Is_Replica" '
554+
'in the next major release. Use "Is_Primary" and "Is_Replica" instead.',
555+
version='3.0.0', collection_name='community.mysql')
556+
546557
module.exit_json(queries=executed_queries, **status)
547558

548559
elif mode in "changemaster":

tests/integration/targets/test_mysql_replication/tasks/mysql_replication_channel.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
- assert:
6363
that:
64-
- replica_status.Is_Slave == true
64+
- replica_status.Is_Replica == true
6565
- replica_status.Master_Host == '{{ mysql_host }}'
6666
- replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position
6767
- replica_status.Master_Port == {{ mysql_primary_port }}
@@ -73,7 +73,7 @@
7373

7474
- assert:
7575
that:
76-
- replica_status.Is_Slave == true
76+
- replica_status.Is_Replica == true
7777
- replica_status.Source_Host == '{{ mysql_host }}'
7878
- replica_status.Exec_Source_Log_Pos == mysql_primary_status.Position
7979
- replica_status.Source_Port == {{ mysql_primary_port }}

tests/integration/targets/test_mysql_replication/tasks/mysql_replication_initial.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
- assert:
6161
that:
62-
- mysql_primary_status.Is_Master == true
62+
- mysql_primary_status.Is_Primary == true
6363
- mysql_primary_status.Position != 0
6464
- mysql_primary_status is not changed
6565

@@ -148,7 +148,7 @@
148148

149149
- assert:
150150
that:
151-
- replica_status.Is_Slave == true
151+
- replica_status.Is_Replica == true
152152
- replica_status.Master_Host == '{{ mysql_host }}'
153153
- replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position
154154
- replica_status.Master_Port == {{ mysql_primary_port }}

0 commit comments

Comments
 (0)