From 7dd4b3524d4d49e80d5e4c24054fa101106a2ecf Mon Sep 17 00:00:00 2001 From: David Kyle Date: Thu, 12 Oct 2023 13:51:24 +0100 Subject: [PATCH] remove extras --- .../loadingservice/ModelLoadingService.java | 9 +++++---- .../ModelLoadingServiceTests.java | 20 ------------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/loadingservice/ModelLoadingService.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/loadingservice/ModelLoadingService.java index ba81e9bc74b4f..a82beaf936573 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/loadingservice/ModelLoadingService.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/loadingservice/ModelLoadingService.java @@ -750,13 +750,14 @@ private void cacheEvictionListener(RemovalNotification @Override public void clusterChanged(ClusterChangedEvent event) { - // If no changes to ingest pipelines and no model alias changes, nothing to do - if (event.changedCustomMetadataSet().contains(IngestMetadata.TYPE) == false - && event.changedCustomMetadataSet().contains(ModelAliasMetadata.NAME) == false) { + final boolean prefetchModels = event.state().nodes().getLocalNode().isIngestNode(); + // If we are not prefetching models and there were no model alias changes, don't bother handling the changes + if ((prefetchModels == false) + && (event.changedCustomMetadataSet().contains(IngestMetadata.TYPE) == false) + && (event.changedCustomMetadataSet().contains(ModelAliasMetadata.NAME) == false)) { return; } - final boolean prefetchModels = event.state().nodes().getLocalNode().isIngestNode(); ClusterState state = event.state(); IngestMetadata currentIngestMetadata = state.metadata().custom(IngestMetadata.TYPE); Set allReferencedModelKeys = event.changedCustomMetadataSet().contains(IngestMetadata.TYPE) diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/loadingservice/ModelLoadingServiceTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/loadingservice/ModelLoadingServiceTests.java index 8a494b094445c..2f4640cfa38dc 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/loadingservice/ModelLoadingServiceTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/loadingservice/ModelLoadingServiceTests.java @@ -656,26 +656,6 @@ public void testAliasesGetUpdatedEvenWhenNotIngestNode() throws IOException { assertThat(modelLoadingService.getModelId("loaded_model_again"), equalTo(model1)); } - public void testEarlyExitOnIrrelevantClusterChangeEvent() { - ModelLoadingService modelLoadingService = new ModelLoadingService( - trainedModelProvider, - auditor, - threadPool, - clusterService, - trainedModelStatsService, - Settings.EMPTY, - "test-node", - circuitBreaker, - mock(XPackLicenseState.class) - ); - - ClusterChangedEvent event = mock(ClusterChangedEvent.class); - when(event.changedCustomMetadataSet()).thenReturn(Set.of()); - modelLoadingService.clusterChanged(event); - - verify(event, never()).state(); - } - @SuppressWarnings("unchecked") private void withTrainedModel(String modelId, long size) { InferenceDefinition definition = mock(InferenceDefinition.class);