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

[7.x] Convert encrypted snapshot license object to LicensedFeature (#78731) #78863

Merged
merged 1 commit into from
Oct 7, 2021
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 @@ -52,8 +52,6 @@ public enum Feature {
MONITORING_CLUSTER_ALERTS(OperationMode.STANDARD, true),
MONITORING_UPDATE_RETENTION(OperationMode.STANDARD, false),

ENCRYPTED_SNAPSHOT(OperationMode.PLATINUM, true),

CCR(OperationMode.PLATINUM, true),

MACHINE_LEARNING(OperationMode.PLATINUM, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

import static org.elasticsearch.repositories.encrypted.EncryptedRepositoryPlugin.ENCRYPTED_SNAPSHOT_FEATURE;

public class EncryptedRepository extends BlobStoreRepository {
static final Logger logger = LogManager.getLogger(EncryptedRepository.class);
// the following constants are fixed by definition
Expand Down Expand Up @@ -176,7 +178,7 @@ public RepositoryStats stats() {
public Map<String, Object> adaptUserMetadata(Map<String, Object> userMetadata) {
// because populating the snapshot metadata must be done before the actual snapshot is first initialized,
// we take the opportunity to validate the license and abort if non-compliant
if (false == licenseStateSupplier.get().isAllowed(XPackLicenseState.Feature.ENCRYPTED_SNAPSHOT)) {
if (false == ENCRYPTED_SNAPSHOT_FEATURE.checkWithoutTracking(licenseStateSupplier.get())) {
throw LicenseUtils.newComplianceException("encrypted snapshots");
}
Map<String, Object> snapshotUserMetadata = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.env.Environment;
import org.elasticsearch.indices.recovery.RecoverySettings;
import org.elasticsearch.license.License;
import org.elasticsearch.license.LicenseUtils;
import org.elasticsearch.license.LicensedFeature;
import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.RepositoryPlugin;
Expand All @@ -40,6 +42,12 @@

public class EncryptedRepositoryPlugin extends Plugin implements RepositoryPlugin {

static final LicensedFeature.Momentary ENCRYPTED_SNAPSHOT_FEATURE = LicensedFeature.momentary(
null,
"encrypted-snapshot",
License.OperationMode.PLATINUM
);

private static final Boolean ENCRYPTED_REPOSITORY_FEATURE_FLAG_REGISTERED;
static {
final String property = System.getProperty("es.encrypted_repository_feature_flag_registered");
Expand Down Expand Up @@ -155,7 +163,7 @@ public Repository create(RepositoryMetadata metadata, Function<String, Repositor
if (false == (delegatedRepository instanceof BlobStoreRepository) || delegatedRepository instanceof EncryptedRepository) {
throw new IllegalArgumentException("Unsupported delegate repository type [" + DELEGATE_TYPE_SETTING.getKey() + "]");
}
if (false == getLicenseState().checkFeature(XPackLicenseState.Feature.ENCRYPTED_SNAPSHOT)) {
if (false == ENCRYPTED_SNAPSHOT_FEATURE.check(getLicenseState())) {
logger.warn(
new ParameterizedMessage(
"Encrypted snapshots are not allowed for the currently installed license [{}]."
Expand Down