Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
n1v0lg committed Dec 8, 2023
1 parent 6e747f3 commit 6b89b7c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,10 @@ private void copyExtraConfigFiles() {
});
}

public void writeToKeystoreFile() {
public void updateStoredSecureSettings() {
if (usesSecureSecretsFile) {
throw new UnsupportedOperationException("updating stored secure settings is not supported in serverless test clusters");
}
final Path keystoreFile = workingDir.resolve("config").resolve("elasticsearch.keystore");
try {
Files.deleteIfExists(keystoreFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public InputStream getNodeLog(int index, LogType logType) {
}

@Override
public void writeToKeystoreFile() {
execute(() -> nodes.parallelStream().forEach(Node::writeToKeystoreFile));
public void updateStoredSecureSettings() {
execute(() -> nodes.parallelStream().forEach(Node::updateStoredSecureSettings));
}

protected void waitUntilReady() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ public InputStream getNodeLog(int index, LogType logType) {
}

@Override
public void writeToKeystoreFile() {
public void updateStoredSecureSettings() {
checkHandle();
handle.writeToKeystoreFile();
handle.updateStoredSecureSettings();
}

protected H getHandle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.elasticsearch.test.cluster.ClusterHandle;
import org.elasticsearch.test.cluster.LogType;
import org.elasticsearch.test.cluster.MutableSettingsProvider;
import org.elasticsearch.test.cluster.util.Version;

import java.io.InputStream;
Expand Down Expand Up @@ -95,7 +96,11 @@ public interface LocalClusterHandle extends ClusterHandle {
InputStream getNodeLog(int index, LogType logType);

/**
* Writes current keystore settings to keystore file on each node.
* Writes secure settings to the relevant secure config file on each node. Use this method if you are dynamically updating secure
* settings via a {@link MutableSettingsProvider} and need the update to be written to file, without a cluster restart.
*
* @throws UnsupportedOperationException if secure settings are stored in a secrets file, i.e., in serverless. Only keystore-based
* storage is currently supported
*/
void writeToKeystoreFile();
void updateStoredSecureSettings();
}
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ private void writeSettingToKeystoreThenReload(String setting, @Nullable String v
} else {
keystoreSettings.put(setting, value);
}
cluster.writeToKeystoreFile();
cluster.updateStoredSecureSettings();
assertOK(adminClient().performRequest(new Request("POST", "/_nodes/reload_secure_settings")));
}

Expand Down

0 comments on commit 6b89b7c

Please sign in to comment.