Skip to content

Commit

Permalink
Merge pull request #143 from squeed/bp-4.4-slow-netns-watch
Browse files Browse the repository at this point in the history
Bug 1839107: node/vnids: Correctly handle case where NetNamespace watch is far behind
  • Loading branch information
openshift-merge-robot committed May 29, 2020
2 parents f4de98e + a4a926d commit 2652368
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions pkg/network/node/networkpolicy.go
Expand Up @@ -102,6 +102,9 @@ func (np *networkPolicyPlugin) SupportsVNIDs() bool {
}

func (np *networkPolicyPlugin) Start(node *OsdnNode) error {
np.lock.Lock()
defer np.lock.Unlock()

np.node = node
np.vnids = newNodeVNIDMap(np, node.networkClient)
if err := np.vnids.Start(node.networkInformers); err != nil {
Expand Down Expand Up @@ -134,9 +137,6 @@ func (np *networkPolicyPlugin) Start(node *OsdnNode) error {
}

func (np *networkPolicyPlugin) initNamespaces() error {
np.lock.Lock()
defer np.lock.Unlock()

inUseVNIDs := np.node.oc.FindPolicyVNIDs()

namespaces, err := np.node.kClient.CoreV1().Namespaces().List(metav1.ListOptions{})
Expand All @@ -149,7 +149,9 @@ func (np *networkPolicyPlugin) initNamespaces() error {
npns.gotNamespace = true
np.namespacesByName[ns.Name] = npns

if vnid, err := np.vnids.WaitAndGetVNID(ns.Name); err == nil {
// can't call WaitAndGetVNID here, because it calls back in to np
// and we hold the lock!
if vnid, err := np.vnids.getVNID(ns.Name); err == nil {
npns.vnid = vnid
npns.inUse = inUseVNIDs.Has(int(vnid))
npns.gotNetNamespace = true
Expand All @@ -162,7 +164,7 @@ func (np *networkPolicyPlugin) initNamespaces() error {
return err
}
for _, policy := range policies.Items {
vnid, err := np.vnids.WaitAndGetVNID(policy.Namespace)
vnid, err := np.vnids.getVNID(policy.Namespace)
if err != nil {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/node/vnids.go
Expand Up @@ -119,7 +119,7 @@ func (vmap *nodeVNIDMap) WaitAndGetVNID(name string) (uint32, error) {
return 0, fmt.Errorf("failed to find netid for namespace: %s, %v", name, err)
}
klog.Warningf("Netid for namespace: %s exists but not found in vnid map", name)
vmap.setVNID(netns.Name, netns.NetID, netnsIsMulticastEnabled(netns))
vmap.handleAddOrUpdateNetNamespace(netns, nil, watch.Added)
return netns.NetID, nil
}
}
Expand Down

0 comments on commit 2652368

Please sign in to comment.