Skip to content

Commit b02b01c

Browse files
committed
Add licence ack messages for Inference
1 parent d5c84af commit b02b01c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class XPackLicenseState {
8585
"Existing follower indices will continue to replicate data" }
8686
);
8787
messages.put(XPackField.REDACT_PROCESSOR, new String[] { "Executing a redact processor in an ingest pipeline will fail." });
88+
messages.put(XPackField.INFERENCE, new String[] { "The Inference API is disabled" });
8889
EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages);
8990
}
9091

@@ -107,6 +108,7 @@ public class XPackLicenseState {
107108
messages.put(XPackField.ENTERPRISE_SEARCH, XPackLicenseState::enterpriseSearchAcknowledgementMessages);
108109
messages.put(XPackField.REDACT_PROCESSOR, XPackLicenseState::redactProcessorAcknowledgementMessages);
109110
messages.put(XPackField.ESQL, XPackLicenseState::esqlAcknowledgementMessages);
111+
messages.put(XPackField.INFERENCE, XPackLicenseState::inferenceApiAcknowledgementMessages);
110112
ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages);
111113
}
112114

@@ -264,6 +266,26 @@ private static String[] esqlAcknowledgementMessages(OperationMode currentMode, O
264266
return Strings.EMPTY_ARRAY;
265267
}
266268

269+
private static String[] inferenceApiAcknowledgementMessages(OperationMode currentMode, OperationMode newMode) {
270+
/*
271+
* Provide an acknowledgement warning to customers that downgrade from Trial or Enterprise to a lower
272+
* license level (Basic, Standard, Gold or Premium) that they will no longer be able to use the Inference API
273+
*/
274+
switch (newMode) {
275+
case TRIAL:
276+
case ENTERPRISE:
277+
break;
278+
default:
279+
switch (currentMode) {
280+
case TRIAL:
281+
case ENTERPRISE:
282+
return new String[] { "The Inference API will be disabled" };
283+
}
284+
break;
285+
}
286+
return Strings.EMPTY_ARRAY;
287+
}
288+
267289
private static String[] machineLearningAcknowledgementMessages(OperationMode currentMode, OperationMode newMode) {
268290
switch (newMode) {
269291
case BASIC:

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.elasticsearch.xpack.core.XPackField;
1414

1515
import java.util.Arrays;
16+
import java.util.EnumSet;
1617
import java.util.List;
1718
import java.util.Map;
1819
import java.util.Set;
@@ -160,6 +161,31 @@ public void testEsqlAckTrialOrEnterpriseToNotTrialOrEnterprise() {
160161
}
161162
}
162163

164+
public void testInferenceAckMessageTrialOrEnterpriseToNotTrialOrEnterprise() {
165+
var notTrialOrEnterprise = EnumSet.allOf(License.OperationMode.class);
166+
notTrialOrEnterprise.remove(TRIAL);
167+
notTrialOrEnterprise.remove(ENTERPRISE);
168+
for (OperationMode to : notTrialOrEnterprise) {
169+
assertAckMessages(XPackField.INFERENCE, randomFrom(TRIAL, ENTERPRISE), to, Set.of("The Inference API will be disabled"));
170+
}
171+
}
172+
173+
public void testInferenceAckMessageToTrialOrEnterprise() {
174+
var fromAll = EnumSet.allOf(License.OperationMode.class);
175+
for (OperationMode from : fromAll) {
176+
assertAckMessages(XPackField.ESQL, from, randomFrom(TRIAL, ENTERPRISE), 0);
177+
}
178+
}
179+
180+
public void testInferenceAckMessageUnlicensedToUnlicensed() {
181+
var notTrialOrEnterprise = EnumSet.allOf(License.OperationMode.class);
182+
notTrialOrEnterprise.remove(TRIAL);
183+
notTrialOrEnterprise.remove(ENTERPRISE);
184+
for (OperationMode to : notTrialOrEnterprise) {
185+
assertAckMessages(XPackField.INFERENCE, randomFrom(notTrialOrEnterprise), to, 0);
186+
}
187+
}
188+
163189
public void testExpiredLicense() {
164190
// use standard feature which would normally be allowed at all license levels
165191
LicensedFeature feature = LicensedFeature.momentary("family", "enterpriseFeature", STANDARD);

0 commit comments

Comments
 (0)