Skip to content

Commit f3cbeea

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 3d64edc commit f3cbeea

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ public class XPackLicenseState {
7373
"Creating and Starting rollup jobs will no longer be allowed.",
7474
"Stopping/Deleting existing jobs, RollupCaps API and RollupSearch continue to function."
7575
});
76+
messages.put(XPackField.CCR, new String[]{
77+
"Creating new follower indices will be blocked",
78+
"Configuring auto-follow patterns will be blocked",
79+
"Auto-follow patterns will no longer discover new leader indices",
80+
"The CCR monitoring endpoint will be blocked",
81+
"Existing follower indices will continue to replicate data"
82+
});
7683
EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages);
7784
}
7885

@@ -91,6 +98,7 @@ public class XPackLicenseState {
9198
messages.put(XPackField.LOGSTASH, XPackLicenseState::logstashAcknowledgementMessages);
9299
messages.put(XPackField.BEATS, XPackLicenseState::beatsAcknowledgementMessages);
93100
messages.put(XPackField.SQL, XPackLicenseState::sqlAcknowledgementMessages);
101+
messages.put(XPackField.CCR, XPackLicenseState::ccrAcknowledgementMessages);
94102
ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages);
95103
}
96104

@@ -257,6 +265,26 @@ private static String[] sqlAcknowledgementMessages(OperationMode currentMode, Op
257265
return Strings.EMPTY_ARRAY;
258266
}
259267

268+
private static String[] ccrAcknowledgementMessages(final OperationMode current, final OperationMode next) {
269+
switch (current) {
270+
// the current license level permits CCR
271+
case TRIAL:
272+
case PLATINUM:
273+
switch (next) {
274+
// the next license level does not permit CCR
275+
case MISSING:
276+
case BASIC:
277+
case STANDARD:
278+
case GOLD:
279+
// so CCR will be disabled
280+
return new String[]{
281+
"Cross-Cluster Replication will be disabled"
282+
};
283+
}
284+
}
285+
return Strings.EMPTY_ARRAY;
286+
}
287+
260288
private static boolean isBasic(OperationMode mode) {
261289
return mode == OperationMode.BASIC;
262290
}

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
@@ -504,4 +504,73 @@ public void testSqlAckTrialOrPlatinumToNotTrialOrPlatinum() {
504504
assertAckMesssages(XPackField.SQL, randomTrialOrPlatinumMode(), randomBasicStandardOrGold(), 1);
505505
}
506506

507+
public void testCcrDefaults() {
508+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
509+
assertTrue(state.isCcrAllowed());
510+
}
511+
512+
public void testCcrBasic() {
513+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
514+
state.update(BASIC, true, null);
515+
516+
assertThat(state.isCcrAllowed(), is(false));
517+
}
518+
519+
public void testCcrBasicExpired() {
520+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
521+
state.update(BASIC, false, null);
522+
523+
assertThat(state.isCcrAllowed(), is(false));
524+
}
525+
526+
public void testCcrStandard() {
527+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
528+
state.update(STANDARD, true, null);
529+
530+
assertThat(state.isCcrAllowed(), is(false));
531+
}
532+
533+
public void testCcrStandardExpired() {
534+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
535+
state.update(STANDARD, false, null);
536+
537+
assertThat(state.isCcrAllowed(), is(false));
538+
}
539+
540+
public void testCcrGold() {
541+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
542+
state.update(GOLD, true, null);
543+
544+
assertThat(state.isCcrAllowed(), is(false));
545+
}
546+
547+
public void testCcrGoldExpired() {
548+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
549+
state.update(GOLD, false, null);
550+
551+
assertThat(state.isCcrAllowed(), is(false));
552+
}
553+
554+
public void testCcrPlatinum() {
555+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
556+
state.update(PLATINUM, true, null);
557+
558+
assertTrue(state.isCcrAllowed());
559+
}
560+
561+
public void testCcrPlatinumExpired() {
562+
final XPackLicenseState state = new XPackLicenseState(Settings.EMPTY);
563+
state.update(PLATINUM, false, null);
564+
565+
assertFalse(state.isCcrAllowed());
566+
}
567+
568+
public void testCcrAckAnyToTrialOrPlatinum() {
569+
assertAckMesssages(XPackField.CCR, randomMode(), randomTrialOrPlatinumMode(), 0);
570+
}
571+
572+
public void testCcrAckTrialOrPlatinumToNotTrialOrPlatinum() {
573+
assertAckMesssages(XPackField.CCR, randomTrialOrPlatinumMode(), randomBasicStandardOrGold(), 1);
574+
}
575+
507576
}

0 commit comments

Comments
 (0)