From 7ba10e559e0b47ffc769e2e6fee05863d8c546a5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 13 Sep 2021 10:03:32 -0400 Subject: [PATCH] Correct ipv4/v6 handling in get_apikey --- .../common/opt/confluent/bin/apiclient | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/confluent_osdeploy/common/opt/confluent/bin/apiclient b/confluent_osdeploy/common/opt/confluent/bin/apiclient index 0586c373..8c8e0531 100644 --- a/confluent_osdeploy/common/opt/confluent/bin/apiclient +++ b/confluent_osdeploy/common/opt/confluent/bin/apiclient @@ -19,14 +19,18 @@ def get_apikey(nodename, mgr, mgr6): apikey = open('/etc/confluent/confluent.apikey').read().strip() if apikey: return apikey + hosts = [] + for host in (mgr, mgr6): + if not host: + continue + hosts.append(host) while not apikey: - try: - apikey = subprocess.check_output(['/opt/confluent/bin/clortho', nodename, mgr]) - except subprocess.CalledProcessError: + for host in hosts: try: - apikey = subprocess.check_output(['/opt/confluent/bin/clortho', nodename, mgr6]) + apikey = subprocess.check_output(['/opt/confluent/bin/clortho', nodename, host]) except subprocess.CalledProcessError: - apikey = '' + continue + break if not isinstance(apikey, str): apikey = apikey.decode('utf8') if apikey.startswith('SEALED:'):