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

(cherry picked from commit 1f85692)

Conflicts: a minor conflict in server/container_create_linux.go

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Apr 22, 2020
1 parent fe61deb commit 96d772c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/container_create_linux.go
Expand Up @@ -39,6 +39,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"

type configDevice struct {
Device rspec.LinuxDevice
Resource rspec.LinuxDeviceCgroup
Expand Down Expand Up @@ -510,6 +513,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 96d772c

Please sign in to comment.