Merge pull request #6076 from yousong/automated-cherry-pick-of-#6075-upstream-release-3.2

Automated cherry pick of #6075: vpcagent: work around nics of pending deleted guest
This commit is contained in:
Zexi Li
2020-04-27 17:19:02 +08:00
committed by GitHub
2 changed files with 16 additions and 13 deletions
+13 -13
View File
@@ -27,8 +27,8 @@ import (
type Vpcs map[string]*Vpc
type Networks map[string]*Network
type Guests map[string]*Guest
type Hosts map[string]*Host // host-vpc as key
type Guestnetworks map[string]*Guestnetwork // guestId as key
type Hosts map[string]*Host
type Guestnetworks map[string]*Guestnetwork // key: guestId/ifname
func (set Vpcs) ModelManager() mcclient_modulebase.IBaseManager {
return &mcclient_modules.Vpcs
@@ -169,18 +169,18 @@ func (ms Networks) joinGuestnetworks(subEntries Guestnetworks) bool {
m.Guestnetworks = Guestnetworks{}
}
for _, subEntry := range subEntries {
id := subEntry.NetworkId
m, ok := ms[id]
netId := subEntry.NetworkId
m, ok := ms[netId]
if !ok {
// this can happen when this guestnetwork is just a
// stub for external/managed guests and "ms" was
// already filtered by conditions like
// already filtered out by conditions like
// external_id.isnullorempty, etc.
continue
}
subId := subEntry.GuestId
subId := subEntry.GuestId + "/" + subEntry.Ifname
if _, ok := m.Guestnetworks[subId]; ok {
log.Warningf("guestnetwork id %s/%s already joined", id, subId)
log.Warningf("guestnetwork net/guest/ifname %s/%s already joined", netId, subId)
continue
}
subEntry.Network = m
@@ -199,7 +199,7 @@ func (set Guestnetworks) NewModel() db.IModel {
func (set Guestnetworks) AddModel(i db.IModel) {
m := i.(*Guestnetwork)
set[m.GuestId] = m
set[m.GuestId+"/"+m.Ifname] = m
}
func (set Guestnetworks) Copy() apihelper.IModelSet {
@@ -211,19 +211,19 @@ func (set Guestnetworks) Copy() apihelper.IModelSet {
}
func (set Guestnetworks) joinGuests(subEntries Guests) bool {
correct := true
for _, gn := range set {
gId := gn.GuestId
g, ok := subEntries[gId]
if !ok {
if gn.Network != nil && gn.Network.Vpc != nil {
log.Warningf("guestnetwork %d(net:%s,ip:%s) guest id %s not found",
gn.RowId, gn.NetworkId, gn.IpAddr, gId)
correct = false
// Only log info instead of error because the
// guest could be in pending_deleted state
log.Infof("guestnetwork (net:%s,ip:%s) guest id %s not found",
gn.NetworkId, gn.IpAddr, gId)
}
continue
}
gn.Guest = g
}
return correct
return true
}
+3
View File
@@ -114,6 +114,9 @@ func (w *Worker) run(ctx context.Context, mss *agentmodels.ModelSets) (err error
for _, network := range vpc.Networks {
ovndb.ClaimNetwork(ctx, network)
for _, guestnetwork := range network.Guestnetworks {
if guestnetwork.Guest == nil {
continue
}
var (
guest = guestnetwork.Guest
network = guestnetwork.Network