From 5b425fc297ce15bbe3e899709097401156310f82 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 25 Sep 2020 08:17:56 +0200 Subject: [PATCH] [aerospike_migrations] - handle exception for unstable-cluster (#900) (#959) * [aerospike_migrations] - handle exception when unstable-cluster is returned * fix lint issue * Update changelogs/fragments/900-aerospike-migration-handle-unstable-cluster.yaml Co-authored-by: Felix Fontein Co-authored-by: Kailun Shi Co-authored-by: Felix Fontein (cherry picked from commit 62ae120c508f36340803ce01212638a1d77c0b75) Co-authored-by: Kailun --- .../900-aerospike-migration-handle-unstable-cluster.yaml | 3 +++ plugins/modules/database/aerospike/aerospike_migrations.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/900-aerospike-migration-handle-unstable-cluster.yaml diff --git a/changelogs/fragments/900-aerospike-migration-handle-unstable-cluster.yaml b/changelogs/fragments/900-aerospike-migration-handle-unstable-cluster.yaml new file mode 100644 index 0000000000..ac8c0d0869 --- /dev/null +++ b/changelogs/fragments/900-aerospike-migration-handle-unstable-cluster.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - aerospike_migrations - handle exception when unstable-cluster is returned (https://github.com/ansible-collections/community.general/pull/900). diff --git a/plugins/modules/database/aerospike/aerospike_migrations.py b/plugins/modules/database/aerospike/aerospike_migrations.py index 6f9d9c017a..27bfc1a95b 100644 --- a/plugins/modules/database/aerospike/aerospike_migrations.py +++ b/plugins/modules/database/aerospike/aerospike_migrations.py @@ -439,7 +439,12 @@ class Migrations: if target_cluster_size is not None: cmd = cmd + "size=" + str(target_cluster_size) + ";" for node in self._nodes: - cluster_key.add(self._info_cmd_helper(cmd, node)) + try: + cluster_key.add(self._info_cmd_helper(cmd, node)) + except aerospike.exception.ServerError as e: # unstable-cluster is returned in form of Exception + if 'unstable-cluster' in e.msg: + return False + raise e if len(cluster_key) == 1: return True return False