Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libpod/oci_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func (r *OCIRuntime) moveConmonToCgroupAndSignal(ctr *Container, cmd *exec.Cmd,
}

logrus.Infof("Running conmon under slice %s and unitName %s", realCgroupParent, unitName)
if err := utils.RunUnderSystemdScope(cmd.Process.Pid, realCgroupParent, unitName); err != nil {
if err := utils.RunUnderSystemdScope(cmd.Process.Pid, realCgroupParent, unitName, true); err != nil {
logrus.Warnf("Failed to add conmon to systemd sandbox cgroup: %v", err)
}
} else {
Expand Down
13 changes: 11 additions & 2 deletions utils/utils_supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
package utils

import (
"syscall"

systemdDbus "github.com/coreos/go-systemd/dbus"
"github.com/godbus/dbus"
)

// RunUnderSystemdScope adds the specified pid to a systemd scope
func RunUnderSystemdScope(pid int, slice string, unitName string) error {
// RunUnderSystemdScope adds the specified pid to a systemd scope.
// If forConmon is set, timeout is increased, and stop signal is set to SIGUSR1.
func RunUnderSystemdScope(pid int, slice string, unitName string, forConmon bool) error {
var properties []systemdDbus.Property
conn, err := systemdDbus.New()
if err != nil {
Expand All @@ -18,6 +21,12 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error {
properties = append(properties, newProp("PIDs", []uint32{uint32(pid)}))
properties = append(properties, newProp("Delegate", true))
properties = append(properties, newProp("DefaultDependencies", false))
if forConmon {
// 10 minute stop timeout
var timeout uint64 = 1000000 * 60 * 10
properties = append(properties, newProp("TimeoutStopUSec", &timeout))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd the opposite here: set TimeoutStopUSec to math.MaxUint64 and also add newProp("KillSignal", syscall.SIGUSR1)) that is used internally by conmon and it won't be forwarded to the container process.

In this way we won't lose the retcode from the container.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh. I like that. Will do.

properties = append(properties, newProp("KillSignal", syscall.SIGUSR1))
}
ch := make(chan string)
_, err = conn.StartTransientUnit(unitName, "replace", properties, ch)
if err != nil {
Expand Down