From 828a69eed71938ffda27ebcf3b466f9b7387d41b Mon Sep 17 00:00:00 2001 From: tzwang Date: Thu, 19 Jun 2025 18:25:34 +0800 Subject: [PATCH] update octopusHttp service --- go.mod | 2 +- go.sum | 4 +- internal/storeLink/octopusHttp/octopusHttp.go | 40 ++++++++++++++++--- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 0086460b..292b5be4 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20250107025835-8fc888b1d170 gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4 gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 - gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250618090521-cb5d253198dd + gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250619094959-66dc370c4b6e gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 gitlink.org.cn/JointCloud/pcm-slurm v0.0.0-20240301080743-8b94bbaf57f5 diff --git a/go.sum b/go.sum index d13498ef..e9a3235f 100644 --- a/go.sum +++ b/go.sum @@ -539,8 +539,8 @@ gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4 h1:WIs/189l gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241125115811-72f3568255a4/go.mod h1:YbuoRgF9sEVvNJPQtGRjdocX7Du6NBOTLn+GVwqRVjo= gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6 h1:9o0ONbSiQHTzODptzgtVZjRYFBLncZ6dpHp9YF+v73I= gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20250313064001-91fb558cfdb6/go.mod h1:MxtnJJcU8S4zfGKZVcg2MOXGtwucKy7MMDwA0IemBd0= -gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250618090521-cb5d253198dd h1:eyroYJi7pQO5OewN9C45u7xUEjegH7qclxIS0dLOfYY= -gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250618090521-cb5d253198dd/go.mod h1:iQtyaoeMP4mNY0xutDBDD/305QwnPjj0zNtiQjXix50= +gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250619094959-66dc370c4b6e h1:KbgH65QhfOYIrkRz1eUmCa9nJZsmEMnu6Fk84nGoyYA= +gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20250619094959-66dc370c4b6e/go.mod h1:iQtyaoeMP4mNY0xutDBDD/305QwnPjj0zNtiQjXix50= gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee h1:+YYzcWPX0Up98nOb5ngkCaqiWHpSH7XJQRTUSvYclWU= gitlink.org.cn/JointCloud/pcm-openi v0.0.0-20250320103718-7bd6650118ee/go.mod h1:0VMTWXsRx7Z5z+kxBid2zf7kq5YtFlxubXEwPHiicyM= gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203 h1:s6PsZ1+bev294IWdZRlV7mnOwI1+UzFcldVW/BqhQzI= diff --git a/internal/storeLink/octopusHttp/octopusHttp.go b/internal/storeLink/octopusHttp/octopusHttp.go index 618b4c93..5f8657d3 100644 --- a/internal/storeLink/octopusHttp/octopusHttp.go +++ b/internal/storeLink/octopusHttp/octopusHttp.go @@ -614,6 +614,26 @@ func chooseResourceType(spec *omodel.Spec) (*collector.ClusterResource, error) { return nil, err } return cres, nil + } else if spec.ResourceQuantity.NvidiaV100 != "" { + tag, err := common2.GetJSONTag(spec.ResourceQuantity, "NvidiaV100") + if err != nil { + return nil, err + } + cres, err := genClusterResources(tag, spec.ResourceQuantity.NvidiaV100, spec) + if err != nil { + return nil, err + } + return cres, nil + } else if spec.ResourceQuantity.MetaxTechComGpu != "" { + tag, err := common2.GetJSONTag(spec.ResourceQuantity, "MetaxTechComGpu") + if err != nil { + return nil, err + } + cres, err := genClusterResources(tag, spec.ResourceQuantity.MetaxTechComGpu, spec) + if err != nil { + return nil, err + } + return cres, nil } return nil, nil @@ -625,6 +645,7 @@ func genClusterResources(cType string, cNum string, s *omodel.Spec) (*collector. var cardNum int64 var cpuCore int64 + var memGi int64 cardNum, err := strconv.ParseInt(cNum, 10, 64) if err != nil { @@ -634,13 +655,20 @@ func genClusterResources(cType string, cNum string, s *omodel.Spec) (*collector. if err != nil { cpuCore = 0 } - gi := strings.Split(s.ResourceQuantity.Memory, Gi) - if len(gi) != 2 { - return nil, fmt.Errorf("s.ResourceQuantity.Memory convert error: %s", s.ResourceQuantity.Memory) - } - memGi, err := strconv.ParseInt(gi[0], 10, 64) - if err != nil { + if s.ResourceQuantity.Memory != "" { + gi := strings.Split(s.ResourceQuantity.Memory, Gi) + if len(gi) != 2 { + return nil, fmt.Errorf("s.ResourceQuantity.Memory convert error: %s", s.ResourceQuantity.Memory) + } + + mGi, err := strconv.ParseInt(gi[0], 10, 64) + if err != nil { + memGi = 0 + } else { + memGi = mGi + } + } else { memGi = 0 }