k8snetworkplumbingwg / ovs-cni

Open vSwitch CNI plugin
Apache License 2.0
218 stars 70 forks source link

Ability to specify `ofport_request` in the network configuration #239

Closed courtland closed 1 year ago

courtland commented 2 years ago

What this PR does / why we need it:

Enables plugin configuration to request a specific ofport number when attaching a container to the host's OVS bridge.

This PR adds a new ofport_request integer field to the network configuration options.

Also addresses the old issue #73.

If the ofport_request field is omitted, the plugin continues to let OVS choose an available port. If the requested ofport is already in use, OVS will automatically choose another free ofport. See man ovs-vswitchd.conf.db(5) for more information about ofport_request behavior.

Special notes for your reviewer:

I am using this as a CNI plugin in conjunction with HashiCorp Nomad and an OpenFlow SDN controller, although I imagine there are use cases for k8s as well. The fixed ofport is required to play nicely with the SDN controller. Containers are bridged into an OVS bridge datapath handled by the OpenFlow controller.

Although I tried to mirror the behavior with the existing OvnPortName option, I am not able to pass along/modify CNI_ARGS through Nomad, which is somewhat related to https://github.com/hashicorp/nomad/issues/13520. This is why I opted to include it in the network configuration along with the vlan/mtu/bridge/etc.

Release note:

Added the ability to request a static OVS `ofport` number via a new `ofport_request` field in the Network Configuration
kubevirt-bot commented 2 years ago

Hi @courtland. Thanks for your PR.

I'm waiting for a k8snetworkplumbingwg member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
phoracek commented 2 years ago

Thanks for opening this @courtland, I will review this during the next week.

courtland commented 2 years ago

Thanks for taking a look at this. I have improved the test, so hopefully it is good to merge. I am fine with waiting for #227 - building from my fork solves my immediate problem for the time being.

phoracek commented 2 years ago

/retest

Looks good, thanks!

phoracek commented 2 years ago

@courtland would you please fix this lint error?

/tmp/src/github.com/k8snetworkplumbingwg/ovs-cni/.gopath/src/github.com/k8snetworkplumbingwg/ovs-cni/pkg/plugin/plugin_test.go:670:5: don't use underscores in Go names; var ofport_request should be ofportRequest
courtland commented 2 years ago

@phoracek lint error is fixed - Sorry, too much Python lately and not enough Go 🤦

phoracek commented 1 year ago

Haha, no worries!

phoracek commented 1 year ago

@courtland would you please rebase the PR, so we could merge it?

courtland commented 1 year ago

@phoracek squashed and rebased against latest main

phoracek commented 1 year ago

/retest

courtland commented 1 year ago

@phoracek I'm having trouble understanding whether or not the test failures are something bad with my rebase, or if they are related to errors in the recent port mirroring changes, as they seem specific to creating mirror ports. Any hints?

phoracek commented 1 year ago

It seems like a transient error, not related to this PR.

/retest

phoracek commented 1 year ago

/override pull-e2e-ovs-cni

It failed on an unrelated port mirroring test

phoracek commented 1 year ago

/retest

Sorry about the trouble, I'm working on stabilization of the test in another PR.

phoracek commented 1 year ago

/retest

phoracek commented 1 year ago

/lgtm /approve

kubevirt-bot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: courtland, phoracek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/k8snetworkplumbingwg/ovs-cni/blob/main/OWNERS)~~ [phoracek] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
phoracek commented 1 year ago

Thanks @courtland !

courtland commented 1 year ago

No worries, thanks for merging it!