diff --git a/pkg/common/common.go b/pkg/common/common.go index e28a11824b769b4ab0a3988170f271df2234cef3..4fa344b7b222f2d24627c99decac883b6635f8c7 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 023cc006db734319f34bb634dd05bc954d48c75b..bd33fed3394f40cec5d0715e2339447b28798d80 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 2b1698e9354e79f39413442a9b67052697d33c4a..dc2e5148a64985108ea7631e67515022990af3d7 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 8f5ba3102c0292c8d011f3425471f8345abe069c..22b138748a93178321335cc7ef2f75e4d38c661b 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) }