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 #51864

Merged
merged 12 commits into from
Feb 9, 2020
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::isAllowedByLicenseInfo));
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::isAllowedByLicenseInfo));
return new ElasticsearchStatusException(message, RestStatus.BAD_REQUEST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,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 @@ -208,8 +209,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 @@ -256,6 +256,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
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer that we change this to either be < PLATINUM, or use methods on XPackLicenseState so that we don't have a bunch of code that assumes the set of licenses and their ordering.

&& 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 isAllowedByLicenseInfo(final XPackInfoResponse.LicenseInfo licenseInfo) {
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
public static boolean isAllowedByLicenseInfo(final XPackInfoResponse.LicenseInfo licenseInfo) {
public static boolean isAllowedByLicense(final XPackInfoResponse.LicenseInfo licenseInfo) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

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