Skip to content

Commit

Permalink
check NO_MODEL_ERR_MSG instead of NO_CHECKPOINT_ERR_MSG
Browse files Browse the repository at this point in the history
Signed-off-by: Kaituo Li <kaituo@amazon.com>
  • Loading branch information
kaituo committed Feb 9, 2023
1 parent 98e3515 commit 6e0d2c4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public void indexAnomalyResultException(
anomalyResultHandler.index(anomalyResult, detectorId, resultIndex);
}

if (errorMessage.contains(CommonErrorMessages.NO_CHECKPOINT_ERR_MSG) && !detector.isMultiCategoryDetector()) {
if (errorMessage.contains(CommonErrorMessages.NO_MODEL_ERR_MSG) && !detector.isMultiCategoryDetector()) {
// single stream detector raises ResourceNotFoundException containing CommonErrorMessages.NO_CHECKPOINT_ERR_MSG
// when there is no checkpoint.
// Delay real time cache update by one minute so we will have trained models by then and update the state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,7 @@ public static String getTooManyCategoricalFieldErr(int limit) {
public static final String UNKNOWN_SEARCH_QUERY_EXCEPTION_MSG =
"Feature has an unknown exception caught while executing the feature query: ";
public static final String VALIDATION_FEATURE_FAILURE = "Validation failed for feature(s) of detector %s";
public static final String NO_MODEL_ERR_MSG = "No RCF models are available either because RCF"
+ " models are not ready or all nodes are unresponsive or the system might have bugs.";

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@
public class AnomalyResultTransportAction extends HandledTransportAction<ActionRequest, AnomalyResultResponse> {

private static final Logger LOG = LogManager.getLogger(AnomalyResultTransportAction.class);
static final String NO_MODEL_ERR_MSG = "No RCF models are available either because RCF"
+ " models are not ready or all nodes are unresponsive or the system might have bugs.";
static final String WAIT_FOR_THRESHOLD_ERR_MSG = "Exception in waiting for threshold result";
static final String NODE_UNRESPONSIVE_ERR_MSG = "Model node is unresponsive. Mute node";
static final String READ_WRITE_BLOCKED = "Cannot read/write due to global block.";
Expand Down Expand Up @@ -699,7 +697,7 @@ private Exception coldStartIfNoModel(AtomicReference<Exception> failure, Anomaly
}
LOG.info("Trigger cold start for {}", detector.getDetectorId());
coldStart(detector);
return previousException.orElse(new InternalFailure(adID, NO_MODEL_ERR_MSG));
return previousException.orElse(new InternalFailure(adID, CommonErrorMessages.NO_MODEL_ERR_MSG));
}

private void findException(Throwable cause, String adID, AtomicReference<Exception> failure, String nodeId) {
Expand Down Expand Up @@ -830,7 +828,7 @@ public void onResponse(RCFResultResponse response) {
);
} else {
LOG.warn(NULL_RESPONSE + " {} for {}", modelID, rcfNodeID);
listener.onFailure(new InternalFailure(adID, NO_MODEL_ERR_MSG));
listener.onFailure(new InternalFailure(adID, CommonErrorMessages.NO_MODEL_ERR_MSG));
}
} catch (Exception ex) {
LOG.error(new ParameterizedMessage("Unexpected exception for [{}]", adID), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.opensearch.ad.ExecuteADResultResponseRecorder;
import org.opensearch.ad.NodeStateManager;
import org.opensearch.ad.TestHelpers;
import org.opensearch.ad.common.exception.InternalFailure;
import org.opensearch.ad.common.exception.ResourceNotFoundException;
import org.opensearch.ad.constant.CommonErrorMessages;
import org.opensearch.ad.constant.CommonName;
Expand Down Expand Up @@ -341,7 +342,7 @@ public void testIndexException() throws IOException {
Object[] args = invocation.getArguments();
ActionListener<AnomalyResultResponse> listener = (ActionListener<AnomalyResultResponse>) args[2];

listener.onFailure(new ResourceNotFoundException(detectorId, CommonErrorMessages.NO_CHECKPOINT_ERR_MSG));
listener.onFailure(new InternalFailure(detectorId, CommonErrorMessages.NO_MODEL_ERR_MSG));

return null;
}).when(client).execute(any(AnomalyResultAction.class), any(), any());
Expand Down

0 comments on commit 6e0d2c4

Please sign in to comment.