Skip to content

Commit

Permalink
CreateContainer: pass TerminationGracePeriod
Browse files Browse the repository at this point in the history
Enable passing of kubernetes termination grace period
down to OCI runtime, as an annotation for systemd.

This builds on top of

* opencontainers/runc#2224
  (or containers/crun#266)

and is part of the fix for

* kubernetes/kubernetes#77873

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Feb 26, 2020
1 parent 878375f commit 1f85692
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/container_create_linux.go
Expand Up @@ -41,6 +41,9 @@ import (
// A lower value would result in the container failing to start.
const minMemoryLimit = 12582912

// Copied from k8s.io/kubernetes/pkg/kubelet/kuberuntime/labels.go
const podTerminationGracePeriodLabel = "io.kubernetes.pod.terminationGracePeriod"

var (
_cgroupv2HasHugetlbOnce sync.Once
_cgroupv2HasHugetlb bool
Expand Down Expand Up @@ -534,6 +537,15 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID, contai
}
specgen.SetLinuxCgroupsPath(cgPath)

if t, ok := kubeAnnotations[podTerminationGracePeriodLabel]; ok {
// currently only supported by systemd, see
// https://github.com/opencontainers/runc/pull/2224
if useSystemd {
specgen.AddAnnotation("org.systemd.property.TimeoutStopUSec",
"uint64 "+t+"000000") // sec to usec
}
}

if privileged {
specgen.SetupPrivileged(true)
} else {
Expand Down

0 comments on commit 1f85692

Please sign in to comment.