Skip to content

Commit

Permalink
Merge pull request #16971 from ygalblum/quadlet-network-depend
Browse files Browse the repository at this point in the history
Quadlet Network - Fix the name of the required network service
  • Loading branch information
openshift-merge-robot authored Jan 3, 2023
2 parents 66ec8aa + a061d79 commit a4edd0d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,13 +821,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)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/quadlet/network.quadlet.container
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/quadlet/network.quadlet.kube
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit a4edd0d

Please sign in to comment.