fix(climc): monitor-alert-test-run prints result error (#21212)

This commit is contained in:
Zexi Li
2024-09-11 20:04:40 +08:00
committed by GitHub
parent d2f2d9ba77
commit e4fd6508c2
2 changed files with 3 additions and 14 deletions
+1 -6
View File
@@ -15,7 +15,6 @@
package monitor
import (
"encoding/json"
"fmt"
"yunion.io/x/pkg/errors"
@@ -46,11 +45,7 @@ func init() {
if err != nil {
return errors.Wrap(err, "DoTestRun")
}
jsonBytes, err := json.MarshalIndent(ret, "", " ")
if err != nil {
return errors.Wrap(err, "MarshalIndent")
}
fmt.Printf("%s\n", jsonBytes)
fmt.Printf("%s\n", ret.PrettyString())
return nil
})
}
+2 -8
View File
@@ -15,8 +15,6 @@
package monitor
import (
"encoding/json"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -125,14 +123,10 @@ func (m *SAlertManager) DoCreate(s *mcclient.ClientSession, config *AlertConfig)
return m.Create(s, input.JSON(input))
}
func (m *SAlertManager) DoTestRun(s *mcclient.ClientSession, id string, input *monitor.AlertTestRunInput) (*monitor.AlertTestRunOutput, error) {
func (m *SAlertManager) DoTestRun(s *mcclient.ClientSession, id string, input *monitor.AlertTestRunInput) (jsonutils.JSONObject, error) {
ret, err := m.PerformAction(s, id, "test-run", input.JSON(input))
if err != nil {
return nil, errors.Wrap(err, "call test-run")
}
out := new(monitor.AlertTestRunOutput)
if err := json.Unmarshal([]byte(ret.String()), out); err != nil {
return nil, errors.Wrapf(err, "Unmarshal %s", ret.String())
}
return out, nil
return ret, nil
}