瀏覽代碼

[ML] unmuting test for issue/53007 and adding logging (#53053)

Benjamin Trent 5 年之前
父節點
當前提交
373d180c19

+ 13 - 1
x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/RunDataFrameAnalyticsIT.java

@@ -14,6 +14,7 @@ import org.elasticsearch.action.get.GetResponse;
 import org.elasticsearch.action.index.IndexRequest;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.action.support.WriteRequest;
+import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.unit.ByteSizeUnit;
 import org.elasticsearch.common.unit.ByteSizeValue;
 import org.elasticsearch.common.xcontent.XContentType;
@@ -48,6 +49,12 @@ public class RunDataFrameAnalyticsIT extends MlNativeDataFrameAnalyticsIntegTest
     @After
     public void cleanup() {
         cleanUp();
+        client().admin().cluster()
+            .prepareUpdateSettings()
+            .setTransientSettings(Settings.builder()
+                .putNull("logger.org.elasticsearch.xpack.ml.action")
+                .putNull("logger.org.elasticsearch.xpack.ml.dataframe"))
+            .get();
     }
 
     public void testOutlierDetectionWithFewDocuments() throws Exception {
@@ -266,9 +273,14 @@ public class RunDataFrameAnalyticsIT extends MlNativeDataFrameAnalyticsIntegTest
             "Finished analysis");
     }
 
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/53007")
     public void testStopOutlierDetectionWithEnoughDocumentsToScroll() throws Exception {
         String sourceIndex = "test-stop-outlier-detection-with-enough-docs-to-scroll";
+        client().admin().cluster()
+            .prepareUpdateSettings()
+            .setTransientSettings(Settings.builder()
+                .put("logger.org.elasticsearch.xpack.ml.action", "DEBUG")
+                .put("logger.org.elasticsearch.xpack.ml.dataframe", "DEBUG"))
+            .get();
 
         client().admin().indices().prepareCreate(sourceIndex)
             .setMapping("numeric_1", "type=double", "numeric_2", "type=float", "categorical_1", "type=keyword")

+ 2 - 0
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDataFrameAnalyticsAction.java

@@ -163,6 +163,7 @@ public class TransportStartDataFrameAnalyticsAction
             new ActionListener<PersistentTasksCustomMetaData.PersistentTask<StartDataFrameAnalyticsAction.TaskParams>>() {
                 @Override
                 public void onResponse(PersistentTasksCustomMetaData.PersistentTask<StartDataFrameAnalyticsAction.TaskParams> task) {
+                    logger.debug("[{}] waiting for task to start", task.getParams().getId());
                     waitForAnalyticsStarted(task, request.getTimeout(), listener);
                 }
 
@@ -397,6 +398,7 @@ public class TransportStartDataFrameAnalyticsAction
                         // what would have happened if the error had been detected in the "fast fail" validation
                         cancelAnalyticsStart(task, predicate.exception, listener);
                     } else {
+                        logger.debug("[{}] task is now started", task.getParams().getId());
                         auditor.info(task.getParams().getId(), Messages.DATA_FRAME_ANALYTICS_AUDIT_STARTED);
                         listener.onResponse(new AcknowledgedResponse(true));
                     }

+ 2 - 0
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDataFrameAnalyticsAction.java

@@ -193,6 +193,7 @@ public class TransportStopDataFrameAnalyticsAction
                 // This means the task has not been assigned to a node yet so
                 // we can stop it by removing its persistent task.
                 // The listener is a no-op as we're already going to wait for the task to be removed.
+                logger.debug("[{}] sending remove request", task.getId());
                 persistentTasksService.sendRemoveRequest(task.getId(), ActionListener.wrap(r -> {}, e -> {}));
             }
         }
@@ -266,6 +267,7 @@ public class TransportStopDataFrameAnalyticsAction
                 filterPersistentTasks(persistentTasks, analyticsIds).isEmpty(),
             request.getTimeout(), ActionListener.wrap(
                 booleanResponse -> {
+                    logger.debug("[{}] analytics is stopped.", request.getId());
                     auditor.info(request.getId(), Messages.DATA_FRAME_ANALYTICS_AUDIT_STOPPED);
                     listener.onResponse(response);
                 },

+ 9 - 2
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java

@@ -105,17 +105,24 @@ public class DataFrameAnalyticsManager {
 
         // Retrieve configuration
         ActionListener<Boolean> statsIndexListener = ActionListener.wrap(
-            aBoolean -> configProvider.get(task.getParams().getId(), configListener),
+            aBoolean -> {
+                LOGGER.debug("[{}] created .ml-stats index", task.getParams().getId());
+                configProvider.get(task.getParams().getId(), configListener);
+            },
             configListener::onFailure
         );
 
         // Make sure the stats index and alias exist
         ActionListener<Boolean> stateAliasListener = ActionListener.wrap(
-            aBoolean -> createStatsIndexAndUpdateMappingsIfNecessary(clusterState, statsIndexListener),
+            aBoolean -> {
+                LOGGER.debug("[{}] created .ml-state index. Starting to create/update .ml-stats index", task.getParams().getId());
+                createStatsIndexAndUpdateMappingsIfNecessary(clusterState, statsIndexListener);
+            },
             configListener::onFailure
         );
 
         // Make sure the state index and alias exist
+        LOGGER.debug("[{}] Starting to create/update .ml-state index", task.getParams().getId());
         AnomalyDetectorsIndex.createStateIndexAndAliasIfNecessary(client, clusterState, expressionResolver, stateAliasListener);
     }
 

+ 2 - 0
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsTask.java

@@ -130,6 +130,7 @@ public class DataFrameAnalyticsTask extends AllocatedPersistentTask implements S
     }
 
     public void stop(String reason, TimeValue timeout) {
+        LOGGER.debug("[{}] stop called with reason [{}]", taskParams.getId(), reason);
         isStopping = true;
 
         ActionListener<Void> reindexProgressListener = ActionListener.wrap(
@@ -146,6 +147,7 @@ public class DataFrameAnalyticsTask extends AllocatedPersistentTask implements S
     }
 
     private void doStop(String reason, TimeValue timeout) {
+        LOGGER.debug("[{}] doStop called with reason [{}] and reindexTaskId [{}]", taskParams.getId(), reason, reindexingTaskId);
         if (reindexingTaskId != null) {
             cancelReindexingTask(reason, timeout);
         }