-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Enforce that java.io.tmpdir exists on startup #28217
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
Enforce that java.io.tmpdir exists on startup #28217
Conversation
If the default java.io.tmpdir is used then the startup script creates it, but if a custom java.io.tmpdir is used then the user must ensure it exists before running Elasticsearch. If they forget then it can cause errors that are hard to understand, so this change adds an explicit check early in the bootstrap and reports a clear error if java.io.tmpdir is not an accessible directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am so sorry for the slow review. I left a comment for consideration.
@@ -288,6 +288,12 @@ static void init( | |||
} catch (IOException e) { | |||
throw new BootstrapException(e); | |||
} | |||
// a misconfigured java.io.tmpdir can cause hard-to-diagnose problems later, so reject it immediately |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am good with the change, but I wonder if we should validate it sooner (e.g., in Elasticsearch). There are other components of the system that might touch the java.io.tmpdir
before this validation is performed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I pushed another commit with the check moved into Elasticsearch.execute()
. That method seems to be the earliest one in the Elasticsearch
class that has access to an Environment
object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
If the default java.io.tmpdir is used then the startup script creates it, but if a custom java.io.tmpdir is used then the user must ensure it exists before running Elasticsearch. If they forget then it can cause errors that are hard to understand, so this change adds an explicit check early in the bootstrap and reports a clear error if java.io.tmpdir is not an accessible directory.
If the elasticsearch-env bash script chooses $ES_TMPDIR then it also creates the directory. This change makes elasticsearch-env.bat do the same thing: if %ES_TMPDIR% is chosen by the script then the script will ensure it exists, but if %ES_TMPDIR% is already set then the user is responsible for creating it. Relates elastic#27609 Relates elastic#28217
If the elasticsearch-env bash script chooses $ES_TMPDIR then it also creates the directory. This change makes elasticsearch-env.bat do the same thing: if %ES_TMPDIR% is chosen by the script then the script will ensure it exists, but if %ES_TMPDIR% is already set then the user is responsible for creating it. Relates #27609 Relates #28217
If the elasticsearch-env bash script chooses $ES_TMPDIR then it also creates the directory. This change makes elasticsearch-env.bat do the same thing: if %ES_TMPDIR% is chosen by the script then the script will ensure it exists, but if %ES_TMPDIR% is already set then the user is responsible for creating it. Relates #27609 Relates #28217
If the elasticsearch-env bash script chooses $ES_TMPDIR then it also creates the directory. This change makes elasticsearch-env.bat do the same thing: if %ES_TMPDIR% is chosen by the script then the script will ensure it exists, but if %ES_TMPDIR% is already set then the user is responsible for creating it. Relates #27609 Relates #28217
If the default java.io.tmpdir is used then the startup script creates
it, but if a custom java.io.tmpdir is used then the user must ensure it
exists before running Elasticsearch. If they forget then it can cause
errors that are hard to understand, so this change adds an explicit
check early in the bootstrap and reports a clear error if java.io.tmpdir
is not an accessible directory.