Skip to content

Commit ab9a0fd

Browse files
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.
1 parent 764ee30 commit ab9a0fd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

framework/db/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public static void main(String[] args) {
147147
{
148148
bwriter.write(newMSKey);
149149
} catch (IOException e) {
150-
System.out.println("Failed to write new secret to file. Please update the file manually");
150+
System.out.println(String.format("Please update the file %s manually. Failed to write new secret to file with error %s", keyFile, e.getMessage()));
151151
}
152152
}
153153
}

setup/bindir/cloud-setup-databases.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,11 @@ for example:
397397

398398
def saveMgmtServerSecretKey():
399399
if self.encryptiontype == 'file':
400-
open(self.encryptionKeyFile, 'w').write(self.mgmtsecretkey)
400+
try:
401+
open(self.encryptionKeyFile, 'w').write(self.mgmtsecretkey)
402+
except IOError as e:
403+
msg = "Failed to save management server secret key file %s due to %s, also please check the default umask"%(self.encryptionKeyFile, e.strerror)
404+
self.errorAndExit(msg)
401405

402406
def formatEncryptResult(value):
403407
return 'ENC(%s)'%value

0 commit comments

Comments
 (0)