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

Add podman network create flag for bridge mtu #8457

Merged
merged 4 commits into from
Dec 2, 2020

Conversation

afbjorklund
Copy link
Contributor

See #8454

@rhatdan
Copy link
Member

rhatdan commented Nov 23, 2020

You need to update man pages

@rhatdan
Copy link
Member

rhatdan commented Nov 23, 2020

Need tests, and I don't think this will work on podman-remote right now.

@rhatdan
Copy link
Member

rhatdan commented Nov 23, 2020

@baude @mheon PTAL

@@ -42,6 +42,8 @@ func networkCreateFlags(cmd *cobra.Command) {

flags.BoolVar(&networkCreateOptions.Internal, "internal", false, "restrict external access from this network")

flags.IntVar(&networkCreateOptions.MTU, "mtu", 0, "MTU")
Copy link
Member

Choose a reason for hiding this comment

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

Should we do a more general options flag? It seems like there could be quite a lot of these.

Copy link
Member

Choose a reason for hiding this comment

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

(The Docker extremely-long-option format is probably unnecessary, but something like --bridge-option mtu=8000?

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 suppose there couldn't be many more than what the CNI "bridge" exposes, but hopefully the user (OP) has more input...

Choose a reason for hiding this comment

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

In my use case I need only the MTU setting to sync it with an underlying network.
When looking at the bridge driver parameters, there's maybe one more good candidate for this - the vlan tag parameter..

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @mheon Lets do this as --bridge-option and just add the two for now, which leaves us room for more in the future without exploding out CLI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other commands use "opt" (instead of option), for instance the one from "podman volume create"

  -o, --opt stringArray   Set driver specific options (default [])

Like the ones from "run":

      --dns-opt strings                          Set custom DNS options
      --log-opt strings                          Logging driver options
      --security-opt stringArray                 Security Options

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

@@ -45,6 +45,10 @@ must be used with a *subnet* option.
Create a *Macvlan* based connection rather than a classic bridge. You must pass an interface name from the host for the
Macvlan connection.

#### **--mtu**

The MTU (integer, optional).
Copy link
Member

Choose a reason for hiding this comment

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

Chunked this together form Wikipedia, is this correct or needs adjusting? I think we need a bit more info than what's here at the moment.

Suggested change
The MTU (integer, optional).
The Maximum Transmission Unit (MTU), the size of the largest protocol data unit that can be communicated in a single network-layer transaction (integer, optional).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully the middle road is OK, with the new options

@rhatdan rhatdan added 3.0 Features kind/feature Categorizes issue or PR as related to a new feature. labels Nov 24, 2020
@afbjorklund
Copy link
Contributor Author

Need tests, and I don't think this will work on podman-remote right now.

I will need some help with this (integration test, and podman remote support)

@rhatdan
Copy link
Member

rhatdan commented Nov 24, 2020

@afbjorklund When you get this to a state that you are happy with, we can get someone to take it over if you want.

Set driver specific options.

For the `bridge` driver the following options are supported: `mtu`.
The `mtu` option sets the Maximum Transmission Unit (MTU) and takes an integer value.
Copy link
Member

Choose a reason for hiding this comment

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

👍

@afbjorklund
Copy link
Contributor Author

I think this should work, and the flag matches the "network" which also uses drivers.

Usage:
  podman volume create [options] [NAME]

Options:
      --driver string     Specify volume driver name (default "local")
  -l, --label strings     Set metadata for a volume (default [])
  -o, --opt stringArray   Set driver specific options (default [])
Usage:
  podman network create [options] [NETWORK]

Options:
  -d, --driver string     driver to manage the network (default "bridge")
  -o, --opt stringArray   Set driver specific options (default [])

And then we don't need another option, for the second driver ?


Was there another flag that should be added as well ? I think "vlan" was mentioned

https://www.cni.dev/plugins/main/bridge/

  • forceAddress (boolean, optional): Indicates if a new IP address should be set if the previous value has been changed. Defaults to false.
  • mtu (integer, optional): explicitly set MTU to the specified value. Defaults to the value chosen by the kernel.
  • promiscMode (boolean, optional): set promiscuous mode on the bridge. Defaults to false.
  • vlan (int, optional): assign VLAN tag. Defaults to none.

The remaining feature is --label, but as mentioned that needs some more work:

#7989 (comment)

Minikube is using labels, to identify which volumes and networks are OK to remove...

--filter='label=created_by.minikube.sigs.k8s.io=true'

The workaround is for the user to clean them up manually...

Volume does have --label, but the --filter was missing value. (#8341)

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

podman-remote works since we are using the full NetworkCreateOptions struct as json in the body.

For the integration tests I recommend adding this to test/e2e/network_create_test.go:

It("podman network create with mtu option", func() {
	net := "mtu-test"
	nc := podmanTest.Podman([]string{"network", "create", "--opt", "mtu=9000", net})
	nc.WaitWithDefaultTimeout()
	Expect(nc.ExitCode()).To(BeZero())
	defer podmanTest.removeCNINetwork(net)

	nc = podmanTest.Podman([]string{"network", "inspect", net})
	nc.WaitWithDefaultTimeout()
	Expect(nc.ExitCode()).To(BeZero())
	Expect(nc.OutputToString()).To(ContainSubstring(`"mtu": 9000,`))
})

cmd/podman/networks/create.go Outdated Show resolved Hide resolved
libpod/network/create.go Show resolved Hide resolved
libpod/network/create.go Outdated Show resolved Hide resolved
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM


For the `bridge` driver the following options are supported: `mtu` and `vlan`.
The `mtu` option sets the Maximum Transmission Unit (MTU) and takes an integer value.
The `vlan` option assign VLAN tag and enables vlan\_filtering. Defaults to none.
Copy link
Member

Choose a reason for hiding this comment

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

Just triple checking, I think the '` is intentional and needed?

Copy link
Contributor Author

@afbjorklund afbjorklund Nov 30, 2020

Choose a reason for hiding this comment

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

Sorry which one ? The backslash ? Editor was complaining about the "naked" underscore, so I escaped it... Maybe needlessly so. Not sure if it was seen as "half an italic" or something

Copy link
Member

Choose a reason for hiding this comment

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

oops, messed up the md prior. vlan\_filtering is what I was asking about. Seems to resolve OK, I'm just not sure it's necessary.

@TomSweeneyRedHat
Copy link
Member

LGTM

@zhangguanzhang
Copy link
Collaborator

may be need to rebase to 1 commit?

@rhatdan
Copy link
Member

rhatdan commented Dec 1, 2020

@afbjorklund needs a rebase, and then we can get this in.

Thanks Luap99 for doing the implementation

Signed-off-by: Anders F Björklund <[email protected]>
Thanks Luap99 for the validation suggestion

Signed-off-by: Anders F Björklund <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Dec 1, 2020

/approve
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 1, 2020
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afbjorklund, rhatdan

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2020
@openshift-merge-robot openshift-merge-robot merged commit c585012 into containers:master Dec 2, 2020
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants