Automated cherry pick of #23846: Fix/host misc fix (#23847)

* fix(host): host register return wrong error value

* fix(host): host handlers use gotypes check ret value is nil
This commit is contained in:
wanyaoqi
2025-11-27 19:19:31 +08:00
committed by GitHub
parent 79166f9aaa
commit 2b0a7ac265
3 changed files with 8 additions and 6 deletions
@@ -22,6 +22,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/onecloud/pkg/apis"
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
@@ -138,7 +139,7 @@ func guestActions(f actionFunc) appsrv.FilterHandler {
res, err := f(ctx, userCred, sid, body)
if err != nil {
hostutils.Response(ctx, w, err)
} else if res != nil {
} else if !gotypes.IsNil(res) {
hostutils.Response(ctx, w, res)
} else {
hostutils.ResponseOk(ctx, w)
+2 -1
View File
@@ -23,6 +23,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/utils"
"yunion.io/x/onecloud/pkg/appsrv"
@@ -79,7 +80,7 @@ func hostActions(f actionFunc) appsrv.FilterHandler {
res, err := f(ctx, sid, body)
if err != nil {
hostutils.Response(ctx, w, err)
} else if res != nil {
} else if !gotypes.IsNil(res) {
hostutils.Response(ctx, w, res)
} else {
hostutils.ResponseOk(ctx, w)
+4 -4
View File
@@ -1225,25 +1225,25 @@ func (h *SHostInfo) register() {
eg := errgroup.Group{}
eg.Go(func() error {
if e := h.initCgroup(); e != nil {
return errors.Wrap(err, "initCgroup")
return errors.Wrap(e, "initCgroup")
}
return nil
})
eg.Go(func() error {
if e := h.initHostNetworks(hostInfo); e != nil {
return errors.Wrap(err, "initHostNetworks")
return errors.Wrap(e, "initHostNetworks")
}
return nil
})
eg.Go(func() error {
if e := h.initIsolatedDevices(); e != nil {
return errors.Wrap(err, "initIsolatedDevices")
return errors.Wrap(e, "initIsolatedDevices")
}
return nil
})
eg.Go(func() error {
if e := h.initStorages(); e != nil {
return errors.Wrap(err, "initStorages")
return errors.Wrap(e, "initStorages")
}
return nil
})