Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readConfigVarFromFilesystem returning None on error hides the root cause #967

Open
ptrdom opened this issue Oct 21, 2021 · 0 comments
Open

Comments

@ptrdom
Copy link
Contributor

ptrdom commented Oct 21, 2021

Versions used

Akka version: 2.6.13

Description

Currently KubernetesApiServiceDiscovery.readConfigVarFromFilesystem method returns None in case of an error reading from a file. This causes complications down the line when trying to identify what is going on. For example, I had an issue where reading the file threw permissions errors. Discovery process proceeds and simply fails to make k8s API requests because it no longer provides Bearer tokens. Error is still logged, but it gets quickly obscured by all the error logs about permissions for anonymous user account, so the root cause gets effectively hidden, making this a gotcha that each developer has to learn. I think this kind of exception should be treated more severely, maybe even by terminating the application, because this is basically a fatal error. Would implementing that make sense?

private def readConfigVarFromFilesystem(path: String, name: String): Option[String] = {
val file = Paths.get(path)
if (Files.exists(file)) {
try {
Some(new String(Files.readAllBytes(file), "utf-8"))
} catch {
case NonFatal(e) =>
log.error(e, "Error reading {} from {}", name, path)
None
}
} else {
log.warning("Unable to read {} from {} because it doesn't exist.", name, path)
None
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant