Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Don't bypass selector provisioning when not default deny
Browse files Browse the repository at this point in the history
If we have namespaces Source and Destination, and Destination
contains a NetworkPolicy allowing access from Source, we need
to provision the ipsets for Source and add them to relevant
selectors, even though Source is DefaultAllow.

Fixes #3059
  • Loading branch information
mikebryant committed Jul 12, 2017
1 parent b73b43f commit 46288b0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions npc/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ func (ns *ns) addNamespace(obj *coreapi.Namespace) error {

// Insert a rule to bypass policies if namespace is DefaultAllow
if !isDefaultDeny(obj) {
return ns.ensureBypassRule(ns.allPods.ipsetName)
if err := ns.ensureBypassRule(ns.allPods.ipsetName); err != nil {
return err
}
}

// Add namespace ipset to matching namespace selectors
Expand All @@ -281,10 +283,14 @@ func (ns *ns) updateNamespace(oldObj, newObj *coreapi.Namespace) error {
if oldDefaultDeny != newDefaultDeny {
common.Log.Infof("namespace DefaultDeny changed from %t to %t", oldDefaultDeny, newDefaultDeny)
if oldDefaultDeny {
return ns.ensureBypassRule(ns.allPods.ipsetName)
if err := ns.ensureBypassRule(ns.allPods.ipsetName); err != nil {
return err
}
}
if newDefaultDeny {
return ns.deleteBypassRule(ns.allPods.ipsetName)
if err := ns.deleteBypassRule(ns.allPods.ipsetName); err != nil {
return err
}
}
}

Expand Down Expand Up @@ -317,7 +323,9 @@ func (ns *ns) deleteNamespace(obj *coreapi.Namespace) error {

// Remove bypass rule
if !isDefaultDeny(obj) {
return ns.deleteBypassRule(ns.allPods.ipsetName)
if err := ns.deleteBypassRule(ns.allPods.ipsetName); err != nil {
return err
}
}

// Remove namespace ipset from any matching namespace selectors
Expand Down

0 comments on commit 46288b0

Please sign in to comment.