Skip to content

Conversation

@vakalapa
Copy link
Contributor

@vakalapa vakalapa commented Aug 30, 2021

Reason for Change:

This PR helps outline the DataPlane interface which acts as an abstraction layer for similar functionalities in Windows and Linux.

a. Addition of new dataplane APIs for control plane to use
b. specific build target functions to convert ipsets and acl policies accoridngly

Issue Fixed:

Requirements:

Notes:

@vakalapa vakalapa marked this pull request as draft August 30, 2021 18:58
@vakalapa vakalapa marked this pull request as ready for review August 31, 2021 21:03
@vakalapa
Copy link
Contributor Author

vakalapa commented Sep 1, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@vakalapa vakalapa requested a review from neaggarwMS September 1, 2021 20:18
set.IpsetReferCount--
}

func (set *IPSet) AddSelectorReference(netPolName string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

different arg name (below func too)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

essentially what we are adding is the network policy name if its a selector ref or a normal ref.

Copy link
Member

@matmerr matmerr left a comment

Choose a reason for hiding this comment

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

some comments


const (
ListSet SetKind = "list"
HashSet SetKind = "set"
Copy link
Member

Choose a reason for hiding this comment

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

tbh I think there's room for what defines a set here, taking linux vernacular could be misleading in windows, but I think in terms of platform agnostic, what about something like hashset is "set" and list is "superset" since it contains only "sets"(?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this "superset" since it is intuitive. But keeping list since we have been used to calling it as list. We can use "nestedset" which windows is using ?

}
}

func getSetKind(setType SetType) SetKind {
Copy link
Member

Choose a reason for hiding this comment

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

is this still needed with properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we derive the kind from type of set input.

Copy link
Contributor

@JungukCho JungukCho left a comment

Choose a reason for hiding this comment

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

Before I put other comments, there are structural (i.e., architectural) comments of this PR.
I may misunderstand the codes and intentions, but some of them are different from what I expected.

  1. I thought interface will be used for ipsetmanager and dataplane to abstract linux and windows. But it seems you use composition with concrete struct instead of interface. I think both ipsetmanager and dataplane are nicely abstract with interface (Example in npm - https://github.com/Azure/azure-container-networking/blob/master/npm/iptm/ioshim.go).
    Do I know why you decide this direction?

  2. There are many almost inline method (just one or two lines) for exposed members. In this case, if you want to keep methods, I think non-capitalizing members if possible since it is good to maintain code as our code base becomes bigger and bigger. In addition, some of them can be removed with interface direction instead of concrete struct.
    I may be wrong, but I think function or method having one line is not very useful. wdyt?

  3. It would be nice to have UTs for ipsetmanager_windows.go and dataplane_windows.go in this PR to guarantee their functionality, but as you said, it will be next PR. So, I think it is ok in this PR.

  4. While I read this PR, there are many common variables and const with debugTools. I think it is good to remove redundant declarations by checking debugTools code carefully. One examaple, is ipset.go and rule.pb.go generated from rule.proto.

@vakalapa
Copy link
Contributor Author

vakalapa commented Sep 8, 2021

@JungukCho thanks foe the comments

  1. I felt there is not much abstraction to be made with interfaces. As part of our design exercise we did find that most of the core logic is same for both dataplanes, only the dataplane specific artifact conversions and application is different. So i took the https://golang.org/src/os/executable.go approach. The main executable package contains a publicly exposed function Executable() and each dataplane specific file will implement the executable() like https://golang.org/src/os/executable_windows.go. I felt this is much easier to read as the flow of code is pretty straight forward. Please let me know if you think there is any issue with this approach
  2. Sure, most of the dataplane.go function may stay inline like above executable approach but some will get filled up with abstractions needed for both dataplanes. Also a single dataplane call will make our lifes easier in terms extending dataplane with a gprc call in between later on for operator model. Like you mentioned i will try to see if i can non-capitalize any members.
  3. Agreed, tests are important and will definitely be one focus area when adding windows dataplane support.
  4. I did not want to increase the scope of this PR. We do have a debug tools work item in pipeline and as part of that work item and also as part of dataplane integration we should be able to clean pkg/dataplane all together. Will be a incremental process. Idea is to not touch any existing code as much possible.

return hcn.DirectionTypeIn
case Egress:
return hcn.DirectionTypeOut
case Both:
Copy link
Contributor

Choose a reason for hiding this comment

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

seems this case is not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Windows dataplane does accept rules on both directions, in case of network policies with both ingress and egress rules i can use a DENY all with BOTH, that way we get away with single rule than 2

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant case Both is not necessary based on logic. Anyway, by default it returns ""

@JungukCho
Copy link
Contributor

JungukCho commented Sep 8, 2021

@JungukCho thanks foe the comments

  1. I felt there is not much abstraction to be made with interfaces. As part of our design exercise we did find that most of the core logic is same for both dataplanes, only the dataplane specific artifact conversions and application is different. So i took the https://golang.org/src/os/executable.go approach. The main executable package contains a publicly exposed function Executable() and each dataplane specific file will implement the executable() like https://golang.org/src/os/executable_windows.go. I felt this is much easier to read as the flow of code is pretty straight forward.
    Please let me know if you think there is any issue with this approach

If they are almost identical, this approach seems reasonable. How about Dataplane? I think they are pretty different implementations. I will first take a look at your reference. I may find better patterns instead of interface. I will let you know if I still prefer to interface and we can discuss more.

  1. Sure, most of the dataplane.go function may stay inline like above executable approach but some will get filled up with abstractions needed for both dataplanes. Also a single dataplane call will make our lifes easier in terms extending dataplane with a gprc call in between later on for operator model. Like you mentioned i will try to see if i can non-capitalize any members.

Still I think those inline functions will be nicely removed with interface. Further more dataplane-specific functions will be added in next PRs. So, it will increase more these inline functions. I will check your above reference and let you know.
I think in this stage thinking a grpc call in design is not very helpful since it is too future. wdyt?

  1. Agreed, tests are important and will definitely be one focus area when adding windows dataplane support.
  2. I did not want to increase the scope of this PR. We do have a debug tools work item in pipeline and as part of that work item and also as part of dataplane integration we should be able to clean pkg/dataplane all together. Will be a incremental process. Idea is to not touch any existing code as much possible.

I am not sure it increases scope of the PR. I meant checking the existing variables and then reusing them to avoid redundant codes in this PR without touching existing logics.

JungukCho
JungukCho previously approved these changes Sep 10, 2021
Copy link
Contributor

@JungukCho JungukCho left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for applying comments.
This PR will be foundation of next NPM!

matmerr
matmerr previously approved these changes Sep 10, 2021
Copy link
Member

@matmerr matmerr left a comment

Choose a reason for hiding this comment

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

🚀

@vakalapa vakalapa dismissed stale reviews from matmerr and JungukCho via 607ba43 September 10, 2021 23:06
huntergregory
huntergregory previously approved these changes Sep 10, 2021
Copy link
Member

@matmerr matmerr left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

@JungukCho JungukCho left a comment

Choose a reason for hiding this comment

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

lgtm

@vakalapa vakalapa merged commit 01c12d8 into master Sep 13, 2021
@vakalapa vakalapa deleted the vakr/dataplaneinterface branch September 13, 2021 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement npm Related to NPM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants