Skip to content

Commit ee58e1b

Browse files
Working tests
1 parent 3fd0895 commit ee58e1b

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/CCMServiceIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ private void forceClusterUpdate() {
169169

170170
public void testDisableCCM_RemovesAuthorizationTask() throws Exception {
171171
disableCCM();
172-
waitForNoTask(AUTH_TASK_ACTION, admin());
173172
assertCCMDisabled();
173+
waitForNoTask(AUTH_TASK_ACTION, admin());
174174

175175
var listener = new TestPlainActionFuture<Void>();
176176
ccmService.get().storeConfiguration(new CCMModel(new SecureString("secret".toCharArray())), listener);
@@ -183,8 +183,8 @@ public void testDisableCCM_RemovesAuthorizationTask() throws Exception {
183183
waitForAuthorizationToComplete(authorizationTaskExecutor);
184184

185185
disableCCM();
186-
waitForNoTask(AUTH_TASK_ACTION, admin());
187186
assertCCMDisabled();
187+
waitForNoTask(AUTH_TASK_ACTION, admin());
188188
}
189189

190190
private void assertCCMDisabled() {

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ private CCMRelatedComponents createCCMDependentComponents(
462462
) {
463463
var ccmEnablementService = new CCMEnablementService(services.clusterService(), services.featureService(), ccmFeature);
464464
var ccmPersistentStorageService = new CCMPersistentStorageService(services.client());
465-
var ccmService = new CCMService(ccmPersistentStorageService, ccmEnablementService, services.projectResolver());
465+
var ccmService = new CCMService(ccmPersistentStorageService, ccmEnablementService, services.projectResolver(), services.client());
466466
var ccmAuthApplierFactory = new CCMAuthenticationApplierFactory(ccmFeature, ccmService);
467467

468468
var authorizationHandler = new ElasticInferenceServiceAuthorizationRequestHandler(

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ccm/CCMService.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void storeConfiguration(CCMModel model, ActionListener<Void> listener) {
5252
logger.debug("Successfully set CCM enabled in enablement service");
5353
enablementListener.onResponse(null);
5454
}, e -> {
55-
logger.atDebug().withThrowable(e).log("Failed to enable CCM in enablement service");
55+
logger.atWarn().withThrowable(e).log("Failed to enable CCM in enablement service");
5656
enablementListener.onFailure(e);
5757
}))
5858
)
@@ -64,8 +64,10 @@ public void storeConfiguration(CCMModel model, ActionListener<Void> listener) {
6464
logger.debug("Successfully enabled authorization task executor");
6565
enableAuthExecutorListener.onResponse(null);
6666
}, e -> {
67-
logger.atDebug().withThrowable(e).log("Failed to enable authorization task executor");
68-
enableAuthExecutorListener.onFailure(e);
67+
logger.atWarn().withThrowable(e).log("Failed to request start of authorization task");
68+
// even if requesting start of the authorization task fails, we still consider CCM enabled because
69+
// the cluster state listener will eventually start the task if it is missing
70+
enableAuthExecutorListener.onResponse(null);
6971
})
7072
)
7173
)
@@ -88,7 +90,7 @@ public void disableCCM(ActionListener<Void> listener) {
8890
logger.debug("Successfully set CCM disabled in enablement service");
8991
disableAuthExecutorListener.onResponse(null);
9092
}, e -> {
91-
logger.atDebug().withThrowable(e).log("Failed to disable CCM in enablement service");
93+
logger.atWarn().withThrowable(e).log("Failed to disable CCM in enablement service");
9294
disableAuthExecutorListener.onFailure(e);
9395
})
9496
)
@@ -102,8 +104,10 @@ public void disableCCM(ActionListener<Void> listener) {
102104
logger.debug("Successfully disabled authorization task executor");
103105
disableAuthExecutorListener.onResponse(null);
104106
}, e -> {
105-
logger.atDebug().withThrowable(e).log("Failed to disable authorization task executor");
106-
disableAuthExecutorListener.onFailure(e);
107+
logger.atWarn().withThrowable(e).log("Failed to request stop of authorization task");
108+
// even if stopping the authorization task fails, we still consider CCM disabled because the tasks themselves
109+
// should eventually stop after they check if ccm is enabled
110+
disableAuthExecutorListener.onResponse(null);
107111
})
108112
)
109113
)

0 commit comments

Comments
 (0)