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

refactor(windows): win-bridge #617

Merged
merged 5 commits into from
Jun 2, 2021

Conversation

thxCode
Copy link
Contributor

@thxCode thxCode commented Apr 19, 2021

There are some problems with win-bridge plugin at present, i.e: unclear error message, unclear function name, cannot apply v2 API in policies...

This PR is going to clear/group the function name, comments, and some error messages through two chore commits. Then, through two refactor commits, some adjustments were made to the process of creating and deleting endpoints, so that the API processing logic of both versions is almost the same. Finally, through a breaking refactor commit to unify the two versions of the policy applying processing.

I think the impact of this final breaking commit is very small as the v2 API lacks the use under dockershim. Merging HcnPolicyArgs into Policies field to unify the endpoint policy configuration in one place. We still keep the same as before under dockershim, but change as below when switching to containerd.

{
    "name":"cbr0",
    "type":"flannel",
    "delegate":{
+       "apiVersion":2,
        "type":"win-bridge",
        "dns":{
            "nameservers":[
                "11.0.0.10"
            ],
            "search":[
                "svc.cluster.local"
            ]
        },
        "policies":[
            {
                "name":"EndpointPolicy",
                "value":{
                    "Type":"OutBoundNAT",
-                   "ExceptionList":[
-                       "192.168.0.0/16",
-                       "11.0.0.0/8",
-                       "10.137.196.0/23"
-                   ]
+                   "Settings":{
+                      "Exceptions":[
+                           "192.168.0.0/16",
+                           "11.0.0.0/8",
+                           "10.137.196.0/23"
+                       ]
+                   }
                }
            },
            {
                "name":"EndpointPolicy",
                "value":{
-                   "Type":"ROUTE",
-                   "DestinationPrefix":"11.0.0.0/8",
-                   "NeedEncap":true
+                   "Type":"SDNRoute",
+                   "Settings":{
+                      "DestinationPrefix":"11.0.0.0/8",
+                      "NeedEncap":true
+                   }
                }
            },
            {
                "name":"EndpointPolicy",
                "value":{
-                   "Type":"ROUTE",
-                   "DestinationPrefix":"10.137.198.27/32",
-                   "NeedEncap":true
+                   "Type":"SDNRoute",
+                   "Settings":{
+                      "DestinationPrefix":"10.137.198.27/32",
+                      "NeedEncap":true
+                   }
                }
            }
        ],
        "loopbackDSR": true
    }
}

@thxCode thxCode force-pushed the refactor_win_bridge branch 2 times, most recently from 222fe58 to 87758ff Compare April 19, 2021 12:18
@thxCode thxCode force-pushed the refactor_win_bridge branch 3 times, most recently from 07a8a55 to 1a06c1e Compare April 19, 2021 13:23
@thxCode
Copy link
Contributor Author

thxCode commented Apr 19, 2021

@nagiesek PTAL cc @mars1024 , @bboreham

@thxCode thxCode changed the title [WIP] refactor(windows): win-bridge refactor(windows): win-bridge Apr 20, 2021
@nagiesek
Copy link
Contributor

looks okay on a quick glance, but let run through this more in depth

@nagiesek
Copy link
Contributor

@vikas-bh

@dcbw
Copy link
Member

dcbw commented May 5, 2021

@vikas-bh @nagiesek any updates here?

@dcbw
Copy link
Member

dcbw commented May 19, 2021

@vikas-bh @nagiesek ping again for review, thanks!

pkg/hns/endpoint_windows.go Outdated Show resolved Hide resolved
@jayunit100
Copy link

hi ! im gonna try to get some context for this ....

@thxCode thxCode force-pushed the refactor_win_bridge branch 3 times, most recently from 436a4cd to e1f5c37 Compare May 20, 2021 02:39
@jayunit100
Copy link

jayunit100 commented May 20, 2021

@daschott @jsturtevant

  • Can we assume this is safe since its a v2 upgrade ?
  • Does the V2 golang client "know" how to translate to V1 API if needed?
  • ... per james V2 HNS has been around for > 1 year people running containers likely will have upgraded...

Copy link

@anfernee anfernee left a comment

Choose a reason for hiding this comment

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

From my limited knowledge of CNI implementation on windows, it looks good. I don't know how do we verify the netconf part with any sort of integration test? It depends on HCN/HNS interfaces on Windows.

pkg/hns/endpoint_windows.go Show resolved Hide resolved
pkg/hns/endpoint_windows.go Show resolved Hide resolved
pkg/hns/endpoint_windows.go Show resolved Hide resolved
pkg/hns/endpoint_windows.go Show resolved Hide resolved
pkg/hns/endpoint_windows.go Show resolved Hide resolved
Copy link
Contributor

@nagiesek nagiesek left a comment

Choose a reason for hiding this comment

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

Large change moving a lot of stuff around. Little hard to follow but nothing jumps out so LGTM. Some minor comments/clarifications could help.

pkg/hns/netconf_windows.go Show resolved Hide resolved
pkg/hns/netconf_windows.go Show resolved Hide resolved
pkg/hns/netconf_windows.go Outdated Show resolved Hide resolved
if strings.EqualFold(hnsEndpoint.VirtualNetwork, epInfo.NetworkId) {
return nil, fmt.Errorf("HNSEndpoint %s is already existed", epInfo.EndpointName)
}
// remove endpoint if corrupted
Copy link

Choose a reason for hiding this comment

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

What constitutes the endpoint being corrupted in this case?

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 think the endpoint is corrupted if it has the same name but mounted on the other network.

- format function names
- add/remove comments
- adjust message of error

Signed-off-by: thxcode <[email protected]>
- group functions by HNS,HCN

Signed-off-by: thxcode <[email protected]>
@thxCode thxCode force-pushed the refactor_win_bridge branch 2 times, most recently from cffe767 to 9f802c2 Compare May 27, 2021 15:42
- support v2 api
- unify v1 and v2 api

BREAKING CHANGE:
- remove `HcnPolicyArgs` field
- merge `HcnPolicyArgs` into `Policies` field

Signed-off-by: thxcode <[email protected]>
@dcbw
Copy link
Member

dcbw commented Jun 2, 2021

Thanks for all the reviews and work.

@dcbw dcbw merged commit 5238c13 into containernetworking:master Jun 2, 2021
@thxCode thxCode deleted the refactor_win_bridge branch June 3, 2021 02:43
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.

6 participants