Skip to content

Commit

Permalink
fix(dbm-services): 资源导入时,解析脚本输出忽略错误message #6135
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq authored and zhangzhw8 committed Aug 8, 2024
1 parent d7b4511 commit caecf05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions dbm-services/common/db-resource/internal/svr/bk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"encoding/json"
"fmt"
"maps"
"regexp"
"time"

"dbm-services/common/go-pubpkg/cmutil"
Expand Down Expand Up @@ -156,6 +157,7 @@ func GetDiskInfo(hosts []IPList, bk_biz_id int, hostOsMap map[string]string) (re
}
ipLogContentMap := make(map[string]*ShellResCollection)
ipFailedLogMap := make(map[string]string)
jsonRe := regexp.MustCompile("{*.*}")
for os_type, ipList := range ipListOsMap {
if len(ipList) == 0 {
continue
Expand All @@ -169,7 +171,9 @@ func GetDiskInfo(hosts []IPList, bk_biz_id int, hostOsMap map[string]string) (re
maps.Copy(ipFailedLogMap, ipFailedLogMapWin)
for _, d := range ipLogs.ScriptTaskLogs {
var dl PowerShellResCollection
if err = json.Unmarshal([]byte(d.LogContent), &dl); err != nil {
jsonBody := jsonRe.FindString(d.LogContent)
logger.Info("%s shell grab json body: %s", d.Ip, jsonBody)
if err = json.Unmarshal([]byte(jsonBody), &dl); err != nil {
logger.Error("unmarshal log content failed %s", err.Error())
continue
}
Expand All @@ -187,7 +191,9 @@ func GetDiskInfo(hosts []IPList, bk_biz_id int, hostOsMap map[string]string) (re
maps.Copy(ipFailedLogMap, ipFailedLogMapLiunx)
for _, d := range ipLogs.ScriptTaskLogs {
var dl ShellResCollection
if err = json.Unmarshal([]byte(d.LogContent), &dl); err != nil {
jsonBody := jsonRe.FindString(d.LogContent)
logger.Info("%s shell grab json body: %s", d.Ip, jsonBody)
if err = json.Unmarshal([]byte(jsonBody), &dl); err != nil {
logger.Error("unmarshal log content failed %s", err.Error())
continue
}
Expand Down
2 changes: 1 addition & 1 deletion helm-charts/bk-dbm/charts/db-resource/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 0.0.1-alpha.98
appVersion: 0.0.1-alpha.99
description: A Helm chart for Kubernetes
name: db-resource
type: application
Expand Down

0 comments on commit caecf05

Please sign in to comment.