Skip to content

Commit 4e003fe

Browse files
authored
Add messages for CCR on license state changes (elastic#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.
1 parent e06f2af commit 4e003fe

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ public class XPackLicenseState {
7979
messages.put(XPackField.ANALYTICS, new String[] {
8080
"Aggregations provided by Data Science plugin are no longer usable."
8181
});
82+
messages.put(XPackField.CCR, new String[]{
83+
"Creating new follower indices will be blocked",
84+
"Configuring auto-follow patterns will be blocked",
85+
"Auto-follow patterns will no longer discover new leader indices",
86+
"The CCR monitoring endpoint will be blocked",
87+
"Existing follower indices will continue to replicate data"
88+
});
8289
EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages);
8390
}
8491

@@ -97,6 +104,7 @@ public class XPackLicenseState {
97104
messages.put(XPackField.LOGSTASH, XPackLicenseState::logstashAcknowledgementMessages);
98105
messages.put(XPackField.BEATS, XPackLicenseState::beatsAcknowledgementMessages);
99106
messages.put(XPackField.SQL, XPackLicenseState::sqlAcknowledgementMessages);
107+
messages.put(XPackField.CCR, XPackLicenseState::ccrAcknowledgementMessages);
100108
ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages);
101109
}
102110

@@ -271,6 +279,27 @@ private static String[] sqlAcknowledgementMessages(OperationMode currentMode, Op
271279
return Strings.EMPTY_ARRAY;
272280
}
273281

282+
private static String[] ccrAcknowledgementMessages(final OperationMode current, final OperationMode next) {
283+
switch (current) {
284+
// the current license level permits CCR
285+
case TRIAL:
286+
case PLATINUM:
287+
case ENTERPRISE:
288+
switch (next) {
289+
// the next license level does not permit CCR
290+
case MISSING:
291+
case BASIC:
292+
case STANDARD:
293+
case GOLD:
294+
// so CCR will be disabled
295+
return new String[]{
296+
"Cross-Cluster Replication will be disabled"
297+
};
298+
}
299+
}
300+
return Strings.EMPTY_ARRAY;
301+
}
302+
274303
private static boolean isBasic(OperationMode mode) {
275304
return mode == OperationMode.BASIC;
276305
}

x-pack/plugin/core/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,75 @@ public void testSqlAckTrialOrPlatinumToNotTrialOrPlatinum() {
491491
assertAckMessages(XPackField.SQL, randomTrialOrPlatinumMode(), randomBasicStandardOrGold(), 1);
492492
}
493493

494+
public void testCcrDefaults() {
495+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
496+
assertTrue(state.isCcrAllowed());
497+
}
498+
499+
public void testCcrBasic() {
500+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
501+
state.update(BASIC, true, null);
502+
503+
assertThat(state.isCcrAllowed(), is(false));
504+
}
505+
506+
public void testCcrBasicExpired() {
507+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
508+
state.update(BASIC, false, null);
509+
510+
assertThat(state.isCcrAllowed(), is(false));
511+
}
512+
513+
public void testCcrStandard() {
514+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
515+
state.update(STANDARD, true, null);
516+
517+
assertThat(state.isCcrAllowed(), is(false));
518+
}
519+
520+
public void testCcrStandardExpired() {
521+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
522+
state.update(STANDARD, false, null);
523+
524+
assertThat(state.isCcrAllowed(), is(false));
525+
}
526+
527+
public void testCcrGold() {
528+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
529+
state.update(GOLD, true, null);
530+
531+
assertThat(state.isCcrAllowed(), is(false));
532+
}
533+
534+
public void testCcrGoldExpired() {
535+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
536+
state.update(GOLD, false, null);
537+
538+
assertThat(state.isCcrAllowed(), is(false));
539+
}
540+
541+
public void testCcrPlatinum() {
542+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
543+
state.update(PLATINUM, true, null);
544+
545+
assertTrue(state.isCcrAllowed());
546+
}
547+
548+
public void testCcrPlatinumExpired() {
549+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
550+
state.update(PLATINUM, false, null);
551+
552+
assertFalse(state.isCcrAllowed());
553+
}
554+
555+
public void testCcrAckAnyToTrialOrPlatinum() {
556+
assertAckMessages(XPackField.CCR, randomMode(), randomTrialOrPlatinumMode(), 0);
557+
}
558+
559+
public void testCcrAckTrialOrPlatinumToNotTrialOrPlatinum() {
560+
assertAckMessages(XPackField.CCR, randomTrialOrPlatinumMode(), randomBasicStandardOrGold(), 1);
561+
}
562+
494563
public void testTransformBasic() throws Exception {
495564
assertAllowed(BASIC, true, XPackLicenseState::isTransformAllowed, true);
496565
}

0 commit comments

Comments
 (0)