-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Ordering of --network
flags is disregarded
#12850
Comments
Is that actually an issue, there was never a guarantee that the interface name is consistent with the ordering of the network names. That this worked before is more of an implementation detail than a feature. I don't think we should fix this but if you really need predictable interface names you can use |
This has never worked, but I think we should fix this. It's possible to re-assign the interface names as you suggested, but it is still reasonable to expect that the interfaces are added to the container in the order given. Does the solution I described seem like the best approach here? Rather than changing the existing types? |
You can already set the interface name in the |
You can do that - but still if you don't, we would expect the interface ordering on the command line to be preserved. This affects the ifindex as well. (We are running routing software in containers.) Could you please be a bit more clear about why this is a bad idea, rather than something that simply is not implemented? Generally speaking, we can infer from other command line options to |
It's not a bad idea I just don't think that guaranteeing this is worth the extra maintenance in the long run. The naming thing can be fixed easily and we could add a test to prevent regressions but this will not fix the ifindex. In the backend we use maps so if we loop over the map the ordering is not deterministic. |
It would be very useful to me. I've examined the backend implementation. All we would need to do is to have a slice containing the interface names in the correct order, and iterate over that to obtain the values from the map in the order we want. Does that sound reasonable if I prepare a PR? |
Are you talking about only the naming or also the ifindex? If you need the stable ifindex, what would be the correct order, interface names sorted ascending? |
@mheon WDYT? |
I'm talking about just adding the interfaces in the order they appear on the command line:
|
Would the ability to manually set interface names (e.g. |
This wouldn't achieve the same effect (see previous comment). Here's one example. The (The exception here is |
As I mentioned earlier, we already make command line ordering critical for other things: |
I am not sure how you want to fix this but it is not possible to keep the cli order in the backend since it is stored as a map. You could sort by the interface name but this would still not match the cli ordering if I would use Just the naming change is simple if that is enough for you. |
I suppose we could automatically add |
@mheon Yes that is easy but he also wants the ifindex to be in the same order and this depends on the order in which the interfaces are created |
Ahh. Yeah, that would be more difficult. |
In the libpod API, we already have the The documentation says that the new |
The API level doesn't matter here, we are talking about the backend. It is stored as map in the db so there is no way to keep the order. We would need to change the types and db to make this work which is not worth the effort also podman 4.0 is about to be released very soon so there is no time to change this.
Note that just looking at |
I realize it's a bit more involved than at first look, but I'd still like to figure out what a workable solution would be here looking ahead to future releases, so that we can add interfaces in command line order. To provide another example, let's say I have two |
This should be helpful for using soft routing in containers. |
A friendly reminder that this issue had no activity for 30 days. |
@Luap99 Is this still an issue? |
Yes |
A friendly reminder that this issue had no activity for 30 days. |
@Luap99 What do you think about doing something like the following patch and retaining the order that the user added the objects. |
I am not a huge fan of adding a new field for this, this will everything more complicated, this can be set by api users so we would need to check for invalid user input. |
Let discuss this on Monday with @mheon at standup. |
A friendly reminder that this issue had no activity for 30 days. |
I'm OK with fixing but IMO this is low priority. Exact way to implement still requires some discussion. |
A friendly reminder that this issue had no activity for 30 days. |
Since this was low priority and no one ever acted on it, I am going to close. Reopen if you want to work on it. |
@rhatdan Please keep this open. I still very much have a need for this. |
I agree that is a valid feature request, it is just that work for it seems rather high. |
it affects my setup, i need specific network interfaces be placed into specific bridges for multus' proper network mapping. i was confident that |
/kind bug
When creating a container, multiple CNI networks can be connected to it, using this syntax (or alternatives):
However, the ordering is disregarded when parsing the network flags. This happens because it returns the network names as keys in an unordered map. So the networks are always added to the container in alphabetical order, i.e.
eth0
will be created forcni-podman1
eth1
will be created forcni-podman2
eth2
will be created forcni-podman3
The expected behavior is that
eth0
will be created forcni-podman2
eth1
will be created forcni-podman3
eth2
will be created forcni-podman1
The most obvious way to accomplish this is to add a fourth return value from
ParseNetworkFlags()
, which is a slice containing the network names in the order they are parsed. (However, there may be other solutions.)cc: @Luap99
The text was updated successfully, but these errors were encountered: