Skip to content
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

[Windows] NoEncap support #2160

Merged
merged 3 commits into from
May 27, 2021
Merged

[Windows] NoEncap support #2160

merged 3 commits into from
May 27, 2021

Conversation

lzhecheng
Copy link
Contributor

@lzhecheng lzhecheng commented May 10, 2021

This PR implements support for Windows Noencap mode. It also includes flow optimization to improve
Pod to Pod performance.
Noencap: If same subnet, destination MAC in OVS is set with peer Node annotation. If not, host routing will
be used to forward traffic.
Hybrid: If same subnet, same as Noencap with same subnet. If not, same as Encap mode.

Supersedes #1901
Fixes #1632

@codecov-commenter
Copy link

codecov-commenter commented May 10, 2021

Codecov Report

Merging #2160 (07a1db7) into main (29f4deb) will increase coverage by 3.35%.
The diff coverage is 57.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2160      +/-   ##
==========================================
+ Coverage   61.63%   64.99%   +3.35%     
==========================================
  Files         273      274       +1     
  Lines       20673    20859     +186     
==========================================
+ Hits        12742    13557     +815     
+ Misses       6594     5922     -672     
- Partials     1337     1380      +43     
Flag Coverage Δ
e2e-tests 52.85% <48.93%> (?)
kind-e2e-tests 52.55% <53.19%> (-0.06%) ⬇️
unit-tests 41.28% <46.80%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/agent/openflow/pipeline.go 79.02% <50.00%> (+7.87%) ⬆️
pkg/agent/openflow/client.go 68.42% <53.84%> (+8.89%) ⬆️
...gent/controller/noderoute/node_route_controller.go 60.82% <75.00%> (+14.43%) ⬆️
pkg/agent/openflow/pipeline_other.go 100.00% <100.00%> (+50.00%) ⬆️
...g/controller/networkpolicy/clusternetworkpolicy.go 72.79% <0.00%> (-14.35%) ⬇️
pkg/apiserver/handlers/endpoint/handler.go 58.82% <0.00%> (-11.77%) ⬇️
pkg/agent/nodeportlocal/rules/iptable_rule.go 55.93% <0.00%> (-7.71%) ⬇️
pkg/apiserver/storage/ram/watch.go 90.38% <0.00%> (-3.85%) ⬇️
...gent/controller/networkpolicy/status_controller.go 72.60% <0.00%> (-2.74%) ⬇️
...kg/controller/networkpolicy/store/networkpolicy.go 83.58% <0.00%> (-1.42%) ⬇️
... and 55 more

@lzhecheng lzhecheng force-pushed the win-noencap branch 2 times, most recently from ee17d65 to f20f2d0 Compare May 10, 2021 14:15
@lzhecheng
Copy link
Contributor Author

/test-all

pkg/agent/openflow/pipeline.go Outdated Show resolved Hide resolved
pkg/agent/controller/noderoute/node_route_controller.go Outdated Show resolved Hide resolved
pkg/agent/controller/noderoute/node_route_controller.go Outdated Show resolved Hide resolved
pkg/agent/controller/noderoute/node_route_controller.go Outdated Show resolved Hide resolved
@lzhecheng
Copy link
Contributor Author

/test-all

@lzhecheng
Copy link
Contributor Author

/test-all

@lzhecheng
Copy link
Contributor Author

/test-windows-conformance

@lzhecheng
Copy link
Contributor Author

/test-conformance

@lzhecheng lzhecheng force-pushed the win-noencap branch 2 times, most recently from 77ab28f to b429bf7 Compare May 11, 2021 07:19
@lzhecheng
Copy link
Contributor Author

/test-all

@lzhecheng
Copy link
Contributor Author

/test-windows-networkpolicy /test-conformance /test-networkpolicy

@lzhecheng
Copy link
Contributor Author

/test-windows-networkpolicy

@lzhecheng
Copy link
Contributor Author

/test-e2e /test-conformance /test-networkpolicy /test-windows-conformance

@lzhecheng
Copy link
Contributor Author

/test-windows-networkpolicy

@lzhecheng
Copy link
Contributor Author

/test-windows-conformance

pkg/agent/openflow/client.go Outdated Show resolved Hide resolved
pkg/agent/openflow/client.go Outdated Show resolved Hide resolved
@lzhecheng lzhecheng force-pushed the win-noencap branch 4 times, most recently from 5e6f48d to 6933039 Compare May 19, 2021 04:42
@lzhecheng lzhecheng requested a review from antoninbas May 26, 2021 06:25
@lzhecheng
Copy link
Contributor Author

/test-all

@lzhecheng
Copy link
Contributor Author

/test-networkpolicy

2 similar comments
@lzhecheng
Copy link
Contributor Author

/test-networkpolicy

@lzhecheng
Copy link
Contributor Author

/test-networkpolicy

@lzhecheng
Copy link
Contributor Author

/test-windows-networkpolicy

@lzhecheng
Copy link
Contributor Author

@antoninbas if you got no more comments on this PR, could you please merge it when tests are successful? So the new release won't be blocked.

}

nrInfo, installed, _ := c.installedNodes.GetByKey(nodeName)
if installed && nrInfo != nil && nrInfo.(*nodeRouteInfo).nodeMAC != nil && peerNodeMAC != nil && nrInfo.(*nodeRouteInfo).nodeMAC.String() == peerNodeMAC.String() {
Copy link
Contributor

Choose a reason for hiding this comment

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

it feels like if they are both nil, we should also return early?

if installed && nrInfo != nil {
    installedMAC := nrInfo.(*nodeRouteInfo).nodeMAC
    if installedMAC == nil && peerNodeMAC == nil {
        return nil
    }
    if installedMAC != nil && peerNodeMAC != nil && installedMAC.String() == peerNodeMAC.String() { {
        return nil
    }
}

Copy link
Member

Choose a reason for hiding this comment

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

It's fine to call installedMAC.String() when installedMAC is nil, it will get "".

type HardwareAddr []byte

func (a HardwareAddr) String() string {
	if len(a) == 0 {
		return ""
	}
	buf := make([]byte, 0, len(a)*3-1)
	for i, b := range a {
		if i > 0 {
			buf = append(buf, ':')
		}
		buf = append(buf, hexDigit[b>>4])
		buf = append(buf, hexDigit[b&0xF])
	}
	return string(buf)
}

So this can be simplified to:

if installed && nrInfo.(*nodeRouteInfo).nodeMAC.String() == peerNodeMAC.String()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need to check nrInfo != nil and peerNodeMAC != nil?

Copy link
Member

Choose a reason for hiding this comment

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

No, we don't need to check it. The "String" method checks the length of the struct. You can test it to confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

pkg/agent/controller/noderoute/node_route_controller.go Outdated Show resolved Hide resolved
Comment on lines +128 to +129
// NoEncap traffic to Node on the different subnet needs underlying routing support.
// Use host default route inside the Node.
Copy link
Member

Choose a reason for hiding this comment

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

This is noEncap + different subnet case, we rely on the underlying network to route the Pod traffic to peer Node as we cannot set nexthop to peerNodeIP in such case. We assume the Node has a default gateway which is an external router and user/cloud-controller will configure the routes on the external router.
Maybe the function name NeedsRoutingToPeer is confusing, I was asked several times why we install route when it does NOT need routing to peer. I will make a PR to clarify it.

pkg/agent/controller/noderoute/node_route_controller.go Outdated Show resolved Hide resolved
@tnqn
Copy link
Member

tnqn commented May 26, 2021

The old PR #1901
Fixed issue #1632

"Fixed issue" is not a github keyword and won't close the issue. Maybe:

Supersedes #1901
Fixes #1632

@@ -88,6 +97,10 @@ func (c *Client) Reconcile(podCIDRs []string) error {
c.hostRoutes.Store(dst, rt)
continue
}
// If the route is not for uplink interface, ignore it.
if c.nodeConfig.UplinkNetConfig != nil && rt.LinkIndex != c.nodeConfig.UplinkNetConfig.Index {
Copy link
Member

Choose a reason for hiding this comment

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

I just found this condition is not correct. listRoutes only returns routes on antrea-gw0 or br-int, so this is going to be always true. And I don't see why we need to check if it's for uplink interface here. We have migrated all routes from uplink to br-int for noEncap case.

I also wonder how we know which route can be deleted as there could be user configured routes on br-int for noEncap case. I checked linux case, it cleans orphaned routes on antrea-gw0 only, which seems working for encap only but at least won't cause problem. I would suggest keep windows the same, i.e. don't try to clean up routes on br-int in Reconcile until there is a way to distinguish user configured routes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

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

LGTM. Just a few minor comments.

pkg/agent/openflow/client.go Outdated Show resolved Hide resolved
pkg/agent/openflow/client.go Show resolved Hide resolved
@lzhecheng
Copy link
Contributor Author

/test-conformance

@lzhecheng
Copy link
Contributor Author

/test-networkpolicy

1 similar comment
@lzhecheng
Copy link
Contributor Author

/test-networkpolicy

@lzhecheng lzhecheng requested review from antoninbas and tnqn May 27, 2021 03:17
@lzhecheng
Copy link
Contributor Author

/test-e2e


nrInfo, installed, _ := c.installedNodes.GetByKey(nodeName)

if installed && nrInfo != nil {
Copy link
Member

@tnqn tnqn May 27, 2021

Choose a reason for hiding this comment

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

I think installed == true already means nrInfo != nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

}

nrInfo, installed, _ := c.installedNodes.GetByKey(nodeName)
if installed && nrInfo != nil && nrInfo.(*nodeRouteInfo).nodeMAC != nil && peerNodeMAC != nil && nrInfo.(*nodeRouteInfo).nodeMAC.String() == peerNodeMAC.String() {
Copy link
Member

Choose a reason for hiding this comment

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

No, we don't need to check it. The "String" method checks the length of the struct. You can test it to confirm.

@@ -165,7 +191,7 @@ func (c *Client) listRoutes() (map[string]*netroute.Route, error) {
rtMap := make(map[string]*netroute.Route)
for idx := range routes {
rt := routes[idx]
if rt.LinkIndex != c.nodeConfig.GatewayConfig.LinkIndex {
if rt.LinkIndex != c.nodeConfig.GatewayConfig.LinkIndex && rt.LinkIndex != c.bridgeInfIndex {
Copy link
Member

Choose a reason for hiding this comment

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

You need to remove the second condition too? otherwise some routes on br-int will be removed unexpectedly. We only manage routes on antrea-gw0 so should return them only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Signed-off-by: Zhecheng Li <[email protected]>
@lzhecheng
Copy link
Contributor Author

/test-all

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@lzhecheng
Copy link
Contributor Author

/test-e2e /test-windows-e2e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support noEncap mode on Windows
6 participants