Skip to content

Commit f3fdc65

Browse files
authored
adding to log traces, set env SKR_TRACE_ON for failed cases (#1853)
* adding to log traces, set env SKR_TRACE_ON for failed cases * update the log message
1 parent 5bfe3cd commit f3fdc65

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

VMEncryption/main/check_util.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,25 @@ def validate_skr_release_rsa_or_ec_key(self,public_settings,check_release_rsa_or
401401
return
402402
manage_id = public_settings.get(CommonVariables.EncryptionManagedIdentity)
403403
KeyEncryptionKeyUrl=public_settings.get(CommonVariables.KeyEncryptionKeyURLKey)
404-
if manage_id:
405-
ret = self._update_imds_managed_id_env_variable(manage_id)
406-
if not ret:
407-
raise Exception(msg)
404+
#checking if managed_id and KeyEncryptionKeyUrl is present. mandatory for DDE.
405+
if not manage_id:
406+
raise Exception('managed identity is not provided. Managed Identity is a mandatory field.')
407+
if not KeyEncryptionKeyUrl:
408+
raise Exception('KEK URL is not provided. Key encryption key URL is a mandatory field.')
409+
ret = self._update_imds_managed_id_env_variable(manage_id)
410+
if not ret:
411+
raise Exception(msg)
408412
cmd = './AzureAttestSKR -n 123456 -k {0} -c imds -r'.format(KeyEncryptionKeyUrl)
409413
executor = CommandExecutor(self.logger)
410414
result = executor.Execute(cmd)
411415
if result != CommonVariables.process_success:
412-
if manage_id:
413-
raise Exception ('{0} Encryption managed identity: {1}'.format(msg,manage_id))
414-
raise Exception(msg)
416+
#SKR is failed trace the logs.
417+
self.logger.log('SKR has failed. Turn on tracing and log the output.')
418+
os.environ["SKR_TRACE_ON"]="1"
419+
result = executor.Execute(cmd)
420+
#re-check, to ensure the SKR.
421+
if result != CommonVariables.process_success:
422+
raise Exception(msg)
415423
return
416424

417425
def precheck_for_fatal_failures(self, public_settings, encryption_status, DistroPatcher, existing_volume_type,check_release_rsa_or_ec_key=False):

0 commit comments

Comments
 (0)