mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
Merge branch 'master' of https://github.com/goodrain/rainbond
This commit is contained in:
commit
69a133868a
@ -1962,6 +1962,12 @@ func (s *ServiceAction) UpdAutoscalerRule(req *api_model.AutoscalerRuleReq) erro
|
||||
return err
|
||||
}
|
||||
|
||||
// delete metrics
|
||||
if err := db.GetManager().TenantServceAutoscalerRuleMetricsDaoTransactions(tx).DeleteByRuleID(req.RuleID); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
for _, metric := range req.Metrics {
|
||||
m := &dbmodel.TenantServiceAutoscalerRuleMetrics{
|
||||
RuleID: req.RuleID,
|
||||
@ -1970,7 +1976,7 @@ func (s *ServiceAction) UpdAutoscalerRule(req *api_model.AutoscalerRuleReq) erro
|
||||
MetricTargetType: metric.MetricTargetType,
|
||||
MetricTargetValue: metric.MetricTargetValue,
|
||||
}
|
||||
if err := db.GetManager().TenantServceAutoscalerRuleMetricsDaoTransactions(tx).UpdateOrCreate(m); err != nil {
|
||||
if err := db.GetManager().TenantServceAutoscalerRuleMetricsDaoTransactions(tx).AddModel(m); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
@ -465,6 +465,7 @@ type TenantServceAutoscalerRuleMetricsDao interface {
|
||||
Dao
|
||||
UpdateOrCreate(metric *model.TenantServiceAutoscalerRuleMetrics) error
|
||||
ListByRuleID(ruleID string) ([]*model.TenantServiceAutoscalerRuleMetrics, error)
|
||||
DeleteByRuleID(ruldID string) error
|
||||
}
|
||||
|
||||
// TenantServiceScalingRecordsDao -
|
||||
|
@ -1569,6 +1569,15 @@ func (t *TenantServceAutoscalerRuleMetricsDaoImpl) ListByRuleID(ruleID string) (
|
||||
return metrics, nil
|
||||
}
|
||||
|
||||
// DeleteByRuleID -
|
||||
func (t *TenantServceAutoscalerRuleMetricsDaoImpl) DeleteByRuleID(ruldID string) error {
|
||||
if err := t.DB.Where("rule_id=?", ruldID).Delete(&model.TenantServiceAutoscalerRuleMetrics{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TenantServiceScalingRecordsDaoImpl -
|
||||
type TenantServiceScalingRecordsDaoImpl struct {
|
||||
DB *gorm.DB
|
||||
|
Loading…
Reference in New Issue
Block a user