mirror of
https://github.com/containers/podman
synced 2024-10-21 01:34:37 +00:00
systemd/generate: change type to notify
Change the type of units generated with --new from "forking" to "notify". This brings Podman closer to systemd and opens up Podman to a number of use cases (see #5572). Units generated without --new remain with `type=forking`. I experimented a bit with adding a `--sdnotify` flag to `podman start` but it doesn't really work well since we're competing with the default sdnotify mode set during container creation. Fixes: #5572 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
parent
b64e20a53d
commit
9ac5267598
|
@ -60,7 +60,7 @@ func filterPodFlags(command []string, argCount int) []string {
|
||||||
return processed
|
return processed
|
||||||
}
|
}
|
||||||
|
|
||||||
// filterCommonContainerFlags removes --conmon-pidfile, --cidfile and --cgroups from the specified command.
|
// filterCommonContainerFlags removes --sdnotify, --rm and --cgroups from the specified command.
|
||||||
// argCount is the number of last arguments which should not be filtered, e.g. the container entrypoint.
|
// argCount is the number of last arguments which should not be filtered, e.g. the container entrypoint.
|
||||||
func filterCommonContainerFlags(command []string, argCount int) []string {
|
func filterCommonContainerFlags(command []string, argCount int) []string {
|
||||||
processed := []string{}
|
processed := []string{}
|
||||||
|
@ -68,11 +68,14 @@ func filterCommonContainerFlags(command []string, argCount int) []string {
|
||||||
s := command[i]
|
s := command[i]
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case s == "--conmon-pidfile", s == "--cidfile", s == "--cgroups":
|
case s == "--rm":
|
||||||
|
// Boolean flags support --flag and --flag={true,false}.
|
||||||
|
continue
|
||||||
|
case s == "--sdnotify", s == "--cgroups":
|
||||||
i++
|
i++
|
||||||
continue
|
continue
|
||||||
case strings.HasPrefix(s, "--conmon-pidfile="),
|
case strings.HasPrefix(s, "--sdnotify="),
|
||||||
strings.HasPrefix(s, "--cidfile="),
|
strings.HasPrefix(s, "--rm="),
|
||||||
strings.HasPrefix(s, "--cgroups="):
|
strings.HasPrefix(s, "--cgroups="):
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,22 +93,22 @@ func TestFilterCommonContainerFlags(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"podman", "run", "--conmon-pidfile", "foo", "alpine"},
|
[]string{"podman", "run", "--conmon-pidfile", "foo", "alpine"},
|
||||||
[]string{"podman", "run", "alpine"},
|
[]string{"podman", "run", "--conmon-pidfile", "foo", "alpine"},
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"podman", "run", "--conmon-pidfile=foo", "alpine"},
|
[]string{"podman", "run", "--conmon-pidfile=foo", "alpine"},
|
||||||
[]string{"podman", "run", "alpine"},
|
[]string{"podman", "run", "--conmon-pidfile=foo", "alpine"},
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"podman", "run", "--cidfile", "foo", "alpine"},
|
[]string{"podman", "run", "--cidfile", "foo", "alpine"},
|
||||||
[]string{"podman", "run", "alpine"},
|
[]string{"podman", "run", "--cidfile", "foo", "alpine"},
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"podman", "run", "--cidfile=foo", "alpine"},
|
[]string{"podman", "run", "--cidfile=foo", "alpine"},
|
||||||
[]string{"podman", "run", "alpine"},
|
[]string{"podman", "run", "--cidfile=foo", "alpine"},
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -122,25 +122,15 @@ func TestFilterCommonContainerFlags(t *testing.T) {
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"podman", "run", "--cgroups", "foo", "--conmon-pidfile", "foo", "--cidfile", "foo", "alpine"},
|
[]string{"podman", "run", "--cgroups=foo", "--rm", "alpine"},
|
||||||
[]string{"podman", "run", "alpine"},
|
[]string{"podman", "run", "alpine"},
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"podman", "run", "--cgroups=foo", "--conmon-pidfile=foo", "--cidfile=foo", "alpine"},
|
[]string{"podman", "run", "--cgroups", "--rm=bogus", "alpine", "--cgroups", "foo", "--conmon-pidfile", "foo", "--cidfile", "foo", "--rm"},
|
||||||
[]string{"podman", "run", "alpine"},
|
[]string{"podman", "run", "alpine", "--cgroups", "foo", "--conmon-pidfile", "foo", "--cidfile", "foo", "--rm"},
|
||||||
1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
[]string{"podman", "run", "--cgroups", "foo", "--conmon-pidfile", "foo", "--cidfile", "foo", "alpine", "--cgroups", "foo", "--conmon-pidfile", "foo", "--cidfile", "foo"},
|
|
||||||
[]string{"podman", "run", "alpine", "--cgroups", "foo", "--conmon-pidfile", "foo", "--cidfile", "foo"},
|
|
||||||
7,
|
7,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
[]string{"podman", "run", "--cgroups=foo", "--conmon-pidfile=foo", "--cidfile=foo", "alpine", "--cgroups=foo", "--conmon-pidfile=foo", "--cidfile=foo"},
|
|
||||||
[]string{"podman", "run", "alpine", "--cgroups=foo", "--conmon-pidfile=foo", "--cidfile=foo"},
|
|
||||||
4,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
@ -25,6 +25,10 @@ type containerInfo struct {
|
||||||
ServiceName string
|
ServiceName string
|
||||||
// Name or ID of the container.
|
// Name or ID of the container.
|
||||||
ContainerNameOrID string
|
ContainerNameOrID string
|
||||||
|
// Type of the unit.
|
||||||
|
Type string
|
||||||
|
// NotifyAccess of the unit.
|
||||||
|
NotifyAccess string
|
||||||
// StopTimeout sets the timeout Podman waits before killing the container
|
// StopTimeout sets the timeout Podman waits before killing the container
|
||||||
// during service stop.
|
// during service stop.
|
||||||
StopTimeout uint
|
StopTimeout uint
|
||||||
|
@ -102,10 +106,19 @@ TimeoutStopSec={{{{.TimeoutStopSec}}}}
|
||||||
ExecStartPre={{{{.ExecStartPre}}}}
|
ExecStartPre={{{{.ExecStartPre}}}}
|
||||||
{{{{- end}}}}
|
{{{{- end}}}}
|
||||||
ExecStart={{{{.ExecStart}}}}
|
ExecStart={{{{.ExecStart}}}}
|
||||||
|
{{{{- if .ExecStop}}}}
|
||||||
ExecStop={{{{.ExecStop}}}}
|
ExecStop={{{{.ExecStop}}}}
|
||||||
|
{{{{- end}}}}
|
||||||
|
{{{{- if .ExecStopPost}}}}
|
||||||
ExecStopPost={{{{.ExecStopPost}}}}
|
ExecStopPost={{{{.ExecStopPost}}}}
|
||||||
|
{{{{- end}}}}
|
||||||
|
{{{{- if .PIDFile}}}}
|
||||||
PIDFile={{{{.PIDFile}}}}
|
PIDFile={{{{.PIDFile}}}}
|
||||||
Type=forking
|
{{{{- end}}}}
|
||||||
|
Type={{{{.Type}}}}
|
||||||
|
{{{{- if .NotifyAccess}}}}
|
||||||
|
NotifyAccess={{{{.NotifyAccess}}}}
|
||||||
|
{{{{- end}}}}
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -208,6 +221,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
|
||||||
info.Executable = executable
|
info.Executable = executable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info.Type = "forking"
|
||||||
info.EnvVariable = define.EnvVariable
|
info.EnvVariable = define.EnvVariable
|
||||||
info.ExecStart = "{{{{.Executable}}}} start {{{{.ContainerNameOrID}}}}"
|
info.ExecStart = "{{{{.Executable}}}} start {{{{.ContainerNameOrID}}}}"
|
||||||
info.ExecStop = "{{{{.Executable}}}} stop {{{{if (ge .StopTimeout 0)}}}}-t {{{{.StopTimeout}}}}{{{{end}}}} {{{{.ContainerNameOrID}}}}"
|
info.ExecStop = "{{{{.Executable}}}} stop {{{{if (ge .StopTimeout 0)}}}}-t {{{{.StopTimeout}}}}{{{{end}}}} {{{{.ContainerNameOrID}}}}"
|
||||||
|
@ -221,8 +235,12 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
|
||||||
// invalid `info.CreateCommand`. Hence, we're doing a best effort unit
|
// invalid `info.CreateCommand`. Hence, we're doing a best effort unit
|
||||||
// generation and don't try aiming at completeness.
|
// generation and don't try aiming at completeness.
|
||||||
if options.New {
|
if options.New {
|
||||||
info.PIDFile = "%t/" + info.ServiceName + ".pid"
|
info.Type = "notify"
|
||||||
info.ContainerIDFile = "%t/" + info.ServiceName + ".ctr-id"
|
info.NotifyAccess = "all"
|
||||||
|
info.PIDFile = ""
|
||||||
|
info.ContainerIDFile = ""
|
||||||
|
info.ExecStop = ""
|
||||||
|
info.ExecStopPost = ""
|
||||||
// The create command must at least have three arguments:
|
// The create command must at least have three arguments:
|
||||||
// /usr/bin/podman run $IMAGE
|
// /usr/bin/podman run $IMAGE
|
||||||
index := 0
|
index := 0
|
||||||
|
@ -245,9 +263,9 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
|
||||||
}
|
}
|
||||||
startCommand = append(startCommand,
|
startCommand = append(startCommand,
|
||||||
"run",
|
"run",
|
||||||
"--conmon-pidfile", "{{{{.PIDFile}}}}",
|
"--sdnotify=conmon",
|
||||||
"--cidfile", "{{{{.ContainerIDFile}}}}",
|
|
||||||
"--cgroups=no-conmon",
|
"--cgroups=no-conmon",
|
||||||
|
"--rm",
|
||||||
)
|
)
|
||||||
remainingCmd := info.CreateCommand[index:]
|
remainingCmd := info.CreateCommand[index:]
|
||||||
|
|
||||||
|
@ -336,11 +354,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
|
||||||
|
|
||||||
startCommand = append(startCommand, remainingCmd...)
|
startCommand = append(startCommand, remainingCmd...)
|
||||||
startCommand = escapeSystemdArguments(startCommand)
|
startCommand = escapeSystemdArguments(startCommand)
|
||||||
|
|
||||||
info.ExecStartPre = "/bin/rm -f {{{{.PIDFile}}}} {{{{.ContainerIDFile}}}}"
|
|
||||||
info.ExecStart = strings.Join(startCommand, " ")
|
info.ExecStart = strings.Join(startCommand, " ")
|
||||||
info.ExecStop = "{{{{.Executable}}}} {{{{if .RootFlags}}}}{{{{ .RootFlags}}}} {{{{end}}}}stop --ignore --cidfile {{{{.ContainerIDFile}}}} {{{{if (ge .StopTimeout 0)}}}}-t {{{{.StopTimeout}}}}{{{{end}}}}"
|
|
||||||
info.ExecStopPost = "{{{{.Executable}}}} {{{{if .RootFlags}}}}{{{{ .RootFlags}}}} {{{{end}}}}rm --ignore -f --cidfile {{{{.ContainerIDFile}}}}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info.TimeoutStopSec = minTimeoutStopSec + info.StopTimeout
|
info.TimeoutStopSec = minTimeoutStopSec + info.StopTimeout
|
||||||
|
|
|
@ -130,12 +130,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman container run --sdnotify=conmon --cgroups=no-conmon --rm -d --replace --name jadda-jadda --hostname hello-world awesome-image:latest command arg1 ... argN "foo=arg \"with \" space"
|
||||||
ExecStart=/usr/bin/podman container run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d --replace --name jadda-jadda --hostname hello-world awesome-image:latest command arg1 ... argN "foo=arg \"with \" space"
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman container stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman container rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -155,12 +152,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm --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 --replace -d --name jadda-jadda --hostname hello-world awesome-image:latest command arg1 ... argN
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -180,12 +174,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm --pod-id-file %t/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
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -205,12 +196,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm --replace --detach --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 --replace --detach --name jadda-jadda --hostname hello-world awesome-image:latest command arg1 ... argN
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -230,12 +218,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
Restart=always
|
Restart=always
|
||||||
TimeoutStopSec=70
|
TimeoutStopSec=70
|
||||||
ExecStartPre=/bin/rm -f %t/container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.pid %t/container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.ctr-id
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm -d awesome-image:latest
|
||||||
ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.pid --cidfile %t/container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.ctr-id --cgroups=no-conmon -d awesome-image:latest
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.ctr-id
|
|
||||||
PIDFile=%t/container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -256,14 +241,11 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
Restart=always
|
Restart=always
|
||||||
TimeoutStopSec=102
|
TimeoutStopSec=102
|
||||||
ExecStartPre=/bin/rm -f %t/jadda-jadda.pid %t/jadda-jadda.ctr-id
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm ` +
|
||||||
ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon ` +
|
|
||||||
detachparam +
|
detachparam +
|
||||||
` awesome-image:latest
|
` awesome-image:latest
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 42
|
Type=notify
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
NotifyAccess=all
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -285,12 +267,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
Restart=always
|
Restart=always
|
||||||
TimeoutStopSec=102
|
TimeoutStopSec=102
|
||||||
ExecStartPre=/bin/rm -f %t/jadda-jadda.pid %t/jadda-jadda.ctr-id
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm -d --replace --name test -p 80:80 awesome-image:latest somecmd --detach=false
|
||||||
ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d --replace --name test -p 80:80 awesome-image:latest somecmd --detach=false
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 42
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -310,12 +289,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
Restart=always
|
Restart=always
|
||||||
TimeoutStopSec=102
|
TimeoutStopSec=102
|
||||||
ExecStartPre=/bin/rm -f %t/jadda-jadda.pid %t/jadda-jadda.ctr-id
|
ExecStart=/usr/bin/podman --events-backend none --runroot /root run --sdnotify=conmon --cgroups=no-conmon --rm -d awesome-image:latest
|
||||||
ExecStart=/usr/bin/podman --events-backend none --runroot /root run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d awesome-image:latest
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman --events-backend none --runroot /root stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 42
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman --events-backend none --runroot /root rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -335,12 +311,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman container run --sdnotify=conmon --cgroups=no-conmon --rm -d awesome-image:latest
|
||||||
ExecStart=/usr/bin/podman container run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d awesome-image:latest
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman container stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman container rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -360,12 +333,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm -d --replace --name test --log-driver=journald --log-opt=tag={{.Name}} awesome-image:latest
|
||||||
ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d --replace --name test --log-driver=journald --log-opt=tag={{.Name}} awesome-image:latest
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -385,12 +355,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm -d --replace --name test awesome-image:latest sh -c "kill $$$$ && echo %%\\"
|
||||||
ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d --replace --name test awesome-image:latest sh -c "kill $$$$ && echo %%\\"
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -410,12 +377,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm -d --conmon-pidfile=foo --cidfile=foo awesome-image:latest podman run --cgroups=foo --conmon-pidfile=foo --cidfile=foo alpine
|
||||||
ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d awesome-image:latest podman run --cgroups=foo --conmon-pidfile=foo --cidfile=foo alpine
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -435,12 +399,9 @@ RequiresMountsFor=/var/run/containers/storage
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
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
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm --pod-id-file %t/pod-foobar.pod-id-file -d --conmon-pidfile=foo --cidfile=foo awesome-image:latest podman run --cgroups=foo --conmon-pidfile=foo --cidfile=foo --pod-id-file /tmp/pod-foobar.pod-id-file alpine
|
||||||
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 -d awesome-image:latest podman run --cgroups=foo --conmon-pidfile=foo --cidfile=foo --pod-id-file /tmp/pod-foobar.pod-id-file alpine
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -461,12 +422,9 @@ Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
Environment=FOO=abc "BAR=my test" USER=%%a
|
Environment=FOO=abc "BAR=my test" USER=%%a
|
||||||
Restart=always
|
Restart=always
|
||||||
TimeoutStopSec=70
|
TimeoutStopSec=70
|
||||||
ExecStartPre=/bin/rm -f %t/jadda-jadda.pid %t/jadda-jadda.ctr-id
|
ExecStart=/usr/bin/podman run --sdnotify=conmon --cgroups=no-conmon --rm -d --env FOO --env=BAR --env=MYENV=2 -e USER awesome-image:latest
|
||||||
ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d --env FOO --env=BAR --env=MYENV=2 -e USER awesome-image:latest
|
Type=notify
|
||||||
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10
|
NotifyAccess=all
|
||||||
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id
|
|
||||||
PIDFile=%t/jadda-jadda.pid
|
|
||||||
Type=forking
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target default.target
|
WantedBy=multi-user.target default.target
|
||||||
|
@ -929,10 +887,10 @@ WantedBy=multi-user.target default.target
|
||||||
}
|
}
|
||||||
got, err := executeContainerTemplate(&test.info, opts)
|
got, err := executeContainerTemplate(&test.info, opts)
|
||||||
if (err != nil) != test.wantErr {
|
if (err != nil) != test.wantErr {
|
||||||
t.Errorf("CreateContainerSystemdUnit() error = \n%v, wantErr \n%v", err, test.wantErr)
|
t.Errorf("CreateContainerSystemdUnit() %s error = \n%v, wantErr \n%v", test.name, err, test.wantErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.Equal(t, test.want, got)
|
assert.Equal(t, test.want, got, test.name)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,6 @@ var _ = Describe("Podman generate systemd", func() {
|
||||||
// Grepping the output (in addition to unit tests)
|
// Grepping the output (in addition to unit tests)
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("# container-foo.service"))
|
Expect(session.OutputToString()).To(ContainSubstring("# container-foo.service"))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring(" --replace "))
|
Expect(session.OutputToString()).To(ContainSubstring(" --replace "))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring(" stop --ignore --cidfile %t/container-foo.ctr-id -t 42"))
|
|
||||||
if !IsRemote() {
|
if !IsRemote() {
|
||||||
// The podman commands in the unit should contain the root flags if generate systemd --new is used
|
// The podman commands in the unit should contain the root flags if generate systemd --new is used
|
||||||
Expect(session.OutputToString()).To(ContainSubstring(" --runroot"))
|
Expect(session.OutputToString()).To(ContainSubstring(" --runroot"))
|
||||||
|
@ -234,7 +233,6 @@ var _ = Describe("Podman generate systemd", func() {
|
||||||
// Grepping the output (in addition to unit tests)
|
// Grepping the output (in addition to unit tests)
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("# container-foo.service"))
|
Expect(session.OutputToString()).To(ContainSubstring("# container-foo.service"))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring(" --replace "))
|
Expect(session.OutputToString()).To(ContainSubstring(" --replace "))
|
||||||
Expect(session.OutputToString()).To(ContainSubstring(" stop --ignore --cidfile %t/container-foo.ctr-id -t 42"))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman generate systemd --new without explicit detaching param", func() {
|
It("podman generate systemd --new without explicit detaching param", func() {
|
||||||
|
@ -247,7 +245,7 @@ var _ = Describe("Podman generate systemd", func() {
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
// Grepping the output (in addition to unit tests)
|
// Grepping the output (in addition to unit tests)
|
||||||
Expect(session.OutputToString()).To(ContainSubstring("--cgroups=no-conmon -d"))
|
Expect(session.OutputToString()).To(ContainSubstring(" -d "))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman generate systemd --new with explicit detaching param in middle", func() {
|
It("podman generate systemd --new with explicit detaching param in middle", func() {
|
||||||
|
|
Loading…
Reference in a new issue