From d1e0fa040e9bbcf4f660daca2f99e912da823bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B8=A3=E6=B2=BC?= Date: Fri, 12 Apr 2024 14:54:52 +0800 Subject: [PATCH] =?UTF-8?q?fixed=2001d15aa=20from=20https://gitee.com/lmzt?= =?UTF-8?q?ju/ascend-docker-runtime/pulls/56=20=E3=80=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=20Modification=E3=80=91=E4=BF=AE=E5=A4=8Dcon?= =?UTF-8?q?tainerd=E7=8E=AF=E5=A2=83=E4=B8=AD=E5=AE=B9=E5=99=A8=E4=B8=AD?= =?UTF-8?q?=E9=A2=84=E5=88=B6ASCEND=5FVISIBLE=5FDEVICES=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=AF=BC=E8=87=B4=E5=AE=9E=E9=99=85=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E8=8A=AF=E7=89=87=E5=92=8Cdevice-plugin=E5=88=86?= =?UTF-8?q?=E9=85=8D=E8=8A=AF=E7=89=87=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime/main.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/runtime/main.go b/runtime/main.go index 8d5fedd..917e329 100644 --- a/runtime/main.go +++ b/runtime/main.go @@ -378,9 +378,8 @@ func getValueByKey(data []string, name string) string { func getValueByDeviceKey(data []string) string { res := "" - isKeyExist := false - for _, envLine := range data { - words := strings.SplitN(envLine, "=", kvPairSize) + for i := len(data) - 1; i >= 0; i-- { + words := strings.SplitN(data[i], "=", kvPairSize) if len(words) != kvPairSize { hwlog.RunLog.Error("environment error") return "" @@ -388,16 +387,12 @@ func getValueByDeviceKey(data []string) string { if words[0] == ascendVisibleDevices { res = words[1] - if strings.Contains(res, ascend) { - return res - } - isKeyExist = true + break } } - if isKeyExist && res == "" { + if res == "" { hwlog.RunLog.Error("ASCEND_VISIBLE_DEVICES env variable is empty, will not mount any ascend device") } - return res } -- Gitee