mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
fix(monitor,apihelper): list storages without details
This commit is contained in:
@@ -137,7 +137,7 @@ func (h *APIHelper) RunManually(ctx context.Context) {
|
||||
func (h *APIHelper) run(ctx context.Context) {
|
||||
changed, err := h.doSync(ctx)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
log.Errorf("doSync error: %v", err)
|
||||
}
|
||||
if changed {
|
||||
mssCopy := h.modelSets.CopyJoined()
|
||||
@@ -161,7 +161,7 @@ func (h *APIHelper) doSync(ctx context.Context) (changed bool, err error) {
|
||||
mss := h.modelSets.Copy()
|
||||
r, err := SyncModelSets(mss, s, h.opts)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return false, errors.Wrap(err, "SyncModelSets")
|
||||
}
|
||||
h.modelSets = mss
|
||||
if !r.Correct {
|
||||
|
||||
@@ -54,6 +54,10 @@ type IModelListParam interface {
|
||||
ModelParamFilter() jsonutils.JSONObject
|
||||
}
|
||||
|
||||
type IModelListSetParams interface {
|
||||
SetModelListParams(params *jsonutils.JSONDict) *jsonutils.JSONDict
|
||||
}
|
||||
|
||||
func SyncModelSets(mssOld IModelSets, s *mcclient.ClientSession, opt *Options) (r ModelSetsUpdateResult, err error) {
|
||||
mss := mssOld.ModelSetList()
|
||||
mssNews := mssOld.NewEmpty()
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/printutils"
|
||||
"yunion.io/x/pkg/util/timeutils"
|
||||
|
||||
@@ -140,6 +141,9 @@ func GetModels(opts *GetModelsOptions) error {
|
||||
filter := inter.ModelParamFilter()
|
||||
params.Update(filter)
|
||||
}
|
||||
if inter, ok := opts.ModelSet.(IModelListSetParams); ok {
|
||||
params = inter.SetModelListParams(params)
|
||||
}
|
||||
//XXX
|
||||
//params.Set(api.LBAGENT_QUERY_ORIG_KEY, jsonutils.NewString(api.LBAGENT_QUERY_ORIG_VAL))
|
||||
|
||||
@@ -148,8 +152,8 @@ func GetModels(opts *GetModelsOptions) error {
|
||||
var err error
|
||||
listResult, err := opts.ModelManager.List(opts.ClientSession, params)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: list failed with updated_at.gt('%s'): %s",
|
||||
manKeyPlural, minUpdatedAt, err)
|
||||
log.Errorf("%s: list failed with updated_at.gt('%s'): %s", manKeyPlural, minUpdatedAt, err)
|
||||
return errors.Wrapf(err, "%s list failed with params: %s", manKeyPlural, params.QueryString())
|
||||
}
|
||||
entriesJson = append(entriesJson, listResult.Data...)
|
||||
if listResult.Offset+len(listResult.Data) >= listResult.Total {
|
||||
|
||||
@@ -246,12 +246,18 @@ func (c *QueryCondition) serieIsLatestResource(resources []jsonutils.JSONObject,
|
||||
tagId = "host_id"
|
||||
}
|
||||
resId := series.Tags[tagId]
|
||||
log.Debugf("serieIsLatestResource use tagId %q, found resId %q", tagId, resId)
|
||||
if len(resources) != 0 {
|
||||
for _, resource := range resources {
|
||||
id, _ := resource.GetString("id")
|
||||
if resId == id {
|
||||
// return true, resource
|
||||
return models.MonitorResourceManager.GetResourceObj(resId)
|
||||
got, obj := models.MonitorResourceManager.GetResourceObj(resId)
|
||||
if got {
|
||||
return true, obj
|
||||
} else {
|
||||
log.Warningf("not found resource %s %s from cache, use list item directly", c.ResType, resId)
|
||||
return true, resource
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -330,6 +330,12 @@ func (s Storages) NeedSync() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s Storages) SetModelListParams(params *jsonutils.JSONDict) *jsonutils.JSONDict {
|
||||
// list storages with details is too long
|
||||
params.Set("details", jsonutils.JSONFalse)
|
||||
return params
|
||||
}
|
||||
|
||||
func (d Domains) ModelManager() modulebase.IBaseManager {
|
||||
return &identity.Domains
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ func (manager *SMonitorResourceManager) SyncResources(ctx context.Context, mss *
|
||||
return err
|
||||
}
|
||||
}
|
||||
log.Infoln("SMonitorResourceManager SyncResources End")
|
||||
log.Infof("SMonitorResourceManager SyncResources End")
|
||||
err := CommonAlertManager.Run(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("CommonAlertManager UpdateMonitorResourceJoint err:%v", err)
|
||||
|
||||
@@ -92,7 +92,7 @@ func StartService() {
|
||||
if err != nil {
|
||||
log.Fatalf("new worker failed: %v", err)
|
||||
}
|
||||
go worker.Start(context.Background(), app, "")
|
||||
go worker.Start(app.GetContext(), app, "")
|
||||
|
||||
//common_app.ServeForever(app, baseOpts)
|
||||
InitInfluxDBSubscriptionHandlers(app, baseOpts)
|
||||
|
||||
Reference in New Issue
Block a user