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

network interfaces: restore bridge slaves #26765

Closed
wants to merge 1 commit into from

Conversation

mxxz
Copy link

@mxxz mxxz commented Jun 22, 2017

I've noticed slaves not coming back up again after restarting the service. With this fix slaves are saved in a file in /run and restored again after start.

@fpletz
Copy link
Member

fpletz commented Jun 23, 2017

cc @kampfschlaefer

@kampfschlaefer
Copy link
Contributor

@fpletz @mxxz I wonder if this is the right solution.

We try to prevent the bridge from restarting by actually defining a reload. But when the restart can not be prevented, then yes, loosing all slaves that are not part of the bridge definition is part of the deal and imho expected behaviour.

I think the correct solution is to define require- and after-dependencies from the services that place additional slaves into bridge onto the bridge service itself.

So if the problem here is that containers loose their connectivity when the bridge is restarted, at first we should try to prevent the bridge from restarting and then we should make the container depend on the bridge service and therefor stop the container before the bridge is restarted and start the container again after the bridge is restarted.

Copy link
Contributor

@kampfschlaefer kampfschlaefer left a comment

Choose a reason for hiding this comment

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

In summary I would not merge this because of design issues.

@@ -263,6 +268,10 @@ let
ip link del "${n}" || true
rm -f /run/${n}.interfaces
'';
preStop = ''
# Save currently attached slaves
ip link | grep master | awk '{print $2,$9}' | grep "${n}" | cut -d ":" -f 1 > /run/${n}.slaves
Copy link
Contributor

Choose a reason for hiding this comment

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

I know there is a webpage called useless-use-of-cat. But this here is a useless use of awk and double grep.

Why not just do ip link |grep "master ${n}" |cut -d' ' f 9 and start two processes less?

@@ -232,7 +232,7 @@ let
before = [ "network-setup.service" (subsystemDevice n) ];
serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true;
path = [ pkgs.iproute ];
path = with pkgs; [ iproute gawk ];
Copy link
Contributor

Choose a reason for hiding this comment

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

see below, if you can do without awk, this is also not needed.

@@ -251,6 +251,11 @@ let
${i}
'')}" > /run/${n}.interfaces

# Enslave previously attached interfaces
[ -f /run/${n}.slaves ] && for ifname in `cat /run/${n}.slaves`; do
Copy link
Contributor

Choose a reason for hiding this comment

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

As I said in a comment on the whole pull request, I don't like the idea here. If a service (container) is depending on the bridge, the dependency should be defined so that systemd can stop and start the dependencies accordingly.

The code above this change "Save list of enslaved interfaces" is saving this services state while it is running.

What you are doing is saving state while the service is not running. Which I believe is really stuff that either should be 'saved' by the whole nix packaging/configuration thing or not need saving at all.

@0xABAB
Copy link
Contributor

0xABAB commented Jul 1, 2017

I am siding with @kampfschlaefer on this one.

@globin
Copy link
Member

globin commented Jul 4, 2017

The case where this is relevant and cannot be fixed with dependency definitions, is where interfaces are dynamically added. This happens e.g. when using KVM/libvirt and using the bridge for the VMs, we have this problem a lot and this would fix it. I cannot see a way to define any dependencies in order to fix this or any other solution currently.

@fpletz fpletz closed this Jul 18, 2017
@fpletz
Copy link
Member

fpletz commented Aug 5, 2017

@volth Because we use it but it is not a general solution for NixOS. It is a bad approach because you can't remove interfaces from bridges using the config and a rebuilt. They would be added again after the reload.

@fpletz
Copy link
Member

fpletz commented Aug 5, 2017

Your other pull request #27678 has the better solution but I haven't had the chance to test it yet. That's why the other one isn't merged yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants