fix(guests): keep a networked guest's resolver and order it after its bridge (task 0010)
A guest placed on a VLAN runs its own networkd, which default-enables systemd-resolved. That conflicts with the nested-container default of inheriting the host's resolv.conf, so its toplevel failed to build; keep the guest's own resolver with networking.useHostResolvConf = false. The same guest's container enslaves its veth to the VLAN bridge at start, but the container backend orders the unit only after the network is up, not after that specific bridge exists — a race the veth enslavement could lose. Order container@<name> after the br-vlan<id> device so the bridge is there first. Both were surfaced by a VM integration test that was explored and then dropped as not worth its regression cost; the task file records the call.
This commit is contained in:
26
lib.nix
26
lib.nix
@@ -139,6 +139,11 @@ let
|
||||
{
|
||||
config = lib.mkIf networked {
|
||||
networking.useNetworkd = true;
|
||||
|
||||
# networkd default-enables resolved, which owns the guest's resolv.conf.
|
||||
# The nested-container default of inheriting the host's file conflicts with that, so the guest keeps its own.
|
||||
networking.useHostResolvConf = false;
|
||||
|
||||
systemd.network.networks."20-eth0" = {
|
||||
matchConfig.Name = "eth0";
|
||||
linkConfig.MACAddress = cfg.mac;
|
||||
@@ -328,9 +333,24 @@ let
|
||||
}
|
||||
];
|
||||
|
||||
# The operator's resource caps land on the guest's own unit.
|
||||
systemd.services."container@${machineName}".serviceConfig =
|
||||
lib.mkIf (cfg.backend == "container") limitConfig;
|
||||
# The operator's resource caps land on the guest's own unit, which a
|
||||
# networked guest also orders after the bridge its veth enslaves to at
|
||||
# start, since the container backend orders the unit after the network
|
||||
# is up but not after that specific bridge existing.
|
||||
systemd.services."container@${machineName}" = lib.mkIf (cfg.backend == "container") (
|
||||
lib.mkMerge [
|
||||
{ serviceConfig = limitConfig; }
|
||||
(lib.mkIf networked (
|
||||
let
|
||||
bridgeDevice = "sys-subsystem-net-devices-${lib.replaceStrings [ "-" ] [ "\\x2d" ] (bridgeName cfg.vlan)}.device";
|
||||
in
|
||||
{
|
||||
after = [ bridgeDevice ];
|
||||
wants = [ bridgeDevice ];
|
||||
}
|
||||
))
|
||||
]
|
||||
);
|
||||
|
||||
containers.${machineName} = lib.mkIf (cfg.backend == "container") {
|
||||
autoStart = cfg.autoStart;
|
||||
|
||||
Reference in New Issue
Block a user