2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Fix apiclient with TPM managed token

The retry mechanism is amended
to clear out the useless key
and start trying to get a network grant again.
This commit is contained in:
Jarrod Johnson 2021-06-24 14:53:54 -04:00
parent 2ef695324a
commit 42f8056d56

View File

@ -20,7 +20,10 @@ def get_apikey(nodename, mgr):
if apikey:
return apikey
while not apikey:
apikey = subprocess.check_output(['/opt/confluent/bin/clortho', nodename, mgr])
try:
apikey = subprocess.check_output(['/opt/confluent/bin/clortho', nodename, mgr])
except subprocess.CalledProcessError:
apikey = ''
if not isinstance(apikey, str):
apikey = apikey.decode('utf8')
if apikey.startswith('SEALED:'):
@ -116,6 +119,8 @@ class HTTPSClient(client.HTTPConnection, object):
if rsp.status == 401:
authed = False
rsp.read()
with open('/etc/confluent/confluent.apikey', 'w+') as akfile:
akfile.write()
self.stdheaders['CONFLUENT_APIKEY'] = get_apikey(
self.node, self.host)
raise Exception(rsp.read())