From d00992b57ca37d07fe46d4cb4d4bbb60f2685230 Mon Sep 17 00:00:00 2001 From: chengjunhua Date: Wed, 4 Sep 2024 11:13:30 +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=91=20=E4=BF=AE=E5=A4=8D=E6=9C=AA=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E6=95=85=E9=9A=9C=E7=A0=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/common/constants.go | 2 ++ pkg/device/ascendcommon.go | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/common/constants.go b/pkg/common/constants.go index a1851652..64dcf10e 100644 --- a/pkg/common/constants.go +++ b/pkg/common/constants.go @@ -161,6 +161,8 @@ const ( // GeneralMapSize general map size GeneralMapSize = 8 + // MapSizeTwo map size two + MapSizeTwo = 2 // GeneralSubscribeTime general subscribe try time GeneralSubscribeTime = 3 // Hex hexadecimal diff --git a/pkg/device/ascendcommon.go b/pkg/device/ascendcommon.go index c95bcaa4..1e7d0a32 100644 --- a/pkg/device/ascendcommon.go +++ b/pkg/device/ascendcommon.go @@ -421,7 +421,7 @@ func (tool *AscendTools) groupDevsByStatus(subClassDevices []*common.NpuDevice, sets.String{}, sets.String{}, sets.String{}, sets.String{} deviceFaults := make([]common.DeviceFault, 0, common.GeneralMapSize) for _, device := range subClassDevices { - tool.updateDeviceFaults(device, deviceFaults) + deviceFaults = append(deviceFaults, tool.getDeviceFaults(device)...) if device.NetworkHealth == v1beta1.Unhealthy { totalNetworkUHDevices.Insert(device.DeviceName) } @@ -441,6 +441,7 @@ func (tool *AscendTools) groupDevsByStatus(subClassDevices []*common.NpuDevice, hwlog.RunLog.Debugf("total unhealthy devices %#v", totalUHDevices) hwlog.RunLog.Debugf("total network unhealthy devices %#v", totalNetworkUHDevices) hwlog.RunLog.Debugf("total recovering devices %#v", totalRCDevices) + hwlog.RunLog.Debugf("device fault list is %#v", deviceFaults) return common.DevStatusSet{ HealthDevices: healthDevice, UnHealthyDevice: totalUHDevices, @@ -450,8 +451,9 @@ func (tool *AscendTools) groupDevsByStatus(subClassDevices []*common.NpuDevice, } } -// updateDeviceFaults update device fault list -func (tool *AscendTools) updateDeviceFaults(device *common.NpuDevice, deviceFaults []common.DeviceFault) { +// getDeviceFaults get device fault list +func (tool *AscendTools) getDeviceFaults(device *common.NpuDevice) []common.DeviceFault { + deviceFaults := make([]common.DeviceFault, 0, common.MapSizeTwo) if len(device.NetworkFaultCodes) != 0 || device.NetworkHealth == v1beta1.Unhealthy { newCode := tool.removeDuplicateErr(append(device.NetworkFaultCodes, common.GetTimeoutFaultCodes(common.NetworkFaultMode)...)) @@ -472,6 +474,7 @@ func (tool *AscendTools) updateDeviceFaults(device *common.NpuDevice, deviceFaul FaultCode: strings.ToUpper(common.Int64Tool.ToHexString(newCode)), }) } + return deviceFaults } func (tool *AscendTools) removeDuplicateErr(faultCodes []int64) []int64 { -- Gitee