Skip to content

Commit 1685cbe

Browse files
committed
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.
1 parent afd9064 commit 1685cbe

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
@@ -77,6 +77,13 @@ public class XPackLicenseState {
7777
messages.put(XPackField.ANALYTICS, new String[] {
7878
"Aggregations provided by Analytics plugin are no longer usable."
7979
});
80+
messages.put(XPackField.CCR, new String[]{
81+
"Creating new follower indices will be blocked",
82+
"Configuring auto-follow patterns will be blocked",
83+
"Auto-follow patterns will no longer discover new leader indices",
84+
"The CCR monitoring endpoint will be blocked",
85+
"Existing follower indices will continue to replicate data"
86+
});
8087
EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages);
8188
}
8289

@@ -95,6 +102,7 @@ public class XPackLicenseState {
95102
messages.put(XPackField.LOGSTASH, XPackLicenseState::logstashAcknowledgementMessages);
96103
messages.put(XPackField.BEATS, XPackLicenseState::beatsAcknowledgementMessages);
97104
messages.put(XPackField.SQL, XPackLicenseState::sqlAcknowledgementMessages);
105+
messages.put(XPackField.CCR, XPackLicenseState::ccrAcknowledgementMessages);
98106
ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages);
99107
}
100108

@@ -269,6 +277,27 @@ private static String[] sqlAcknowledgementMessages(OperationMode currentMode, Op
269277
return Strings.EMPTY_ARRAY;
270278
}
271279

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

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)