diff --git a/server/container_create_linux.go b/server/container_create_linux.go index dff7fbdfa43..d2a23666a76 100644 --- a/server/container_create_linux.go +++ b/server/container_create_linux.go @@ -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 @@ -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 {