elasticips: error when we have no usable eip network

This commit is contained in:
Yousong Zhou
2020-09-23 16:21:43 +08:00
parent 382f628287
commit 63c4818b8a
+6 -2
View File
@@ -1265,17 +1265,21 @@ func (manager *SElasticipManager) NewEipForVMOnHost(ctx context.Context, userCre
return nil, errors.Wrapf(err, "fetch eip networks usable in host %s(%s)",
host.Name, host.Id)
}
var net *SNetwork
for i := range nets {
net := &nets[i]
net = &nets[i]
cnt, err := net.GetFreeAddressCount()
if err != nil {
continue
}
if cnt > 0 {
eip.NetworkId = net.Id
break
}
}
if net == nil {
return nil, errors.Error("no usable eip network")
}
eip.NetworkId = net.Id
}
var err error