@@ -1233,14 +1233,14 @@ public synchronized void undeployController(String modelId, ActionListener<Strin
1233
1233
} else if (isModelRunningOnNode (modelId )) {
1234
1234
log
1235
1235
.error (
1236
- "Failed to undeploy model controller due to model is in ML cache but with a state other than deployed. Please check model: "
1236
+ "Failed to undeploy model controller because model is in ML cache but with a state other than deployed. Please check model: "
1237
1237
+ modelId ,
1238
1238
new RuntimeException ()
1239
1239
);
1240
1240
listener
1241
1241
.onFailure (
1242
1242
new RuntimeException (
1243
- "Failed to undeploy model controller due to model is in ML cache but with a state other than deployed. Please check model: "
1243
+ "Failed to undeploy model controller because model is in ML cache but with a state other than deployed. Please check model: "
1244
1244
+ modelId
1245
1245
)
1246
1246
);
@@ -1276,25 +1276,47 @@ private synchronized void deployControllerWithDeployingModel(
1276
1276
log .error ("Failed to parse ml task" + r .getId (), e );
1277
1277
listener .onFailure (e );
1278
1278
}
1279
- } else if (mlModel . getIsControllerEnabled () == null || ! mlModel .getIsControllerEnabled ()) {
1279
+ } else if (! BooleanUtils . isTrue ( mlModel .getIsControllerEnabled () )) {
1280
1280
// Not going to respond the failure here due to the model deploy can still work
1281
1281
// well
1282
1282
listener
1283
1283
.onResponse (
1284
- "The model "
1284
+ "No controller is deployed because the model "
1285
1285
+ modelId
1286
- + " is expected not having a model controller. Please use the create model controller api to create one if this is unexpected."
1286
+ + " is expected not having an enabled model controller. Please use the create controller api to create one if this is unexpected."
1287
1287
);
1288
1288
log
1289
- .warn (
1290
- "The model "
1291
- + modelId
1292
- + " is expected not having a model controller. Please use the create model controller api to create one if this is unexpected."
1289
+ .debug (
1290
+ "No controller is deployed because the model " + modelId + " is expected not having an enabled model controller."
1293
1291
);
1294
1292
} else {
1295
1293
listener .onFailure (new OpenSearchStatusException ("Failed to find model controller" , RestStatus .NOT_FOUND ));
1296
1294
}
1297
- }, listener ::onFailure ));
1295
+ }, e -> {
1296
+ if (e instanceof IndexNotFoundException ) {
1297
+ if (!BooleanUtils .isTrue (mlModel .getIsControllerEnabled ())) {
1298
+ // Not going to respond the failure here due to the model deploy can still work
1299
+ // well
1300
+ listener
1301
+ .onResponse (
1302
+ "No controller is deployed because the model "
1303
+ + modelId
1304
+ + " is expected not having an enabled model controller. Please use the create model controller api to create one if this is unexpected."
1305
+ );
1306
+ log
1307
+ .debug (
1308
+ "No controller is deployed because the model "
1309
+ + modelId
1310
+ + " is expected not having an enabled model controller."
1311
+ );
1312
+ } else {
1313
+ listener .onFailure (new OpenSearchStatusException ("Failed to find model controller" , RestStatus .NOT_FOUND ));
1314
+ }
1315
+ } else {
1316
+ log .error ("Failed to re-deploy the model controller for model: " + modelId , e );
1317
+ listener .onFailure (e );
1318
+ }
1319
+ }));
1298
1320
}
1299
1321
1300
1322
/**
@@ -1315,10 +1337,13 @@ public void deployControllerWithDeployingModel(MLModel mlModel, Integer eligible
1315
1337
deployControllerWithDeployingModel (mlModel , eligibleNodeCount , ActionListener .wrap (response -> {
1316
1338
if (response .startsWith ("Successfully" )) {
1317
1339
log .debug (response , mlModel .getModelId ());
1318
- } else if (response .startsWith ("Failed" )) {
1319
- log .error (response );
1340
+ } else if (response
1341
+ .endsWith (
1342
+ "is expected not having a model controller. Please use the create model controller api to create one if this is unexpected."
1343
+ )) {
1344
+ log .warn (response );
1320
1345
} else {
1321
- log .info (response );
1346
+ log .error (response );
1322
1347
}
1323
1348
}, e -> log .error ("Failed to re-deploy the model controller for model: " + mlModel .getModelId (), e )));
1324
1349
}
@@ -1364,7 +1389,13 @@ private TokenBucket createTokenBucket(Integer eligibleNodeCount, MLRateLimiter r
1364
1389
limit / unit .toSeconds (1 ),
1365
1390
eligibleNodeCount
1366
1391
);
1367
- return new TokenBucket (System ::nanoTime , limit / unit .toNanos (1 ) / eligibleNodeCount , limit , limit / eligibleNodeCount );
1392
+ // Burst token must be greater than 1 to accept request
1393
+ return new TokenBucket (
1394
+ System ::nanoTime ,
1395
+ limit / unit .toNanos (1 ) / eligibleNodeCount ,
1396
+ Math .max (limit / eligibleNodeCount , 1 ),
1397
+ Math .max (limit / eligibleNodeCount , 1 )
1398
+ );
1368
1399
}
1369
1400
return null ;
1370
1401
}
0 commit comments