mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-20 12:22:16 +08:00
fix(monitor): onecloud notifiers role_ids validation
This commit is contained in:
@@ -71,8 +71,8 @@ func init() {
|
||||
if err := input.Settings.Unmarshal(settings); err != nil {
|
||||
return input, errors.Wrap(err, "unmarshal setting")
|
||||
}
|
||||
if settings.Channel == "" && len(settings.RobotIds) == 0 {
|
||||
return input, httperrors.NewInputParameterError("channel is empty")
|
||||
if settings.Channel == "" && len(settings.RobotIds) == 0 && len(settings.RoleIds) == 0 {
|
||||
return input, httperrors.NewInputParameterError("channel, robot_ids or role_ids is empty")
|
||||
}
|
||||
ids := make([]string, 0)
|
||||
for _, uid := range settings.UserIds {
|
||||
|
||||
@@ -55,8 +55,8 @@ type SAlertRecord struct {
|
||||
Level string `charset:"ascii" width:"36" nullable:"false" default:"normal" list:"user" update:"user"`
|
||||
State string `width:"36" charset:"ascii" nullable:"false" default:"unknown" list:"user" update:"user"`
|
||||
SendState string `width:"36" charset:"ascii" default:"ok" list:"user" update:"user"`
|
||||
EvalData jsonutils.JSONObject `list:"user" update:"user"`
|
||||
AlertRule jsonutils.JSONObject `list:"user" update:"user"`
|
||||
EvalData jsonutils.JSONObject `list:"user" update:"user" length:""`
|
||||
AlertRule jsonutils.JSONObject `list:"user" update:"user" length:""`
|
||||
ResType string `width:"36" list:"user" update:"user"`
|
||||
}
|
||||
|
||||
|
||||
@@ -194,8 +194,10 @@ func (man *SCommonAlertManager) ValidateCreateData(
|
||||
}
|
||||
}
|
||||
// 默认的系统配置Recipients=commonalert-default
|
||||
if data.AlertType != monitor.CommonAlertSystemAlertType && len(data.Recipients) == 0 {
|
||||
return data, merrors.NewArgIsEmptyErr("recipients")
|
||||
if data.AlertType != monitor.CommonAlertSystemAlertType {
|
||||
if len(data.Recipients) == 0 && len(data.RobotIds) == 0 && len(data.Roles) == 0 {
|
||||
return data, merrors.NewArgIsEmptyErr("recipients, robot_ids or roles")
|
||||
}
|
||||
}
|
||||
|
||||
if len(data.CommonMetricInputQuery.MetricQuery) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user