add banner for initial datanode start, promoting preflight interface (#17008)

This commit is contained in:
Tomas Dvorak
2023-10-20 14:44:17 +02:00
committed by GitHub
parent 5e86e92bb0
commit 42aa1c36ed
2 changed files with 17 additions and 12 deletions

View File

@@ -111,18 +111,20 @@ public class JerseyService extends AbstractIdleService {
@Subscribe
public synchronized void handleOpensearchConfigurationChange(OpensearchConfigurationChangeEvent event) throws Exception {
LOG.info("Opensearch config changed, restarting jersey service to apply security changes");
if(apiHttpServer == null) {
// this is the very first start of the jersey service
LOG.info("Starting Data node REST API");
} else {
// jersey service has been running for some time, now we received new configuration. We'll reboot the service
LOG.info("Server configuration changed, restarting Data node REST API to apply security changes");
}
shutDown();
doStartup(extractSslConfiguration(event.config()));
}
/**
* TODO: replace this map magic with proper types in OpensearchConfiguration
*/
private SSLEngineConfigurator extractSslConfiguration(OpensearchConfiguration config) throws GeneralSecurityException, IOException {
final OpensearchSecurityConfiguration securityConfiguration = config.opensearchSecurityConfiguration();
if (securityConfiguration != null && securityConfiguration.securityEnabled()) {
// caution, this path is relative to the opensearch config directory!
return buildSslEngineConfigurator(securityConfiguration.getHttpCertificate());
} else {
return null;

View File

@@ -40,10 +40,7 @@ public class OpensearchProcessService extends AbstractIdleService implements Pro
private static final int WATCHDOG_RESTART_ATTEMPTS = 3;
private final OpensearchProcess process;
private final Provider<OpensearchConfiguration> configurationProvider;
private final CustomCAX509TrustManager trustManager;
private final EventBus eventBus;
private final NodeService nodeService;
private final Configuration configuration;
@Inject
public OpensearchProcessService(final DatanodeConfiguration datanodeConfiguration,
@@ -53,9 +50,6 @@ public class OpensearchProcessService extends AbstractIdleService implements Pro
final NodeService nodeService,
final Configuration configuration) {
this.configurationProvider = configurationProvider;
this.trustManager = trustManager;
this.nodeService = nodeService;
this.configuration = configuration;
this.eventBus = eventBus;
this.process = createOpensearchProcess(datanodeConfiguration, trustManager, configuration, nodeService);
eventBus.register(this);
@@ -86,7 +80,16 @@ public class OpensearchProcessService extends AbstractIdleService implements Pro
if (config.securityConfigured()) {
this.process.startWithConfig(config);
} else {
LOG.warn("Opensearch process not started. Please provide proper security configuration, using certificate provisioning in the pre-flight mode, by manual certificate creation or by disabling security in the config.");
String noConfigMessage = """
\n
========================================================================================================
It seems you are starting Data node for the first time. The current configuration is not sufficient to
start the indexer process because a security configuration is missing. You have to either provide http
and transport SSL certificates or use the Graylog preflight interface to configure this Data node remotely.
========================================================================================================
""";
LOG.info(noConfigMessage);
}
eventBus.post(new OpensearchConfigurationChangeEvent(config));
}