Skip to content

Commit ac9a048

Browse files
Merge pull request #9375 from Luap99/fix-9373
Fix broken podman generate systemd --new with pods
2 parents df8ba7f + bf083c1 commit ac9a048

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pkg/systemd/generate/containers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type containerInfo struct {
6868

6969
// If not nil, the container is part of the pod. We can use the
7070
// podInfo to extract the relevant data.
71-
pod *podInfo
71+
Pod *podInfo
7272
}
7373

7474
const containerTemplate = headerTemplate + `
@@ -215,8 +215,8 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
215215
)
216216
// If the container is in a pod, make sure that the
217217
// --pod-id-file is set correctly.
218-
if info.pod != nil {
219-
podFlags := []string{"--pod-id-file", info.pod.PodIDFile}
218+
if info.Pod != nil {
219+
podFlags := []string{"--pod-id-file", "{{{{.Pod.PodIDFile}}}}"}
220220
startCommand = append(startCommand, podFlags...)
221221
info.CreateCommand = filterPodFlags(info.CreateCommand)
222222
}

pkg/systemd/generate/containers_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Environment=PODMAN_SYSTEMD_UNIT=%n
170170
Restart=always
171171
TimeoutStopSec=70
172172
ExecStartPre=/bin/rm -f %t/jadda-jadda.pid %t/jadda-jadda.ctr-id
173-
ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon --pod-id-file /tmp/pod-foobar.pod-id-file --replace -d --name jadda-jadda --hostname hello-world awesome-image:latest command arg1 ... argN
173+
ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon --pod-id-file %t/pod-foobar.pod-id-file --replace -d --name jadda-jadda --hostname hello-world awesome-image:latest command arg1 ... argN
174174
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
175175
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
176176
PIDFile=%t/jadda-jadda.pid
@@ -487,8 +487,8 @@ WantedBy=multi-user.target default.target
487487
PodmanVersion: "CI",
488488
CreateCommand: []string{"I'll get stripped", "run", "-d", "--name", "jadda-jadda", "--hostname", "hello-world", "awesome-image:latest", "command", "arg1", "...", "argN"},
489489
EnvVariable: EnvVariable,
490-
pod: &podInfo{
491-
PodIDFile: "/tmp/pod-foobar.pod-id-file",
490+
Pod: &podInfo{
491+
PodIDFile: "%t/pod-foobar.pod-id-file",
492492
},
493493
},
494494
goodNameNewWithPodFile,

pkg/systemd/generate/pods.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func PodUnits(pod *libpod.Pod, options entities.GenerateSystemdOptions) (map[str
162162
}
163163
units[podInfo.ServiceName] = out
164164
for _, info := range containerInfos {
165-
info.pod = podInfo
165+
info.Pod = podInfo
166166
out, err := executeContainerTemplate(info, options)
167167
if err != nil {
168168
return nil, err

0 commit comments

Comments
 (0)