Skip to content

Remove ignore system bootstrap checks #20511

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

Merged
merged 2 commits into from
Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
67 changes: 2 additions & 65 deletions core/src/main/java/org/elasticsearch/bootstrap/BootstrapCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ private BootstrapCheck() {
static void check(final Settings settings, final BoundTransportAddress boundTransportAddress) throws NodeValidationException {
check(
enforceLimits(boundTransportAddress),
BootstrapSettings.IGNORE_SYSTEM_BOOTSTRAP_CHECKS.get(settings),
checks(settings),
Node.NODE_NAME_SETTING.get(settings));
}
Expand All @@ -77,18 +76,15 @@ static void check(final Settings settings, final BoundTransportAddress boundTran
*
* @param enforceLimits true if the checks should be enforced or
* otherwise warned
* @param ignoreSystemChecks true if system checks should be enforced
* or otherwise warned
* @param checks the checks to execute
* @param nodeName the node name to be used as a logging prefix
*/
// visible for testing
static void check(
final boolean enforceLimits,
final boolean ignoreSystemChecks,
final List<Check> checks,
final String nodeName) throws NodeValidationException {
check(enforceLimits, ignoreSystemChecks, checks, Loggers.getLogger(BootstrapCheck.class, nodeName));
check(enforceLimits, checks, Loggers.getLogger(BootstrapCheck.class, nodeName));
}

/**
Expand All @@ -97,14 +93,11 @@ static void check(
*
* @param enforceLimits true if the checks should be enforced or
* otherwise warned
* @param ignoreSystemChecks true if system checks should be enforced
* or otherwise warned
* @param checks the checks to execute
* @param logger the logger to
*/
static void check(
final boolean enforceLimits,
final boolean ignoreSystemChecks,
final List<Check> checks,
final Logger logger) throws NodeValidationException {
final List<String> errors = new ArrayList<>();
Expand All @@ -113,13 +106,10 @@ static void check(
if (enforceLimits) {
logger.info("bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks");
}
if (enforceLimits && ignoreSystemChecks) {
logger.warn("enforcing bootstrap checks but ignoring system bootstrap checks, consider not ignoring system checks");
}

for (final Check check : checks) {
if (check.check()) {
if ((!enforceLimits || (check.isSystemCheck() && ignoreSystemChecks)) && !check.alwaysEnforce()) {
if (!enforceLimits && !check.alwaysEnforce()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man == false reads so much easier :)

ignoredErrors.add(check.errorMessage());
} else {
errors.add(check.errorMessage());
Expand Down Expand Up @@ -201,14 +191,6 @@ interface Check {
*/
String errorMessage();

/**
* test if the check is a system-level check
*
* @return true if the check is a system-level check as opposed
* to an Elasticsearch-level check
*/
boolean isSystemCheck();

default boolean alwaysEnforce() {
return false;
}
Expand Down Expand Up @@ -245,11 +227,6 @@ long getMaxHeapSize() {
return JvmInfo.jvmInfo().getConfiguredMaxHeapSize();
}

@Override
public final boolean isSystemCheck() {
return false;
}

}

static class OsXFileDescriptorCheck extends FileDescriptorCheck {
Expand Down Expand Up @@ -299,11 +276,6 @@ long getMaxFileDescriptorCount() {
return ProcessProbe.getInstance().getMaxFileDescriptorCount();
}

@Override
public final boolean isSystemCheck() {
return true;
}

}

static class MlockallCheck implements Check {
Expand All @@ -329,11 +301,6 @@ boolean isMemoryLocked() {
return Natives.isMemoryLocked();
}

@Override
public final boolean isSystemCheck() {
return true;
}

}

static class MaxNumberOfThreadsCheck implements Check {
Expand All @@ -360,11 +327,6 @@ long getMaxNumberOfThreads() {
return JNANatives.MAX_NUMBER_OF_THREADS;
}

@Override
public final boolean isSystemCheck() {
return true;
}

}

static class MaxSizeVirtualMemoryCheck implements Check {
Expand Down Expand Up @@ -393,11 +355,6 @@ long getMaxSizeVirtualMemory() {
return JNANatives.MAX_SIZE_VIRTUAL_MEMORY;
}

@Override
public final boolean isSystemCheck() {
return true;
}

}

static class MaxMapCountCheck implements Check {
Expand Down Expand Up @@ -465,11 +422,6 @@ long parseProcSysVmMaxMapCount(final String procSysVmMaxMapCount) throws NumberF
return Long.parseLong(procSysVmMaxMapCount);
}

@Override
public final boolean isSystemCheck() {
return true;
}

}

static class ClientJvmCheck implements BootstrapCheck.Check {
Expand All @@ -492,11 +444,6 @@ public String errorMessage() {
getVmName());
}

@Override
public final boolean isSystemCheck() {
return false;
}

}

/**
Expand Down Expand Up @@ -524,11 +471,6 @@ public String errorMessage() {
JvmInfo.jvmInfo().getVmName());
}

@Override
public boolean isSystemCheck() {
return false;
}

}

abstract static class MightForkCheck implements BootstrapCheck.Check {
Expand All @@ -546,11 +488,6 @@ boolean isSeccompInstalled() {
// visible for testing
abstract boolean mightFork();

@Override
public final boolean isSystemCheck() {
return false;
}

@Override
public final boolean alwaysEnforce() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ private BootstrapSettings() {
Setting.boolSetting("bootstrap.seccomp", true, Property.NodeScope);
public static final Setting<Boolean> CTRLHANDLER_SETTING =
Setting.boolSetting("bootstrap.ctrlhandler", true, Property.NodeScope);
public static final Setting<Boolean> IGNORE_SYSTEM_BOOTSTRAP_CHECKS =
Setting.boolSetting("bootstrap.ignore_system_bootstrap_checks", false, Property.NodeScope);

}
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ public void apply(Settings value, Settings current, Settings previous) {
BootstrapSettings.MEMORY_LOCK_SETTING,
BootstrapSettings.SECCOMP_SETTING,
BootstrapSettings.CTRLHANDLER_SETTING,
BootstrapSettings.IGNORE_SYSTEM_BOOTSTRAP_CHECKS,
IndexingMemoryController.INDEX_BUFFER_SIZE_SETTING,
IndexingMemoryController.MIN_INDEX_BUFFER_SIZE_SETTING,
IndexingMemoryController.MAX_INDEX_BUFFER_SIZE_SETTING,
Expand Down
Loading