mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
optimize(host): wrap updateOrCreateHost error (#21141)
This commit is contained in:
@@ -1417,7 +1417,11 @@ func (h *SHostInfo) ensureHostRecord(zoneId string) (*api.HostDetails, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return h.updateOrCreateHost(h.HostId)
|
||||
host, err := h.updateOrCreateHost(h.HostId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "updateOrCreateHost")
|
||||
}
|
||||
return host, nil
|
||||
}
|
||||
|
||||
func (h *SHostInfo) UpdateSyncInfo(hostId string, body jsonutils.JSONObject) (interface{}, error) {
|
||||
@@ -1561,11 +1565,14 @@ func (h *SHostInfo) updateOrCreateHost(hostId string) (*api.HostDetails, error)
|
||||
)
|
||||
if !h.isInit {
|
||||
res, err = modules.Hosts.Update(h.GetSession(), hostId, jsonutils.Marshal(input))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "update host with input: %s", jsonutils.Marshal(input))
|
||||
}
|
||||
} else {
|
||||
res, err = modules.Hosts.CreateInContext(h.GetSession(), jsonutils.Marshal(input), &modules.Zones, h.ZoneId)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "host create or update with %s", jsonutils.Marshal(input))
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "create host with zone: %q, input: %s", h.ZoneId, jsonutils.Marshal(input))
|
||||
}
|
||||
}
|
||||
|
||||
hostDetails := api.HostDetails{}
|
||||
|
||||
Reference in New Issue
Block a user