From 2e1ed36c0ab20eb67e331c95b853404fdc5eb0eb Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 29 Nov 2024 02:18:14 +1100 Subject: [PATCH] [8.16] [ML] Trained Models: Show deployment stats for unallocated deployments (#202005) (#202166) # Backport This will backport the following commits from `main` to `8.16`: - [[ML] Trained Models: Show deployment stats for unallocated deployments (#202005)](https://github.com/elastic/kibana/pull/202005) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Dima Arnautov --- .../plugins/ml/common/types/trained_models.ts | 1 + .../nodes_overview/allocated_models.tsx | 8 +++-- .../model_management/expanded_row.tsx | 33 ++++++++++++++++--- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/ml/common/types/trained_models.ts b/x-pack/plugins/ml/common/types/trained_models.ts index 794d3123eee7f..f4ed52ff21f52 100644 --- a/x-pack/plugins/ml/common/types/trained_models.ts +++ b/x-pack/plugins/ml/common/types/trained_models.ts @@ -193,6 +193,7 @@ export interface AllocatedModel { */ model_id?: string; state: string; + reason?: string; model_size_bytes: number; required_native_memory_bytes: number; node: { diff --git a/x-pack/plugins/ml/public/application/memory_usage/nodes_overview/allocated_models.tsx b/x-pack/plugins/ml/public/application/memory_usage/nodes_overview/allocated_models.tsx index 4dd04780e2e92..cc9beceff5556 100644 --- a/x-pack/plugins/ml/public/application/memory_usage/nodes_overview/allocated_models.tsx +++ b/x-pack/plugins/ml/public/application/memory_usage/nodes_overview/allocated_models.tsx @@ -57,15 +57,17 @@ export const AllocatedModels: FC = ({ { width: '8%', name: i18n.translate('xpack.ml.trainedModels.nodesList.modelsList.modelRoutingStateHeader', { - defaultMessage: 'Routing state', + defaultMessage: 'State', }), 'data-test-subj': 'mlAllocatedModelsTableRoutingState', render: (v: AllocatedModel) => { const { routing_state: routingState, reason } = v.node.routing_state; + const isFailed = routingState === 'failed'; + return ( - {routingState} + {routingState} ); }, @@ -252,7 +254,7 @@ export const AllocatedModels: FC = ({ }), 'data-test-subj': 'mlAllocatedModelsTableStartedTime', render: (v: AllocatedModel) => { - return dateFormatter(v.node.start_time); + return v.node.start_time ? dateFormatter(v.node.start_time) : '-'; }, }, { diff --git a/x-pack/plugins/ml/public/application/model_management/expanded_row.tsx b/x-pack/plugins/ml/public/application/model_management/expanded_row.tsx index e9db6b4e4f590..eaec5776c3b81 100644 --- a/x-pack/plugins/ml/public/application/model_management/expanded_row.tsx +++ b/x-pack/plugins/ml/public/application/model_management/expanded_row.tsx @@ -169,13 +169,40 @@ export const ExpandedRow: FC = ({ item }) => { license_level, ]); - const deploymentStatItems: AllocatedModel[] = useMemo(() => { + const deploymentStatItems = useMemo(() => { const deploymentStats = stats.deployment_stats; const modelSizeStats = stats.model_size_stats; if (!deploymentStats || !modelSizeStats) return []; - const items: AllocatedModel[] = deploymentStats.flatMap((perDeploymentStat) => { + return deploymentStats.flatMap((perDeploymentStat) => { + // A deployment can be in a starting state and not allocated to any node yet. + if (perDeploymentStat.nodes.length < 1) { + return [ + { + key: `${perDeploymentStat.deployment_id}_no_node`, + ...perDeploymentStat, + ...modelSizeStats, + node: { + name: '-', + average_inference_time_ms: 0, + inference_count: 0, + routing_state: { + routing_state: perDeploymentStat.state, + reason: perDeploymentStat.reason, + }, + last_access: 0, + number_of_pending_requests: 0, + start_time: 0, + throughput_last_minute: 0, + number_of_allocations: 0, + threads_per_allocation: 0, + error_count: 0, + }, + }, + ]; + } + return perDeploymentStat.nodes.map((n) => { const nodeName = Object.values(n.node)[0].name; return { @@ -200,8 +227,6 @@ export const ExpandedRow: FC = ({ item }) => { }; }); }); - - return items; }, [stats]); const hideColumns = useMemo(() => {