Skip to content

Conversation

@huntergregory
Copy link
Contributor

@huntergregory huntergregory commented May 17, 2022

Used to never apply policies to endpoints if the policy selector involved a list set. Two changes to enable this:

  1. fix calculation getting IPs in the intersection of pod selector IPSets
  2. separate out member IPSets of list IPSets in the pod selector

Other change: fail the dataplane if a non "azure" network is specified or if IPPolicyMode is used, which is unimplemented.

@huntergregory huntergregory added the npm Related to NPM. label May 17, 2022
@huntergregory huntergregory requested a review from a team as a code owner May 17, 2022 01:05
@huntergregory huntergregory requested review from vakalapa and removed request for a team May 17, 2022 01:05
)
}

if len(policyNetworkRequest.Policies) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why move this check down ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the other check back, but this is a separate check. We can have 1+ setpolicysettings but have 0 policies if there are no setpolicies with the given policyType

@huntergregory huntergregory force-pushed the npm-fix-windows-intersection branch from e4cdb51 to 0dd8c55 Compare May 19, 2022 20:22
if set.Kind == HashSet {
result := make(map[string]struct{}, len(set.IPPodKey))
for ip := range set.IPPodKey {
result[ip] = struct{}{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the set.IPPodKey map directly ignore values instead of creating a map with the same keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking about this more, there are 2 scenarios:

  1. when determining which IPs to apply a new policy on, we use the full map
  2. when updating the IPSets that a pod is a part of, we only check to see if the Pod IP is in the map

The second scenario doesn't require the full map and could use O(1) space, but I'm not sure if this a worthwhile optimization if we already do the O(N) space option for another scenario

@tamilmani1989 tamilmani1989 merged commit ebd695e into master May 23, 2022
@tamilmani1989 tamilmani1989 deleted the npm-fix-windows-intersection branch May 23, 2022 21:05
matmerr pushed a commit to matmerr/azure-container-networking that referenced this pull request Jun 29, 2022
* fix windows intersection

* test intersection

* fix build

* separate out children of pod selector and add translate UTs

* address comments

* address named return comment

* optimize space/time for checking if an ip satisfies a pod selector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

npm Related to NPM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants