Skip to content
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

Add a docs link to the log message about each failing bootstrap check #99644

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/99644.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 99644
summary: Add links to docs from failing bootstrap checks
area: Infra/Node Lifecycle
type: enhancement
issues: [99614]

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.bootstrap;

import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.ReferenceDocs;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.node.NodeValidationException;
import org.elasticsearch.test.AbstractBootstrapCheckTestCase;
Expand Down Expand Up @@ -49,7 +50,17 @@ public void tearDown() throws Exception {

public void testEnforceBootstrapChecks() throws NodeValidationException {
setEsEnforceBootstrapChecks("true");
final List<BootstrapCheck> checks = Collections.singletonList(context -> BootstrapCheck.BootstrapCheckResult.failure("error"));
final List<BootstrapCheck> checks = Collections.singletonList(new BootstrapCheck() {
@Override
public BootstrapCheckResult check(BootstrapContext context) {
return BootstrapCheck.BootstrapCheckResult.failure("error");
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECKS;
}
});

final Logger logger = mock(Logger.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package org.elasticsearch.bootstrap;

import org.elasticsearch.common.ReferenceDocs;

import java.util.Objects;

/**
Expand Down Expand Up @@ -59,4 +61,6 @@ default boolean alwaysEnforce() {
return false;
}

ReferenceDocs referenceDocs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.Constants;
import org.elasticsearch.cluster.coordination.ClusterBootstrapService;
import org.elasticsearch.common.ReferenceDocs;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.transport.BoundTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
Expand Down Expand Up @@ -131,10 +132,11 @@ static void check(final BootstrapContext context, final boolean enforceLimits, f
for (final BootstrapCheck check : checks) {
final BootstrapCheck.BootstrapCheckResult result = check.check(context);
if (result.isFailure()) {
final String message = result.getMessage() + "; for more information see [" + check.referenceDocs() + "]";
if (enforceLimits == false && enforceBootstrapChecks == false && check.alwaysEnforce() == false) {
ignoredErrors.add(result.getMessage());
ignoredErrors.add(message);
} else {
errors.add(result.getMessage());
errors.add(message);
}
}
}
Expand All @@ -150,7 +152,9 @@ static void check(final BootstrapContext context, final boolean enforceLimits, f
+ errors.size()
+ "] bootstrap checks failed. You must address the points described in the following ["
+ errors.size()
+ "] lines before starting Elasticsearch."
+ "] lines before starting Elasticsearch. For more information see ["
+ ReferenceDocs.BOOTSTRAP_CHECKS
+ "]"
);
for (int i = 0; i < errors.size(); i++) {
messages.add("bootstrap check failure [" + (i + 1) + "] of [" + errors.size() + "]: " + errors.get(i));
Expand Down Expand Up @@ -240,6 +244,11 @@ public BootstrapCheckResult check(BootstrapContext context) {
}
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_HEAP_SIZE;
}

// visible for testing
long getInitialHeapSize() {
return JvmInfo.jvmInfo().getConfiguredInitialHeapSize();
Expand Down Expand Up @@ -298,6 +307,11 @@ public final BootstrapCheckResult check(BootstrapContext context) {
}
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_FILE_DESCRIPTOR;
}

// visible for testing
long getMaxFileDescriptorCount() {
return ProcessProbe.getMaxFileDescriptorCount();
Expand All @@ -321,6 +335,11 @@ boolean isMemoryLocked() {
return Natives.isMemoryLocked();
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_MEMORY_LOCK;
}

}

static class MaxNumberOfThreadsCheck implements BootstrapCheck {
Expand Down Expand Up @@ -349,6 +368,10 @@ long getMaxNumberOfThreads() {
return JNANatives.MAX_NUMBER_OF_THREADS;
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_MAX_NUMBER_THREADS;
}
}

static class MaxSizeVirtualMemoryCheck implements BootstrapCheck {
Expand Down Expand Up @@ -378,6 +401,10 @@ long getMaxSizeVirtualMemory() {
return JNANatives.MAX_SIZE_VIRTUAL_MEMORY;
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_MAX_SIZE_VIRTUAL_MEMORY;
}
}

/**
Expand Down Expand Up @@ -409,6 +436,10 @@ long getMaxFileSize() {
return JNANatives.MAX_FILE_SIZE;
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_MAX_FILE_SIZE;
}
}

static class MaxMapCountCheck implements BootstrapCheck {
Expand Down Expand Up @@ -478,6 +509,10 @@ static long parseProcSysVmMaxMapCount(final String procSysVmMaxMapCount) throws
return Long.parseLong(procSysVmMaxMapCount);
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_MAXIMUM_MAP_COUNT;
}
}

static class ClientJvmCheck implements BootstrapCheck {
Expand All @@ -501,6 +536,10 @@ String getVmName() {
return JvmInfo.jvmInfo().getVmName();
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_CLIENT_JVM;
}
}

/**
Expand Down Expand Up @@ -529,6 +568,10 @@ String getUseSerialGC() {
return JvmInfo.jvmInfo().useSerialGC();
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_USE_SERIAL_COLLECTOR;
}
}

/**
Expand All @@ -551,6 +594,10 @@ boolean isSystemCallFilterInstalled() {
return Natives.isSystemCallFilterInstalled();
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_SYSTEM_CALL_FILTER;
}
}

abstract static class MightForkCheck implements BootstrapCheck {
Expand Down Expand Up @@ -579,6 +626,11 @@ public final boolean alwaysEnforce() {
return true;
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_ONERROR_AND_ONOUTOFMEMORYERROR;
}

}

static class OnErrorCheck extends MightForkCheck {
Expand Down Expand Up @@ -658,6 +710,11 @@ String javaVersion() {
return Constants.JAVA_VERSION;
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_EARLY_ACCESS;
}

}

static class AllPermissionCheck implements BootstrapCheck {
Expand All @@ -681,6 +738,10 @@ boolean isAllPermissionGranted() {
return true;
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_ALL_PERMISSION;
}
}

static class DiscoveryConfiguredCheck implements BootstrapCheck {
Expand All @@ -703,6 +764,11 @@ public BootstrapCheckResult check(BootstrapContext context) {
)
);
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECK_DISCOVERY_CONFIGURATION;
}
}

static class ByteOrderCheck implements BootstrapCheck {
Expand All @@ -718,5 +784,10 @@ public BootstrapCheckResult check(BootstrapContext context) {
ByteOrder nativeByteOrder() {
return ByteOrder.nativeOrder();
}

@Override
public ReferenceDocs referenceDocs() {
return ReferenceDocs.BOOTSTRAP_CHECKS;
}
}
}
22 changes: 22 additions & 0 deletions server/src/main/java/org/elasticsearch/common/ReferenceDocs.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ public enum ReferenceDocs {
CONCURRENT_REPOSITORY_WRITERS,
ARCHIVE_INDICES,
HTTP_TRACER,
BOOTSTRAP_CHECK_HEAP_SIZE,
BOOTSTRAP_CHECK_FILE_DESCRIPTOR,
BOOTSTRAP_CHECK_MEMORY_LOCK,
BOOTSTRAP_CHECK_MAX_NUMBER_THREADS,
BOOTSTRAP_CHECK_MAX_FILE_SIZE,
BOOTSTRAP_CHECK_MAX_SIZE_VIRTUAL_MEMORY,
BOOTSTRAP_CHECK_MAXIMUM_MAP_COUNT,
BOOTSTRAP_CHECK_CLIENT_JVM,
BOOTSTRAP_CHECK_USE_SERIAL_COLLECTOR,
BOOTSTRAP_CHECK_SYSTEM_CALL_FILTER,
BOOTSTRAP_CHECK_ONERROR_AND_ONOUTOFMEMORYERROR,
BOOTSTRAP_CHECK_EARLY_ACCESS,
BOOTSTRAP_CHECK_G1GC,
BOOTSTRAP_CHECK_ALL_PERMISSION,
BOOTSTRAP_CHECK_DISCOVERY_CONFIGURATION,
BOOTSTRAP_CHECKS,
BOOTSTRAP_CHECK_ENCRYPT_SENSITIVE_DATA,
BOOTSTRAP_CHECK_PKI_REALM,
BOOTSTRAP_CHECK_ROLE_MAPPINGS,
BOOTSTRAP_CHECK_TLS,
BOOTSTRAP_CHECK_TOKEN_SSL,
BOOTSTRAP_CHECK_SECURITY_MINIMAL_SETUP,
// this comment keeps the ';' on the next line so every entry above has a trailing ',' which makes the diff for adding new links cleaner
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,27 @@
"SHARD_LOCK_TROUBLESHOOTING": "troubleshooting-unstable-cluster.html#_diagnosing_shardlockobtainfailedexception_failures_2",
"CONCURRENT_REPOSITORY_WRITERS": "add-repository.html",
"ARCHIVE_INDICES": "archive-indices.html",
"HTTP_TRACER": "modules-network.html#http-rest-request-tracer"
"HTTP_TRACER": "modules-network.html#http-rest-request-tracer",
"BOOTSTRAP_CHECK_HEAP_SIZE": "_heap_size_check.html",
"BOOTSTRAP_CHECK_FILE_DESCRIPTOR": "_file_descriptor_check.html",
"BOOTSTRAP_CHECK_MEMORY_LOCK": "_memory_lock_check.html",
"BOOTSTRAP_CHECK_MAX_NUMBER_THREADS": "max-number-threads-check.html",
"BOOTSTRAP_CHECK_MAX_FILE_SIZE": "_max_file_size_check.html",
"BOOTSTRAP_CHECK_MAX_SIZE_VIRTUAL_MEMORY": "max-size-virtual-memory-check.html",
"BOOTSTRAP_CHECK_MAXIMUM_MAP_COUNT": "_maximum_map_count_check.html",
"BOOTSTRAP_CHECK_CLIENT_JVM": "_client_jvm_check.html",
"BOOTSTRAP_CHECK_USE_SERIAL_COLLECTOR": "_use_serial_collector_check.html",
"BOOTSTRAP_CHECK_SYSTEM_CALL_FILTER": "_system_call_filter_check.html",
"BOOTSTRAP_CHECK_ONERROR_AND_ONOUTOFMEMORYERROR": "_onerror_and_onoutofmemoryerror_checks.html",
"BOOTSTRAP_CHECK_EARLY_ACCESS": "_early_access_check.html",
"BOOTSTRAP_CHECK_G1GC": "_g1gc_check.html",
"BOOTSTRAP_CHECK_ALL_PERMISSION": "_all_permission_check.html",
"BOOTSTRAP_CHECK_DISCOVERY_CONFIGURATION": "_discovery_configuration_check.html",
"BOOTSTRAP_CHECKS": "bootstrap-checks.html",
"BOOTSTRAP_CHECK_ENCRYPT_SENSITIVE_DATA": "bootstrap-checks-xpack.html#_encrypt_sensitive_data_check",
"BOOTSTRAP_CHECK_PKI_REALM": "bootstrap-checks-xpack.html#_pki_realm_check",
"BOOTSTRAP_CHECK_ROLE_MAPPINGS": "bootstrap-checks-xpack.html#_role_mappings_check",
"BOOTSTRAP_CHECK_TLS": "bootstrap-checks-xpack.html#bootstrap-checks-tls",
"BOOTSTRAP_CHECK_TOKEN_SSL": "bootstrap-checks-xpack.html#_token_ssl_check",
"BOOTSTRAP_CHECK_SECURITY_MINIMAL_SETUP": "security-minimal-setup.html"
}
Loading