-
Notifications
You must be signed in to change notification settings - Fork 25k
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
[TEST] Reload secure settings transport IT #31180
[TEST] Reload secure settings transport IT #31180
Conversation
Pinging @elastic/es-core-infra |
@@ -102,6 +104,8 @@ protected NodeRequest newNodeRequest(String nodeId, NodesReloadSecureSettingsReq | |||
try { | |||
p.reload(settingsWithKeystore); | |||
} catch (final Exception e) { | |||
logger.warn((Supplier<?>) () -> new ParameterizedMessage("Plugin [{}] threw [{}] on node [{}]", | |||
p.getClass().getSimpleName(), e.getClass().getSimpleName(), clusterService.localNode().getName()), e); |
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.
1/2 non test change
assert password.length == 0; | ||
if (password.length != 0) { | ||
throw new IllegalArgumentException("Keystore format does not accept non-empty passwords"); | ||
} |
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.
2/2 non test change
This password is no longer internal API, there are code paths where the user supplies its value.
@@ -102,6 +104,8 @@ protected NodeRequest newNodeRequest(String nodeId, NodesReloadSecureSettingsReq | |||
try { | |||
p.reload(settingsWithKeystore); | |||
} catch (final Exception e) { | |||
logger.warn((Supplier<?>) () -> new ParameterizedMessage("Plugin [{}] threw [{}] during reload", |
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.
1/2 non test change
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 the class name in the message since we also log the exception
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 left some comments. Regarding not being able to write a keystore in tests, maybe someone from @elastic/es-core-infra could provide some thoughts about whether there is a better way than checking the files in as a resource.
@@ -102,6 +104,8 @@ protected NodeRequest newNodeRequest(String nodeId, NodesReloadSecureSettingsReq | |||
try { | |||
p.reload(settingsWithKeystore); | |||
} catch (final Exception e) { | |||
logger.warn((Supplier<?>) () -> new ParameterizedMessage("Plugin [{}] threw [{}] during reload", |
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 the class name in the message since we also log the exception
|
||
@Override | ||
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
return Arrays.asList(MockReloadablePlugin.class, MisbehavingReloadablePlugin.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.
should we randomize the order? Sometimes the misbehaving goes first?
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.
Yes! I was under the impression that the order here is not relevant when iterating oveer Plugin instances. But it is, and this is a good thing!
|
||
@Override | ||
public List<Setting<?>> getSettings() { | ||
return Arrays.asList(DUMMY_SECRET_SETTING); |
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.
Collections.singletonList
|
||
public static class MisbehavingReloadablePlugin extends CountingReloadablePlugin { | ||
|
||
private volatile boolean sulky = false; |
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.
can we rename this to shouldThrow
? Then just have a setter for the method? Also, let's make this non-volatile and the methods synchronized since we technically do a CAS in reload
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.
Yes, I've been lax here.
Thank you @jaymode . |
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 pending discussion with the core-infra team regarding the updating of the keystore during the test
@jaymode The matter did not piqued any interest. Please take another short look, thanks! |
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.
Left one comment. Otherwise LGTM as long as CI is happy.
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
final List<Class<? extends Plugin>> plugins = Arrays.asList(MockReloadablePlugin.class, MisbehavingReloadablePlugin.class); | ||
// shuffle as reload is called in order | ||
Collections.shuffle(plugins); |
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.
you need to use Collections.shuffle(plugins, random())
to fix the build failure
Appreciate the prompt review! Thank you, I will make sure CI runs several times before merging the feature branch! |
Adds Integration Tests for the
TransportNodesReloadSecureSettingsAction
. Specifically, it tests:reload
calls)throw
during a plugin reload on any node will not interrupt thereload
flow in any way - it will just return the exception in the response)Previously there were tests only for the individual plugins implementing the reload handler, no tests for the "broadcast password - decrypt keystore - notify plugins - close keystore" logic.
One obstacle I struggled with was generating keystores programatically. They are test resources in the present implementation. The problem is that saving a generated keystores requires the Java SM permissions to change file permissions. This is not granted for the server codebase. In the real world the keystore is generated before the Security Manager is installed.
Relates: #29135
CC @elastic/es-security