From cfbd3404d0117779ef0ea7b207aa76ca5ac8d4fe Mon Sep 17 00:00:00 2001 From: Light-Alex <245212467@qq.com> Date: Thu, 8 Aug 2024 20:30:54 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=20Modification=E3=80=91pod=20annotation=E4=B8=AD=E6=96=B0?= =?UTF-8?q?=E5=A2=9Esuper=20device=20id=E4=BF=A1=E6=81=AF=20=E3=80=90?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=BA=20Modifier=E3=80=91yanchuanxiang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/common/common.go | 10 ++++++---- pkg/common/proto.go | 9 +++++---- pkg/device/ascendcommon.go | 40 +++++++++++++++++++++++++------------- pkg/server/manager.go | 1 + 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/pkg/common/common.go b/pkg/common/common.go index e28a1182..4fa344b7 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -64,9 +64,10 @@ const ( // ServerInfo used for pass parameters type ServerInfo struct { - ServerID string - DeviceType string - SuperPodID int32 + ServerID string + DeviceType string + SuperPodID int32 + SuperDeviceId int32 } // GetPattern return pattern map @@ -493,7 +494,8 @@ func GetPodConfiguration(phyDevMapVirtualDev map[int]int, devices map[int]string sortDevicesKey = append(sortDevicesKey, deviceID) } sort.Ints(sortDevicesKey) - instance := Instance{PodName: podName, ServerID: info.ServerID, SuperPodId: info.SuperPodID} + instance := Instance{PodName: podName, ServerID: info.ServerID, SuperPodId: info.SuperPodID, + SuperDeviceId: info.SuperDeviceId} for _, deviceID := range sortDevicesKey { if !IsVirtualDev(info.DeviceType) { instance.Devices = append(instance.Devices, Device{ diff --git a/pkg/common/proto.go b/pkg/common/proto.go index 023cc006..bd33fed3 100644 --- a/pkg/common/proto.go +++ b/pkg/common/proto.go @@ -97,10 +97,11 @@ type Device struct { // Device // Instance is for annotation type Instance struct { // Instance - PodName string `json:"pod_name"` // pod Name - ServerID string `json:"server_id"` // serverdId - SuperPodId int32 `json:"super_pod_id"` - Devices []Device `json:"devices"` // dev + PodName string `json:"pod_name"` // pod Name + ServerID string `json:"server_id"` // serverdId + SuperPodId int32 `json:"super_pod_id"` + SuperDeviceId int32 `json:"super_device_id"` + Devices []Device `json:"devices"` // dev } // Option option diff --git a/pkg/device/ascendcommon.go b/pkg/device/ascendcommon.go index 2b1698e9..dc2e5148 100644 --- a/pkg/device/ascendcommon.go +++ b/pkg/device/ascendcommon.go @@ -58,16 +58,17 @@ const ( // AscendTools struct definition type AscendTools struct { - client *kubeclient.ClientK8s - dmgr devmanager.DeviceInterface - name string - deviceUsage string - unHealthyKey string - devCount int32 - healthDevice sets.String - boardId uint32 - superPodID int32 - serverIndex int32 + client *kubeclient.ClientK8s + dmgr devmanager.DeviceInterface + name string + deviceUsage string + unHealthyKey string + devCount int32 + healthDevice sets.String + boardId uint32 + superPodID int32 + superDeviceID int32 + serverIndex int32 // record map[device_logic_id]inresetting to show cardInResetMap map[int32]bool cardInResetLock sync.Mutex @@ -99,6 +100,8 @@ type DevManager interface { GetDeviceUsage() string SetSuperPodID(superPodID int32) GetSuperPodID() int32 + SetSuperDeviceID(superPodID int32) + GetSuperDeviceID() int32 SetServerIndex(serverIndex int32) GetServerIndex() int32 GetServerBoardId(devLogicID int32) (uint32, error) @@ -584,9 +587,10 @@ func (tool *AscendTools) AddPodAnnotation(pod *v1.Pod, kltRequestDevices, dpResp return fmt.Errorf("get ascend devices ip failed, err: %v", err) } info := common.ServerInfo{ - ServerID: serverID, - DeviceType: deviceType, - SuperPodID: tool.GetSuperPodID(), + ServerID: serverID, + DeviceType: deviceType, + SuperPodID: tool.GetSuperPodID(), + SuperDeviceId: tool.GetSuperDeviceID(), } configuration := common.GetPodConfiguration(phyDevMapVirtualDev, ascendVisibleDevices, pod.Name, info) if !common.ParamOption.PresetVDevice { @@ -1136,6 +1140,16 @@ func (tool *AscendTools) GetSuperPodID() int32 { return tool.superPodID } +// SetSuperDeviceID set super device id +func (tool *AscendTools) SetSuperDeviceID(superDeviceID int32) { + tool.superDeviceID = superDeviceID +} + +// GetSuperDeviceID get super device id +func (tool *AscendTools) GetSuperDeviceID() int32 { + return tool.superDeviceID +} + // SetServerIndex setting the index from server func (tool *AscendTools) SetServerIndex(serverIndex int32) { tool.serverIndex = serverIndex diff --git a/pkg/server/manager.go b/pkg/server/manager.go index 8f5ba310..22b13874 100644 --- a/pkg/server/manager.go +++ b/pkg/server/manager.go @@ -250,6 +250,7 @@ func (hdm *HwDevManager) setSuperPodInfo() { superPodInfo := hdm.getSuperPodInfo() hwlog.RunLog.Infof("get super pod id: %d, server index: %d", superPodInfo.SuperPodId, superPodInfo.ServerId) hdm.manager.SetSuperPodID(superPodInfo.SuperPodId) + hdm.manager.SetSuperDeviceID(superPodInfo.SdId) hdm.manager.SetServerIndex(superPodInfo.ServerId) } -- Gitee