-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Network policy: use shared pod selector address sets #3329
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f6f3ed8
Unlock shared default deny port group early, when no db changes
npinaeva 120140f
Add PodSelectorAddressSet object, that should be used to manage
npinaeva ed34024
Rework gressPolicy ACLs build: previously all gress policies with at
npinaeva 7f4b409
Add PodSelectorAddressSet tests.
npinaeva 54b67a3
don't create acl if no namespace address sets are selected.
npinaeva File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1327,11 +1327,11 @@ func (oc *DefaultNetworkController) addNetworkPolicy(policy *knet.NetworkPolicy) | |
func (oc *DefaultNetworkController) buildNetworkPolicyACLs(np *networkPolicy, aclLogging *ACLLoggingLevels) []*nbdb.ACL { | ||
acls := []*nbdb.ACL{} | ||
for _, gp := range np.ingressPolicies { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: in the future we should make network policy actually have an update instead of delete+add |
||
acl := gp.buildLocalPodACLs(np.portGroupName, aclLogging) | ||
acl, _ := gp.buildLocalPodACLs(np.portGroupName, aclLogging) | ||
acls = append(acls, acl...) | ||
} | ||
for _, gp := range np.egressPolicies { | ||
acl := gp.buildLocalPodACLs(np.portGroupName, aclLogging) | ||
acl, _ := gp.buildLocalPodACLs(np.portGroupName, aclLogging) | ||
acls = append(acls, acl...) | ||
} | ||
|
||
|
@@ -1525,7 +1525,7 @@ func (oc *DefaultNetworkController) peerNamespaceUpdate(np *networkPolicy, gp *g | |
return nil | ||
} | ||
// buildLocalPodACLs is safe for concurrent use, see function comment for details | ||
acls := gp.buildLocalPodACLs(np.portGroupName, aclLogging) | ||
acls, deletedACLs := gp.buildLocalPodACLs(np.portGroupName, aclLogging) | ||
ops, err := libovsdbops.CreateOrUpdateACLsOps(oc.nbClient, nil, acls...) | ||
if err != nil { | ||
return err | ||
|
@@ -1534,6 +1534,17 @@ func (oc *DefaultNetworkController) peerNamespaceUpdate(np *networkPolicy, gp *g | |
if err != nil { | ||
return err | ||
} | ||
if len(deletedACLs) > 0 { | ||
deletedACLsWithUUID, err := libovsdbops.FindACLs(oc.nbClient, deletedACLs) | ||
if err != nil { | ||
return fmt.Errorf("failed to find deleted acls: %w", err) | ||
} | ||
|
||
ops, err = libovsdbops.DeleteACLsFromPortGroupOps(oc.nbClient, ops, np.portGroupName, deletedACLsWithUUID...) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
_, err = libovsdbops.TransactAndCheck(oc.nbClient, ops) | ||
return err | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Previously l3Match for gress with namespace selector that doesn't select
anything looked like "ip4.src == {}", now it will be
"ip4.src == {}"."
Do we really want to program ACLs that wont match on anything? In the previous behavior it made sense because address sets are populated without touching ACL again. But ACL will have to be updated to have the right address set once the selector finally matches something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually the previous behaviour for namespace selector was
We can delete this empty-match acl, but that will complicate the code, since we need to delete the acl on update when no namespaces are matched, and we will need to track which acls got deleted. Now we just update all existing acls, and on namespace delete acl will be updated to empty match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the behavior here of ovn-controller when the match is an empty brace? Does it throw any error or warning, does it assume it does not match anything? @dceara ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ovn-controller complains, e.g.:
So the flow will not be installed (and will obviously never match).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i will use the update instead of mutate for port group acl updates then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of extra clarification: the
"ip4.src == {}"
match can be replaced by"0"
with the exact same effect - nothing will match.