mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(monitor): alert policy use ownerId when update
1.根据参数中的project和domain属性调用FetchOwnerId方法,然后确定报警策略归属并进行监控查询过滤
This commit is contained in:
@@ -916,7 +916,8 @@ func (alert *SCommonAlert) ValidateUpdateData(
|
||||
return data, errors.Wrap(err, "metric_query Unmarshal error")
|
||||
}
|
||||
scope, _ := data.GetString("scope")
|
||||
err = CommonAlertManager.ValidateMetricQuery(metricQuery, scope, userCred)
|
||||
ownerId := CommonAlertManager.GetOwnerId(ctx, userCred, data)
|
||||
err = CommonAlertManager.ValidateMetricQuery(metricQuery, scope, ownerId)
|
||||
if err != nil {
|
||||
return data, errors.Wrap(err, "metric query error")
|
||||
}
|
||||
@@ -947,6 +948,14 @@ func (alert *SCommonAlert) ValidateUpdateData(
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (manager *SCommonAlertManager) GetOwnerId(ctx context.Context, userCred mcclient.TokenCredential, data jsonutils.JSONObject) mcclient.IIdentityProvider {
|
||||
ownId, _ := CommonAlertManager.FetchOwnerId(ctx, data)
|
||||
if ownId == nil {
|
||||
ownId = userCred
|
||||
}
|
||||
return ownId
|
||||
}
|
||||
|
||||
func (alert *SCommonAlert) PostUpdate(
|
||||
ctx context.Context, userCred mcclient.TokenCredential,
|
||||
query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
|
||||
Reference in New Issue
Block a user