fix(region): avoid sync esxi panic (#17791)

This commit is contained in:
屈轩
2023-08-17 18:13:13 +08:00
committed by GitHub
parent 14aaa012ad
commit 19445ad574
2 changed files with 2 additions and 6 deletions
+1 -1
View File
@@ -4551,7 +4551,7 @@ func (h *SHost) addNetif(ctx context.Context, userCred mcclient.TokenCredential,
}
netif, err := NetInterfaceManager.FetchByMacVlan(mac, vlanId)
if err != nil {
if err != sql.ErrNoRows {
if errors.Cause(err) != sql.ErrNoRows {
return httperrors.NewInternalServerError("fail to fetch netif by mac %s: %s", mac, err)
}
// else not found
+1 -5
View File
@@ -96,11 +96,7 @@ func (manager *SNetInterfaceManager) FetchByMacVlan(mac string, vlanId int) (*SN
ret := &SNetInterface{}
err := q.First(ret)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
return nil, nil
} else {
return nil, errors.Wrap(err, "Query")
}
return nil, errors.Wrapf(err, "First")
}
ret.SetModelManager(manager, ret)
return ret, nil