Skip to content

Commit

Permalink
Log when PasswordManager fails to load any master password (#3849)
Browse files Browse the repository at this point in the history
  • Loading branch information
phet authored Dec 15, 2023
1 parent 81910bf commit cb36e2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private List<TextEncryptor> getEncryptors(CachedInstanceKey cacheKey) {
try (Closer closer = Closer.create()) {
if (!fs.exists(currentMasterPasswordFile) ||
fs.getFileStatus(currentMasterPasswordFile).isDirectory()) {
LOG.warn("Master password path '" + currentMasterPasswordFile + "' not a FileSystem file.");
continue;
}
InputStream in = closer.register(fs.open(currentMasterPasswordFile));
Expand All @@ -124,18 +125,23 @@ private List<TextEncryptor> getEncryptors(CachedInstanceKey cacheKey) {
suffix = "." + String.valueOf(i);
} catch (FileNotFoundException fnf) {
// It is ok for password files not being present
LOG.warn("Master password file " + currentMasterPasswordFile + " not found.");
LOG.warn("Master password file '" + currentMasterPasswordFile + "' not found.");
} catch (IOException ioe) {
exception = ioe;
LOG.warn("Master password could not be read from file " + currentMasterPasswordFile);
LOG.warn("Master password file could not be read from '" + currentMasterPasswordFile + "'");
} catch (Exception e) {
LOG.warn("Encryptor could not be instantiated.");
LOG.warn("Encryptor could not be instantiated using file '" + currentMasterPasswordFile + "'.", e);
}
} while (i++ < numOfEncryptionKeys);

// Throw exception if could not read any existing password file
if (encryptors.size() < 1 && exception != null) {
throw new RuntimeException("Master Password could not be read from any master password file.", exception);
if (encryptors.size() < 1) {
if (exception != null) {
throw new RuntimeException("Master password could not be read from any master password file.", exception);
} else {
// TODO: determine whether to always throw whenever no encryptors, despite `exception == null`! (for now, at least give notice by logging)
LOG.error("No master password loaded, despite " + numOfEncryptionKeys + " encryption keys!");
}
}
return encryptors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,8 @@ private void cancelDagNode(DagNode<JobExecutionPlan> dagNodeToCancel) throws Exe
String serializedFuture = DagManagerUtils.getSpecProducer(dagNodeToCancel).serializeAddSpecResponse(future);
props.put(ConfigurationKeys.SPEC_PRODUCER_SERIALIZED_FUTURE, serializedFuture);
sendCancellationEvent(dagNodeToCancel.getValue());
} else {
log.warn("No Job future when canceling DAG node (hence, not sending cancellation event) - {}", dagNodeToCancel.getValue().getJobSpec().getUri());
}
if (dagNodeToCancel.getValue().getJobSpec().getConfig().hasPath(ConfigurationKeys.FLOW_EXECUTION_ID_KEY)) {
props.setProperty(ConfigurationKeys.FLOW_EXECUTION_ID_KEY,
Expand Down

0 comments on commit cb36e2c

Please sign in to comment.