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 enterprise mode and refactor license check (#51864) #52115

Merged
merged 4 commits into from
Feb 21, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ private static ElasticsearchStatusException indexMetadataNonCompliantRemoteLicen
RemoteClusterLicenseChecker.buildErrorMessage(
"ccr",
licenseCheck.remoteClusterLicenseInfo(),
RemoteClusterLicenseChecker::isLicensePlatinumOrTrial));
RemoteClusterLicenseChecker::isAllowedByLicense));
return new ElasticsearchStatusException(message, RestStatus.BAD_REQUEST);
}

Expand All @@ -426,7 +426,7 @@ private static ElasticsearchStatusException clusterStateNonCompliantRemoteLicens
RemoteClusterLicenseChecker.buildErrorMessage(
"ccr",
licenseCheck.remoteClusterLicenseInfo(),
RemoteClusterLicenseChecker::isLicensePlatinumOrTrial));
RemoteClusterLicenseChecker::isAllowedByLicense));
return new ElasticsearchStatusException(message, RestStatus.BAD_REQUEST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ public enum OperationMode {
BASIC((byte) 2),
STANDARD((byte) 3),
GOLD((byte) 4),
PLATINUM((byte) 5);
PLATINUM((byte) 5),
ENTERPRISE((byte) 6);

private final byte id;

Expand Down Expand Up @@ -214,8 +215,9 @@ public static OperationMode resolve(LicenseType type) {
case GOLD:
return GOLD;
case PLATINUM:
case ENTERPRISE: // TODO Add an explicit enterprise operating mode
return PLATINUM;
case ENTERPRISE:
return ENTERPRISE;
case TRIAL:
return TRIAL;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ && isProductionMode(settings, clusterService.localNode())) {
"] license unless TLS is configured or security is disabled");
} else if (XPackSettings.FIPS_MODE_ENABLED.get(settings)
&& newLicense.operationMode() != License.OperationMode.PLATINUM
&& newLicense.operationMode() != License.OperationMode.ENTERPRISE
&& newLicense.operationMode() != License.OperationMode.TRIAL) {
throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() +
"] license unless FIPS mode is disabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ public RemoteClusterLicenseChecker(final Client client, final Predicate<License.
this.predicate = predicate;
}

public static boolean isLicensePlatinumOrTrial(final XPackInfoResponse.LicenseInfo licenseInfo) {
public static boolean isAllowedByLicense(final XPackInfoResponse.LicenseInfo licenseInfo) {
final License.OperationMode mode = License.OperationMode.parse(licenseInfo.getMode());
return mode == License.OperationMode.PLATINUM || mode == License.OperationMode.TRIAL;
return XPackLicenseState.isAllowedByOperationMode(mode, License.OperationMode.PLATINUM, true);
}

/**
Expand Down
Loading