mirror of
https://github.com/containers/podman.git
synced 2025-05-25 19:16:59 +08:00
Merge pull request #9375 from Luap99/fix-9373
Fix broken podman generate systemd --new with pods
This commit is contained in:
@ -68,7 +68,7 @@ type containerInfo struct {
|
|||||||
|
|
||||||
// If not nil, the container is part of the pod. We can use the
|
// If not nil, the container is part of the pod. We can use the
|
||||||
// podInfo to extract the relevant data.
|
// podInfo to extract the relevant data.
|
||||||
pod *podInfo
|
Pod *podInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
const containerTemplate = headerTemplate + `
|
const containerTemplate = headerTemplate + `
|
||||||
@ -215,8 +215,8 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
|
|||||||
)
|
)
|
||||||
// If the container is in a pod, make sure that the
|
// If the container is in a pod, make sure that the
|
||||||
// --pod-id-file is set correctly.
|
// --pod-id-file is set correctly.
|
||||||
if info.pod != nil {
|
if info.Pod != nil {
|
||||||
podFlags := []string{"--pod-id-file", info.pod.PodIDFile}
|
podFlags := []string{"--pod-id-file", "{{{{.Pod.PodIDFile}}}}"}
|
||||||
startCommand = append(startCommand, podFlags...)
|
startCommand = append(startCommand, podFlags...)
|
||||||
info.CreateCommand = filterPodFlags(info.CreateCommand)
|
info.CreateCommand = filterPodFlags(info.CreateCommand)
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ Environment=PODMAN_SYSTEMD_UNIT=%n
|
|||||||
Restart=always
|
Restart=always
|
||||||
TimeoutStopSec=70
|
TimeoutStopSec=70
|
||||||
ExecStartPre=/bin/rm -f %t/jadda-jadda.pid %t/jadda-jadda.ctr-id
|
ExecStartPre=/bin/rm -f %t/jadda-jadda.pid %t/jadda-jadda.ctr-id
|
||||||
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
|
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
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
||||||
PIDFile=%t/jadda-jadda.pid
|
PIDFile=%t/jadda-jadda.pid
|
||||||
@ -487,8 +487,8 @@ WantedBy=multi-user.target default.target
|
|||||||
PodmanVersion: "CI",
|
PodmanVersion: "CI",
|
||||||
CreateCommand: []string{"I'll get stripped", "run", "-d", "--name", "jadda-jadda", "--hostname", "hello-world", "awesome-image:latest", "command", "arg1", "...", "argN"},
|
CreateCommand: []string{"I'll get stripped", "run", "-d", "--name", "jadda-jadda", "--hostname", "hello-world", "awesome-image:latest", "command", "arg1", "...", "argN"},
|
||||||
EnvVariable: EnvVariable,
|
EnvVariable: EnvVariable,
|
||||||
pod: &podInfo{
|
Pod: &podInfo{
|
||||||
PodIDFile: "/tmp/pod-foobar.pod-id-file",
|
PodIDFile: "%t/pod-foobar.pod-id-file",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
goodNameNewWithPodFile,
|
goodNameNewWithPodFile,
|
||||||
|
@ -162,7 +162,7 @@ func PodUnits(pod *libpod.Pod, options entities.GenerateSystemdOptions) (map[str
|
|||||||
}
|
}
|
||||||
units[podInfo.ServiceName] = out
|
units[podInfo.ServiceName] = out
|
||||||
for _, info := range containerInfos {
|
for _, info := range containerInfos {
|
||||||
info.pod = podInfo
|
info.Pod = podInfo
|
||||||
out, err := executeContainerTemplate(info, options)
|
out, err := executeContainerTemplate(info, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user