Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dbm-services): 资源导入时,解析脚本输出忽略错误message #6135 #6136

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading