Updated log message and throw error when unable to update the secret key file (#6542)

This PR fixes issue #6232 to update the error message and throw the error when updating key file is failed. This helps to find out the proper reason for failure, mainly with umask.
This commit is contained in:
Harikrishna 2022-07-09 21:21:11 +05:30 committed by GitHub
parent 764ee30ecc
commit ab9a0fd69f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -147,7 +147,7 @@ public class EncryptionSecretKeyChanger {
{ {
bwriter.write(newMSKey); bwriter.write(newMSKey);
} catch (IOException e) { } catch (IOException e) {
System.out.println("Failed to write new secret to file. Please update the file manually"); System.out.println(String.format("Please update the file %s manually. Failed to write new secret to file with error %s", keyFile, e.getMessage()));
} }
} }
} }

View File

@ -397,7 +397,11 @@ for example:
def saveMgmtServerSecretKey(): def saveMgmtServerSecretKey():
if self.encryptiontype == 'file': if self.encryptiontype == 'file':
open(self.encryptionKeyFile, 'w').write(self.mgmtsecretkey) try:
open(self.encryptionKeyFile, 'w').write(self.mgmtsecretkey)
except IOError as e:
msg = "Failed to save management server secret key file %s due to %s, also please check the default umask"%(self.encryptionKeyFile, e.strerror)
self.errorAndExit(msg)
def formatEncryptResult(value): def formatEncryptResult(value):
return 'ENC(%s)'%value return 'ENC(%s)'%value