From ccbc5dcfb8a8cbfdb6370eb79d33c4d4398650c3 Mon Sep 17 00:00:00 2001 From: Rain Zheng Date: Sat, 29 Jan 2022 00:58:46 +0800 Subject: [PATCH] fix(host): judge whether the resource exists correctly (#13370) --- pkg/hostman/isolated_device/isolated_device.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/hostman/isolated_device/isolated_device.go b/pkg/hostman/isolated_device/isolated_device.go index 6a53c22b3c..2869da3257 100644 --- a/pkg/hostman/isolated_device/isolated_device.go +++ b/pkg/hostman/isolated_device/isolated_device.go @@ -24,9 +24,9 @@ import ( "yunion.io/x/pkg/errors" api "yunion.io/x/onecloud/pkg/apis/compute" + "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/procutils" ) @@ -199,7 +199,7 @@ func (man *isolatedDeviceManager) StartDetachTask() { jsonutils.Marshal(map[string]interface{}{ "purge": true, })); err != nil { - if jce, ok := errors.Cause(err).(*httputils.JSONClientError); ok && jce.Code == 404 { + if errors.Cause(err) == httperrors.ErrResourceNotFound { break } log.Errorf("Detach device %s failed: %v, try again later", dev.Id, err)