Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions npm/nwpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ func (npMgr *NetworkPolicyManager) AddNetworkPolicy(npObj *networkingv1.NetworkP
npMgr.ProcessedNpMap[npProcessedKey] = npObj
}

npMgr.RawNpMap[npKey] = npObj

sets, namedPorts, lists, ingressIPCidrs, egressIPCidrs, iptEntries = translatePolicy(npObj)
for _, set := range sets {
log.Logf("Creating set: %v, hashedSet: %v", set, util.GetHashedName(set))
Expand Down Expand Up @@ -192,6 +190,7 @@ func (npMgr *NetworkPolicyManager) AddNetworkPolicy(npObj *networkingv1.NetworkP
return err
}
}
npMgr.RawNpMap[npKey] = npObj

metrics.NumPolicies.Inc()
timer.StopAndRecord(metrics.AddPolicyExecTime)
Expand Down Expand Up @@ -241,8 +240,6 @@ func (npMgr *NetworkPolicyManager) DeleteNetworkPolicy(npObj *networkingv1.Netwo
removeCidrsRule("in", npObj.ObjectMeta.Name, npObj.ObjectMeta.Namespace, ingressIPCidrs, allNs.IpsMgr)
removeCidrsRule("out", npObj.ObjectMeta.Name, npObj.ObjectMeta.Namespace, egressIPCidrs, allNs.IpsMgr)

delete(npMgr.RawNpMap, npKey)

if oldPolicy, oldPolicyExists := npMgr.ProcessedNpMap[npProcessedKey]; oldPolicyExists {
deductedPolicy, err := deductPolicy(oldPolicy, npObj)
if err != nil {
Expand All @@ -264,6 +261,7 @@ func (npMgr *NetworkPolicyManager) DeleteNetworkPolicy(npObj *networkingv1.Netwo
return err
}
}
delete(npMgr.RawNpMap, npKey)

metrics.NumPolicies.Dec()

Expand Down