Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/TencentBlueKing/bk-bcs in…
Browse files Browse the repository at this point in the history
…to across-fix-0813
  • Loading branch information
q15971095971 committed Aug 13, 2024
2 parents 2827051 + 9438c3e commit d5e04de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ func (h *HttpServerClient) ListAppMonitors(request *restful.Request, response *r

infoList := make([]InstalledScenarioInfo, 0)
for _, appMonitor := range appMonitorList.Items {
specBytes, _ := yaml.Marshal(appMonitor.Spec)
info := InstalledScenarioInfo{Name: appMonitor.Spec.Scenario,
Status: string(appMonitor.Status.SyncStatus.State),
Message: appMonitor.Status.SyncStatus.Message}
Message: string(specBytes)}

panelSelector, err1 := k8smetav1.LabelSelectorAsSelector(k8smetav1.SetAsLabelSelector(map[string]string{
monitorextensionv1.LabelKeyForAppMonitorName: appMonitor.GetName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ func ThreeWayMergeMonitorRule(original, current, modified []*v1.MonitorRuleDetai
// 3. 其余情况, 统一以模板为准
var mergeRule *v1.MonitorRuleDetail
if cmp.Equal(originalRule, currentRule, cmp.Comparer(compareMonitorRule)) {
blog.Infof("mergeRule..")
blog.Infof("[%s]mergeRule..", originalRule.Name)
// 相同说明用户没有在面板上进行修改
mergeRule = modifiedRule
// 告警组配置以用户设置为准
mergeRule.Notice = mergeNoticeGroup(currentRule.Notice, modifiedRule.Notice)
} else {
blog.Infof("changed Rule..")
blog.Infof("[%s]changed Rule..", originalRule.Name)
// 用户进行了修改, 不做变更
mergeRule = currentRule
}
Expand Down
25 changes: 22 additions & 3 deletions bcs-scenarios/bcs-monitor-controller/pkg/repo/git_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"gopkg.in/yaml.v3"
)

// ScenarioInfo info of monitor scenario
type ScenarioInfo struct {
Name string
Readme string
OptionInfo string
Name string `json:"name"`
Readme string `json:"readme"`
OptionInfo string `json:"option_info"`
Config ScenarioConfig `json:"config"`
}

// ScenarioConfig config
type ScenarioConfig struct {
Label string `yaml:"label" json:"label"`
// if true, not visible for users
Invisible bool `yaml:"invisible" json:"invisible"`
}

// gitRepo clone git repo and pull in certain freq
Expand Down Expand Up @@ -235,10 +244,20 @@ func (gr *gitRepo) refreshScenarioInfos() error {
}
// 所有场景以目录形式存在
if file.IsDir() {
config := ScenarioConfig{}
configStr := readFileContent(filepath.Join(gr.Directory, file.Name(), "config.yaml"))
// 解析config失败时正常返回
if err1 := yaml.Unmarshal([]byte(configStr), &config); err1 != nil {
blog.Errorf("Scene[%s] unmarshal config failed, err: %s", file.Name(), err1.Error)
}
if config.Invisible {
continue
}
scenarioList = append(scenarioList, &ScenarioInfo{
Name: file.Name(),
Readme: readFileContent(filepath.Join(gr.Directory, file.Name(), "README.md")),
OptionInfo: readFileContent(filepath.Join(gr.Directory, file.Name(), "option.yaml")),
Config: config,
})
}
}
Expand Down

0 comments on commit d5e04de

Please sign in to comment.