@@ -339,6 +339,10 @@ func (a *Allocator) freeHostnic(nic *rpc.HostNic) error {
339339 }
340340
341341 if _ , err := qcclient .QClient .DeattachNics ([]string {nic .ID }, true ); err != nil {
342+ if strings .Contains (err .Error (), constants .ResourceNotFound ) {
343+ log .Infof ("nic %s/%s was not found from api, skip DeattachNics and DeleteNics" , nic .VxNet .ID , nic .ID )
344+ return nil
345+ }
342346 log .Errorf ("DeattachNics for vxnet %s failed: nic %s failed: %v" , nic .VxNet .ID , nic .ID , err )
343347 return err
344348 }
@@ -355,13 +359,14 @@ func (a *Allocator) ClearFreeHostnic(force bool) error {
355359 a .lock .Lock ()
356360 defer a .lock .Unlock ()
357361
358- maxVxnetNicsCount := a .getVxnetMaxNicNum ()
359- if len (a .nics ) < a .conf .NodeThreshold && maxVxnetNicsCount < a .conf .VxnetThreshold && ! force {
360- log .Infof ("no hostnic to free: %d %d %d %d" , len (a .nics ), maxVxnetNicsCount , a .conf .NodeThreshold , a .conf .VxnetThreshold )
361- return nil
362- }
362+ // maxVxnetNicsCount := a.getVxnetMaxNicNum()
363+ // log.Infof("freeHostnic: %d %d %d %d", len(a.nics), maxVxnetNicsCount, a.conf.NodeThreshold, a.conf.VxnetThreshold)
364+ // if len(a.nics) < a.conf.NodeThreshold && maxVxnetNicsCount < a.conf.VxnetThreshold && !force {
365+ // log.Infof("no hostnic to free: %d %d %d %d", len(a.nics), maxVxnetNicsCount, a.conf.NodeThreshold, a.conf.VxnetThreshold)
366+ // return nil
367+ // }
363368
364- log .Infof ("freeHostnic: %d %d %d %d " , len (a .nics ), maxVxnetNicsCount , a . conf . NodeThreshold , a . conf . VxnetThreshold )
369+ log .Infof ("freeHostnic: %d" , len (a .nics ))
365370 for vxnet , status := range a .nics {
366371 if len (status .Pods ) == 0 {
367372 nicKey := getNicKey (status .Nic )
0 commit comments