From 35d69ed1dbe3e07c152f89817e76ef2de57e6aad Mon Sep 17 00:00:00 2001 From: y00841556 Date: Mon, 4 Dec 2023 18:58:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=A1=A5=E5=85=A8=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- k8s-mpam-controller/pkg/agent/mpam.go | 29 +++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/k8s-mpam-controller/pkg/agent/mpam.go b/k8s-mpam-controller/pkg/agent/mpam.go index 814ee7d..d3b9bfe 100644 --- a/k8s-mpam-controller/pkg/agent/mpam.go +++ b/k8s-mpam-controller/pkg/agent/mpam.go @@ -287,7 +287,8 @@ func generateFullConf(mpamconf interface{}) []interface{} { continue } if checkConfig(rcdata) { - mpamFullCfg[index] = rcdata + fullData = createFullData(rcdata, string(cfg)) + mpamFullCfg[index] = fullData } else { klog.Errorf("config %v is not right, please check config", rcdata) } @@ -298,6 +299,30 @@ func generateFullConf(mpamconf interface{}) []interface{} { return mpamFullCfg } +func createFullData(rcdata, cfg string) string { + curCfg := strings.Split(strings.Split(rcdata, ":")[1], ";") + fullCfg := strings.Split(strings.Split(cfg, ":")[1], ";") + + for _, numaCfg := range curCfg { + numaId, err := strconv.Atoi(strings.Split(numaCfg, "=")[0]) + if err != nil { + klog.Errorf("createFullData error, please check config") + return rcdata + } + fullCfg[numaId] = numaCfg + } + + finalCfg := strings.Split(rcdata, ":")[0] + ":" + for id, numaCfg := range fullCfg { + finalCfg += numaCfg + if id != len(fullCfg) -1 { + finalCfg += ";" + } + } + + return finalCfg +} + func applyConfig(data *configData) { var mpamGroups []string @@ -342,7 +367,7 @@ func applyConfig(data *configData) { } } - if len(mpamGroups) > num_closids { + if len(mpamGroups) >= num_closids { klog.Errorf("The number of groups to be created exceeds the upper limit,"+ "only %v groups can be created", num_closids) } -- Gitee