From 2b0a7ac265642ce3c07a6c8294e3f4d3f358614c Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Thu, 27 Nov 2025 19:19:31 +0800 Subject: [PATCH] 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 --- pkg/hostman/guestman/guesthandlers/guesthandler.go | 3 ++- pkg/hostman/hosthandler/handler.go | 3 ++- pkg/hostman/hostinfo/hostinfo.go | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/hostman/guestman/guesthandlers/guesthandler.go b/pkg/hostman/guestman/guesthandlers/guesthandler.go index e014b86fd8..416c391735 100644 --- a/pkg/hostman/guestman/guesthandlers/guesthandler.go +++ b/pkg/hostman/guestman/guesthandlers/guesthandler.go @@ -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) diff --git a/pkg/hostman/hosthandler/handler.go b/pkg/hostman/hosthandler/handler.go index f663ab7c15..8ee6a081db 100644 --- a/pkg/hostman/hosthandler/handler.go +++ b/pkg/hostman/hosthandler/handler.go @@ -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) diff --git a/pkg/hostman/hostinfo/hostinfo.go b/pkg/hostman/hostinfo/hostinfo.go index 9885c0b480..e9cdaac279 100644 --- a/pkg/hostman/hostinfo/hostinfo.go +++ b/pkg/hostman/hostinfo/hostinfo.go @@ -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 })