From 1685cbe504f58c07409560b7b9476e07964d2801 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sat, 22 Feb 2020 09:09:04 -0500 Subject: [PATCH] Add messages for CCR on license state changes (#52470) When a license expires, or license state changes, functionality might be disabled. This commit adds messages for CCR to inform users that CCR functionality will be disabled when a license expires, or when license state changes to a license level lower than trial/platinum/enterprise. --- .../license/XPackLicenseState.java | 29 ++++++++ .../license/XPackLicenseStateTests.java | 69 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java index a9a7a0fa309..f76e73f7390 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -77,6 +77,13 @@ public class XPackLicenseState { messages.put(XPackField.ANALYTICS, new String[] { "Aggregations provided by Analytics plugin are no longer usable." }); + messages.put(XPackField.CCR, new String[]{ + "Creating new follower indices will be blocked", + "Configuring auto-follow patterns will be blocked", + "Auto-follow patterns will no longer discover new leader indices", + "The CCR monitoring endpoint will be blocked", + "Existing follower indices will continue to replicate data" + }); EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages); } @@ -95,6 +102,7 @@ public class XPackLicenseState { messages.put(XPackField.LOGSTASH, XPackLicenseState::logstashAcknowledgementMessages); messages.put(XPackField.BEATS, XPackLicenseState::beatsAcknowledgementMessages); messages.put(XPackField.SQL, XPackLicenseState::sqlAcknowledgementMessages); + messages.put(XPackField.CCR, XPackLicenseState::ccrAcknowledgementMessages); ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages); } @@ -269,6 +277,27 @@ public class XPackLicenseState { return Strings.EMPTY_ARRAY; } + private static String[] ccrAcknowledgementMessages(final OperationMode current, final OperationMode next) { + switch (current) { + // the current license level permits CCR + case TRIAL: + case PLATINUM: + case ENTERPRISE: + switch (next) { + // the next license level does not permit CCR + case MISSING: + case BASIC: + case STANDARD: + case GOLD: + // so CCR will be disabled + return new String[]{ + "Cross-Cluster Replication will be disabled" + }; + } + } + return Strings.EMPTY_ARRAY; + } + private static boolean isBasic(OperationMode mode) { return mode == OperationMode.BASIC; } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java index 7cb8e3f137a..51633291041 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java @@ -491,6 +491,75 @@ public class XPackLicenseStateTests extends ESTestCase { assertAckMessages(XPackField.SQL, randomTrialOrPlatinumMode(), randomBasicStandardOrGold(), 1); } + public void testCcrDefaults() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + assertTrue(state.isCcrAllowed()); + } + + public void testCcrBasic() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + state.update(BASIC, true, null); + + assertThat(state.isCcrAllowed(), is(false)); + } + + public void testCcrBasicExpired() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + state.update(BASIC, false, null); + + assertThat(state.isCcrAllowed(), is(false)); + } + + public void testCcrStandard() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + state.update(STANDARD, true, null); + + assertThat(state.isCcrAllowed(), is(false)); + } + + public void testCcrStandardExpired() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + state.update(STANDARD, false, null); + + assertThat(state.isCcrAllowed(), is(false)); + } + + public void testCcrGold() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + state.update(GOLD, true, null); + + assertThat(state.isCcrAllowed(), is(false)); + } + + public void testCcrGoldExpired() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + state.update(GOLD, false, null); + + assertThat(state.isCcrAllowed(), is(false)); + } + + public void testCcrPlatinum() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + state.update(PLATINUM, true, null); + + assertTrue(state.isCcrAllowed()); + } + + public void testCcrPlatinumExpired() { + final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY); + state.update(PLATINUM, false, null); + + assertFalse(state.isCcrAllowed()); + } + + public void testCcrAckAnyToTrialOrPlatinum() { + assertAckMessages(XPackField.CCR, randomMode(), randomTrialOrPlatinumMode(), 0); + } + + public void testCcrAckTrialOrPlatinumToNotTrialOrPlatinum() { + assertAckMessages(XPackField.CCR, randomTrialOrPlatinumMode(), randomBasicStandardOrGold(), 1); + } + public void testTransformBasic() throws Exception { assertAllowed(BASIC, true, XPackLicenseState::isTransformAllowed, true); }