-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 support for driver-specific options during container creation #24535
add support for driver-specific options during container creation #24535
Conversation
Ephemeral COPR build failed. @containers/packit-build please check. |
FYI if you call This will also need documentation on --network option to at least document to one new option you added. I think putting this behind @mheon WDYT? |
I want to say we should validate at create time (if necessary by calling Current approach LGTM given that. I don't like it but the alternatives are worse. |
6ab15aa
to
da9a0c3
Compare
Signed-off-by: Michael Zimmermann <[email protected]>
da9a0c3
to
9c79590
Compare
Would a simple e2e test be the right choice for this change? Do those actually run netavark in the background? Otherwise such a test probably wouldn't be that useful. |
yes in test/e2e there a bunch of tests all using netavark. The problem here is though that we use the distro version so we first need to release a netavark then update it here in our CI images and only then we could test the new option. Having a test is important to ensure the option is fully working and correct send to netavark so we know it works end to end. You can add a Skip("") to the test so it is not run in CI yet but having a test that I can enable later when we update the CI images is always a good idea. |
The test |
Yes if we go with the current version that would need to be dropped. I guess you can update the test to ensure unknown keys end up in the options map. |
93b8978
to
828301f
Compare
I've added tests now. If you prefer the Can you help me with the |
test/e2e/network_test.go
Outdated
@@ -297,6 +298,23 @@ var _ = Describe("Podman network", func() { | |||
Expect(rmAll).Should(ExitCleanly()) | |||
}) | |||
|
|||
It("podman run container host interface name", func() { | |||
Skip("We need to update netavark first.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please say FIXME: We need netavark >= v1.14 for host interface support
.
This is important for anyone looking at this to know when this can be dropped.
test/e2e/network_test.go
Outdated
Skip("We need to update netavark first.") | ||
|
||
ctrName := "testCtr" | ||
vethName := "my_veth" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not use static names, that might cause conflicts on the host.
Append a random suffix, i.e. "my_veth" + stringid.GenerateRandomID()[:8]
veth, err := net.InterfaceByName(vethName) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(veth.Name).To(Equal(vethName)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go
index 018b7eb97..3d3f1d393 100644
--- a/test/e2e/network_test.go
+++ b/test/e2e/network_test.go
@@ -312,6 +312,11 @@ var _ = Describe("Podman network", func() {
veth, err := net.InterfaceByName(vethName)
Expect(err).ToNot(HaveOccurred())
Expect(veth.Name).To(Equal(vethName))
+ } else {
+ session := podmanTest.Podman([]string{"unshare", "--rootless-netns", "ip", "link", "show", vethName})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(ExitCleanly())
+ Expect(session.OutputToString()).To(ContainSubstring(vethName))
}
})
we can test rootless as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, thanks.
@@ -161,7 +161,14 @@ func TestParseNetworkFlag(t *testing.T) { | |||
name: "bridge mode with invalid option", | |||
args: []string{"bridge:abc=123"}, | |||
nsmode: Namespace{NSMode: Bridge}, | |||
err: "unknown bridge network option: abc", | |||
networks: map[string]types.PerNetworkOptions{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you rename the test to not say invalid but rather unknown.
Also maybe add another case where add 2+ options to make sure it is working for multiple keys. I know it does as the code is simple enough but better to validate that
I run the test on my system and it worked there (having a netavark from main installed) + added a diff to make do something useful as rootless as well |
test/e2e/network_test.go
Outdated
Expect(container).Should(ExitCleanly()) | ||
|
||
if !isRootless() { | ||
// make sure cni/netavark created bridge with expected name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh and please drop cni here, we no longer support cni upstream and cni doesn't support this option
You can ignore the search failures. They are just random registry flakes. We rerun tests as needed. |
This way has a huge disadvantage: The user will not see an error when he uses a non-existent option. Another disadvantage is, that if we add more options within podman, they might collide with the names chosen by plugins. Such issues might be hard to debug. The advantage is that the usage is very nice: --network bridge:opt1=val1,opt2=val2. Alternatively, we could put this behind `opt=`, which is harder to use, but would solve all issues above: --network bridge:opt=opt1=val1,opt=opt2=val2 Signed-off-by: Michael Zimmermann <[email protected]>
828301f
to
315e741
Compare
Thanks for the review. I addressed all your comments in the most recent push. |
Code LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Luap99, M1cha 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 |
This way has a huge disadvantage: The user will not see an error when he uses a non-existent option. Another disadvantage is, that if we add more options within podman, they might collide with the names chosen by plugins. Such issues might be hard to debug.
The advantage is that the usage is very nice:
--network bridge:opt1=val1,opt2=val2
.Alternatively, we could put this behind
opt=
, which is harder to use, but would solve all issues above:--network bridge:opt=opt1=val1,opt=opt2=val2
Does this PR introduce a user-facing change?
Depends on: containers/common#2245
Required by: containers/netavark#1125