Handle TERM signal to reduce pod terminating time.

This commit is contained in:
Yecheng Fu 2018-05-18 16:55:00 +08:00
parent 09c9ecd3fd
commit 55bc8d74a2
3 changed files with 4 additions and 4 deletions

View File

@ -231,7 +231,7 @@ func CreateDeployment(client clientset.Interface, replicas int32, podLabels map[
// name. A slice of BASH commands can be supplied as args to be run by the pod
func MakeDeployment(replicas int32, podLabels map[string]string, nodeSelector map[string]string, namespace string, pvclaims []*v1.PersistentVolumeClaim, isPrivileged bool, command string) *extensions.Deployment {
if len(command) == 0 {
command = "while true; do sleep 1; done"
command = "trap exit TERM; while true; do sleep 1; done"
}
zero := int64(0)
deploymentName := "deployment-" + string(uuid.NewUUID())

View File

@ -815,7 +815,7 @@ func MakeWritePod(ns string, pvc *v1.PersistentVolumeClaim) *v1.Pod {
// name. A slice of BASH commands can be supplied as args to be run by the pod
func MakePod(ns string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim, isPrivileged bool, command string) *v1.Pod {
if len(command) == 0 {
command = "while true; do sleep 1; done"
command = "trap exit TERM; while true; do sleep 1; done"
}
podSpec := &v1.Pod{
TypeMeta: metav1.TypeMeta{
@ -902,7 +902,7 @@ func MakeNginxPod(ns string, nodeSelector map[string]string, pvclaims []*v1.Pers
// SELinux testing requires to pass HostIPC and HostPID as booleansi arguments.
func MakeSecPod(ns string, pvclaims []*v1.PersistentVolumeClaim, isPrivileged bool, command string, hostIPC bool, hostPID bool, seLinuxLabel *v1.SELinuxOptions, fsGroup *int64) *v1.Pod {
if len(command) == 0 {
command = "while true; do sleep 1; done"
command = "trap exit TERM; while true; do sleep 1; done"
}
podName := "security-context-" + string(uuid.NewUUID())
if fsGroup == nil {

View File

@ -3472,7 +3472,7 @@ func newExecPodSpec(ns, generateName string) *v1.Pod {
{
Name: "exec",
Image: BusyBoxImage,
Command: []string{"sh", "-c", "while true; do sleep 5; done"},
Command: []string{"sh", "-c", "trap exit TERM; while true; do sleep 5; done"},
},
},
},