Skip to content

Commit

Permalink
Datanode migration: fix invalid hostname (#19894)
Browse files Browse the repository at this point in the history
* silently remove trailing slash from hostname (#19884)

* move check up further
  • Loading branch information
moesterheld authored Jul 17, 2024
1 parent 942827f commit bc34f7e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.graylog2.plugin.certificates.RenewalPolicy;
import org.graylog2.plugin.cluster.ClusterConfigService;
import org.graylog2.rest.resources.datanodes.DatanodeRestApiProxy;
import org.graylog2.shared.utilities.StringUtils;
import org.graylog2.storage.providers.ElasticsearchVersionProvider;
import org.graylog2.system.processing.control.ClusterProcessingControl;
import org.graylog2.system.processing.control.ClusterProcessingControlFactory;
Expand Down Expand Up @@ -256,7 +257,11 @@ public boolean dataNodeStartupFinished() {
@Override
public void startRemoteReindex() {
final String allowlist = getStateMachineContext().getActionArgumentOpt("allowlist", String.class).orElse(null);
final URI hostname = Objects.requireNonNull(URI.create(getStateMachineContext().getActionArgument("hostname", String.class)), "hostname has to be provided");
String host = StringUtils.requireNonBlank(getStateMachineContext().getActionArgument("hostname", String.class), "hostname has to be provided");
if (host.endsWith("/")) {
host = host.substring(0, host.length() - 1);
}
final URI hostname = URI.create(host);
final String user = getStateMachineContext().getActionArgumentOpt("user", String.class).orElse(null);
final String password = getStateMachineContext().getActionArgumentOpt("password", String.class).orElse(null);
final List<String> indices = getStateMachineContext().getActionArgumentOpt("indices", List.class).orElse(Collections.emptyList()); // todo: generics!
Expand Down

0 comments on commit bc34f7e

Please sign in to comment.