From a061d793df7091db9959e471d904f2976fb31892 Mon Sep 17 00:00:00 2001 From: Ygal Blum Date: Mon, 2 Jan 2023 14:52:44 +0200 Subject: [PATCH] Quadlet Network - Fix the name of the required network service The name of the network service does not start with systemd only the podman network name Signed-off-by: Ygal Blum --- pkg/systemd/quadlet/quadlet.go | 8 ++++---- test/e2e/quadlet/network.quadlet.container | 4 ++-- test/e2e/quadlet/network.quadlet.kube | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index 881070a32d..676d44b2ba 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -811,13 +811,13 @@ func addNetworks(quadletUnitFile *parser.UnitFile, groupName string, serviceUnit networks := quadletUnitFile.LookupAll(groupName, KeyNetwork) for _, network := range networks { if len(network) > 0 { - networkName, options, found := strings.Cut(network, ":") - if strings.HasSuffix(networkName, ".network") { + quadletNetworkName, options, found := strings.Cut(network, ":") + if strings.HasSuffix(quadletNetworkName, ".network") { // the podman network name is systemd-$name - networkName = replaceExtension(networkName, "", "systemd-", "") + networkName := replaceExtension(quadletNetworkName, "", "systemd-", "") // the systemd unit name is $name-network.service - networkServiceName := replaceExtension(networkName, ".service", "", "-network") + networkServiceName := replaceExtension(quadletNetworkName, ".service", "", "-network") serviceUnitFile.Add(UnitGroup, "Requires", networkServiceName) serviceUnitFile.Add(UnitGroup, "After", networkServiceName) diff --git a/test/e2e/quadlet/network.quadlet.container b/test/e2e/quadlet/network.quadlet.container index 5b15ca6810..27193617f2 100644 --- a/test/e2e/quadlet/network.quadlet.container +++ b/test/e2e/quadlet/network.quadlet.container @@ -1,6 +1,6 @@ ## assert-podman-args "--network=systemd-basic" -## assert-key-is "Unit" "Requires" "systemd-basic-network.service" -## assert-key-is "Unit" "After" "systemd-basic-network.service" +## assert-key-is "Unit" "Requires" "basic-network.service" +## assert-key-is "Unit" "After" "basic-network.service" [Container] Image=localhost/imagename diff --git a/test/e2e/quadlet/network.quadlet.kube b/test/e2e/quadlet/network.quadlet.kube index a24d5e3544..a69479bbb9 100644 --- a/test/e2e/quadlet/network.quadlet.kube +++ b/test/e2e/quadlet/network.quadlet.kube @@ -1,6 +1,6 @@ ## assert-podman-args "--network=systemd-basic" -## assert-key-is "Unit" "Requires" "systemd-basic-network.service" -## assert-key-is "Unit" "After" "systemd-basic-network.service" +## assert-key-is "Unit" "Requires" "basic-network.service" +## assert-key-is "Unit" "After" "basic-network.service" [Kube]