Commit c1ff2832 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Capture last exception



This fixes a minor problem in LURenewCrypto, where we
use the exception variable after the try/except block.
By assigning it to a previously initialized one, we make
sure that we can access this information.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 1c5456b5
......@@ -131,6 +131,7 @@ class LUClusterRenewCrypto(NoHooksLU):
except IOError:
logging.info("No old certificate available.")
last_exception = None
for _ in range(self._MAX_NUM_RETRIES):
try:
# Technically it should not be necessary to set the cert
......@@ -142,10 +143,11 @@ class LUClusterRenewCrypto(NoHooksLU):
client_cert_tmp=pathutils.NODED_CLIENT_CERT_FILE_TMP)
break
except errors.OpExecError as e:
pass
last_exception = e
else:
feedback_fn("Could not renew the master's client SSL certificate."
" Cleaning up. Error: %s." % e)
if last_exception:
feedback_fn("Could not renew the master's client SSL certificate."
" Cleaning up. Error: %s." % last_exception)
# Cleaning up temporary certificates
utils.RemoveNodeFromCandidateCerts("%s-SERVER" % master_uuid,
cluster.candidate_certs)
......@@ -164,6 +166,7 @@ class LUClusterRenewCrypto(NoHooksLU):
feedback_fn("* Skipping offline node %s" % node_info.name)
continue
if node_uuid != master_uuid:
last_exception = None
for _ in range(self._MAX_NUM_RETRIES):
try:
new_digest = CreateNewClientCert(self, node_uuid)
......@@ -172,8 +175,8 @@ class LUClusterRenewCrypto(NoHooksLU):
new_digest,
cluster.candidate_certs)
break
except errors.OpExecError as last_exception:
pass
except errors.OpExecError as e:
last_exception = e
else:
if last_exception:
node_errors[node_uuid] = last_exception
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment