-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HADOOP-19639. SecretManager configuration at runtime #7827
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
Conversation
07f20c7
to
fecb7de
Compare
- static configuration of SecretManager is required because it has some static method what use the selected algorithm - in case if class path not contains the config values (for example TEZ DAGAppMaster run) the default values will be loaded at runtime - the default values can cause failers in modern environments (they are not FIPS compliant) - new SecretManagerConfig created to be able to modify the SecretManager config without core-site.xml present on class path
...roject/hadoop-common/src/main/java/org/apache/hadoop/security/token/SecretManagerConfig.java
Outdated
Show resolved
Hide resolved
...roject/hadoop-common/src/main/java/org/apache/hadoop/security/token/SecretManagerConfig.java
Outdated
Show resolved
Hide resolved
...roject/hadoop-common/src/main/java/org/apache/hadoop/security/token/SecretManagerConfig.java
Outdated
Show resolved
Hide resolved
...roject/hadoop-common/src/main/java/org/apache/hadoop/security/token/SecretManagerConfig.java
Outdated
Show resolved
Hide resolved
- remove setters from SecretManagerConfig
- add Warning message to update if Mac or Keygen was already created with other config
- delete extra space
- add interface doc
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
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.
Thank you for the patch @K0K0V0K . This looks good to me!
@K0K0V0K LGTM +1. |
...roject/hadoop-common/src/main/java/org/apache/hadoop/security/token/SecretManagerConfig.java
Outdated
Show resolved
Hide resolved
...roject/hadoop-common/src/main/java/org/apache/hadoop/security/token/SecretManagerConfig.java
Outdated
Show resolved
Hide resolved
@K0K0V0K thanks for the patch so far! please consider the 2 comments I left before proceeding, I believe it would make this patch cleaner and more user-friendly |
🎊 +1 overall
This message was automatically generated. |
- improve debug logs
- fix visibility
private static String selectedAlgorithm; | ||
private static int selectedLength; | ||
|
||
private static final Map<Thread, KeyGenerator> KEYGENS = new WeakHashMap<>(); |
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.
KeyGenerator is not threadlocal, there will be a single global instance, right?
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.
If everything works as expected yes, but no there is not granted some one will not call this method again ...
you right this should be in SecretManager not in an other class
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 just rechecked the code, seems like Keygenerator is a local variable for every SecretManager instance.
Maybe this could be thread local, and maybe could improve the performance, but i would rather not touch this for sake of the stability.
"Hint: If you turn on debug log you can see when it happened. Keygens: {}", KEYGENS); | ||
} | ||
if (!MACS.isEmpty()) { | ||
LOG.warn("Mac was already initialized with older config, those will not be updated." + |
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 don't think we need to store and log all the macs, I would be satisfied with logging if there is any in the current thread, acquired by:
threadLocalMac.get()
assuming that the update() happens on the same thread as the usage, this can be a useful logging message (without logging a whole MACS collection)
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
- delete SecretManagerConfig.java
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
I ended up deleting the SecretManagerConfig file and moved the relevant code into SecretManager. This ensures that only SecretManager has access to key generation and MAC creation, reducing the risk of other components using that logic unintentionally. Thank you for your previous reviews and suggestions—they were very helpful in improving this PR. When you have a moment, could you kindly take another look? Thanks again! |
thanks a lot @K0K0V0K for taking care of this, looks good to me! I know not everything you’ve had to do here has been the most exciting—it is what it is, especially as long as we’re dealing with static stuff around SecretManager let me defer the final decision to hadoop folks |
@K0K0V0K Thank you for your contribution, LGTM +1. We will wait for 1-2 days to see if there are any other comments. If not, we will merge this PR. |
@K0K0V0K Thanks for the contribution! Merged into trunk. @abstractdog @Hean-Chhinling Thanks for the review! |
Description of PR
HADOOP-19639
Static configuration of SecretManager is required because it contains static methods that use the selected algorithm.
If the classpath does not contain the configuration values (for example, when running TEZ DAGAppMaster), default values will be loaded at runtime.
These default values may cause failures in modern environments, as they are not FIPS-compliant.
A new SecretManagerConfig class has been created to allow modification of the SecretManager configuration without requiring core-site.xml on the classpath.
How was this patch tested?
For code changes:
LICENSE
,LICENSE-binary
,NOTICE-binary
files?