From 889654f284a74f96b886983fe70bca3192f51094 Mon Sep 17 00:00:00 2001 From: Robert Lucian Chiriac Date: Wed, 5 May 2021 00:44:01 +0300 Subject: [PATCH 1/3] Fix number of API replicas shown in cluster info --- pkg/operator/endpoints/info.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/operator/endpoints/info.go b/pkg/operator/endpoints/info.go index ee61b4aaf1..a6a6cc71cb 100644 --- a/pkg/operator/endpoints/info.go +++ b/pkg/operator/endpoints/info.go @@ -109,6 +109,7 @@ func getNodeInfos() ([]schema.NodeInfo, int, error) { pod := pods[i] _, isAPIPod := pod.Labels["apiName"] + asyncDeploymentType, isAsyncPod := pod.Labels["cortex.dev/async"] if pod.Spec.NodeName == "" && isAPIPod { numPendingReplicas++ @@ -120,7 +121,7 @@ func getNodeInfos() ([]schema.NodeInfo, int, error) { continue } - if isAPIPod { + if isAPIPod && (!isAsyncPod || asyncDeploymentType != "gateway") { node.NumReplicas++ } From 875bae783893873bbcb9c8bbba7879890ec54f2e Mon Sep 17 00:00:00 2001 From: Robert Lucian Chiriac Date: Mon, 10 May 2021 15:36:07 +0300 Subject: [PATCH 2/3] Add "num async gateway replicas" column --- cli/cmd/cluster.go | 8 ++++++-- pkg/operator/endpoints/info.go | 9 +++++++-- pkg/operator/schema/schema.go | 19 ++++++++++--------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/cli/cmd/cluster.go b/cli/cmd/cluster.go index 9ce4ea5b4d..4165a13016 100644 --- a/cli/cmd/cluster.go +++ b/cli/cmd/cluster.go @@ -887,7 +887,7 @@ func printInfoNodes(infoResponse *schema.InfoResponse) { numAPIInstances := len(infoResponse.NodeInfos) var totalReplicas int - var doesClusterHaveGPUs, doesClusterHaveInfs bool + var doesClusterHaveGPUs, doesClusterHaveInfs, doesClusterHaveAsyncAPIs bool for _, nodeInfo := range infoResponse.NodeInfos { totalReplicas += nodeInfo.NumReplicas if nodeInfo.ComputeUserCapacity.GPU > 0 { @@ -896,6 +896,9 @@ func printInfoNodes(infoResponse *schema.InfoResponse) { if nodeInfo.ComputeUserCapacity.Inf > 0 { doesClusterHaveInfs = true } + if nodeInfo.NumAsyncGatewayReplicas > 0 { + doesClusterHaveAsyncAPIs = true + } } var pendingReplicasStr string @@ -913,6 +916,7 @@ func printInfoNodes(infoResponse *schema.InfoResponse) { {Title: "instance type"}, {Title: "lifecycle"}, {Title: "replicas"}, + {Title: "async gateway replicas", Hidden: doesClusterHaveAsyncAPIs}, {Title: "CPU (requested / total allocatable)"}, {Title: "memory (requested / total allocatable)"}, {Title: "GPU (requested / total allocatable)", Hidden: !doesClusterHaveGPUs}, @@ -930,7 +934,7 @@ func printInfoNodes(infoResponse *schema.InfoResponse) { memStr := nodeInfo.ComputeUserRequested.Mem.String() + " / " + nodeInfo.ComputeUserCapacity.Mem.String() gpuStr := s.Int64(nodeInfo.ComputeUserRequested.GPU) + " / " + s.Int64(nodeInfo.ComputeUserCapacity.GPU) infStr := s.Int64(nodeInfo.ComputeUserRequested.Inf) + " / " + s.Int64(nodeInfo.ComputeUserCapacity.Inf) - rows = append(rows, []interface{}{nodeInfo.InstanceType, lifecycle, nodeInfo.NumReplicas, cpuStr, memStr, gpuStr, infStr}) + rows = append(rows, []interface{}{nodeInfo.InstanceType, lifecycle, nodeInfo.NumReplicas, nodeInfo.NumAsyncGatewayReplicas, cpuStr, memStr, gpuStr, infStr}) } t := table.Table{ diff --git a/pkg/operator/endpoints/info.go b/pkg/operator/endpoints/info.go index 0b4bdf7e4f..0b723e8f1f 100644 --- a/pkg/operator/endpoints/info.go +++ b/pkg/operator/endpoints/info.go @@ -118,8 +118,13 @@ func getNodeInfos() ([]schema.NodeInfo, int, error) { continue } - if isAPIPod && (!isAsyncPod || asyncDeploymentType != "gateway") { - node.NumReplicas++ + if isAPIPod { + if !isAsyncPod || asyncDeploymentType == "api" { + node.NumReplicas++ + } + if !isAsyncPod || asyncDeploymentType == "gateway" { + node.NumAsyncGatewayReplicas++ + } } cpu, mem, gpu, inf := k8s.TotalPodCompute(&pod.Spec) diff --git a/pkg/operator/schema/schema.go b/pkg/operator/schema/schema.go index f820f6710b..9486e1f225 100644 --- a/pkg/operator/schema/schema.go +++ b/pkg/operator/schema/schema.go @@ -31,15 +31,16 @@ type InfoResponse struct { } type NodeInfo struct { - Name string `json:"name"` - NodeGroupName string `json:"nodegroup_name"` - InstanceType string `json:"instance_type"` - IsSpot bool `json:"is_spot"` - Price float64 `json:"price"` - NumReplicas int `json:"num_replicas"` - ComputeUserCapacity userconfig.Compute `json:"compute_user_capacity"` // the total resources available to the user on a node - ComputeAvailable userconfig.Compute `json:"compute_available"` // unused resources on a node - ComputeUserRequested userconfig.Compute `json:"compute_user_requested"` // total resources requested by user on a node + Name string `json:"name"` + NodeGroupName string `json:"nodegroup_name"` + InstanceType string `json:"instance_type"` + IsSpot bool `json:"is_spot"` + Price float64 `json:"price"` + NumReplicas int `json:"num_replicas"` + NumAsyncGatewayReplicas int `json:"num_async_gateway_replicas"` + ComputeUserCapacity userconfig.Compute `json:"compute_user_capacity"` // the total resources available to the user on a node + ComputeAvailable userconfig.Compute `json:"compute_available"` // unused resources on a node + ComputeUserRequested userconfig.Compute `json:"compute_user_requested"` // total resources requested by user on a node } type DeployResult struct { From d17a20a8841739ec56b7ef55be017f961e9e9872 Mon Sep 17 00:00:00 2001 From: Robert Lucian Chiriac Date: Mon, 10 May 2021 15:56:09 +0300 Subject: [PATCH 3/3] Fix logic --- cli/cmd/cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cmd/cluster.go b/cli/cmd/cluster.go index 4165a13016..133ae81de8 100644 --- a/cli/cmd/cluster.go +++ b/cli/cmd/cluster.go @@ -916,7 +916,7 @@ func printInfoNodes(infoResponse *schema.InfoResponse) { {Title: "instance type"}, {Title: "lifecycle"}, {Title: "replicas"}, - {Title: "async gateway replicas", Hidden: doesClusterHaveAsyncAPIs}, + {Title: "async gateway replicas", Hidden: !doesClusterHaveAsyncAPIs}, {Title: "CPU (requested / total allocatable)"}, {Title: "memory (requested / total allocatable)"}, {Title: "GPU (requested / total allocatable)", Hidden: !doesClusterHaveGPUs},