mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Merge pull request #117393 from HirazawaUi/use-wait-replace-loop
Use wait to avoid blocking the SIGTERM handler
This commit is contained in:
commit
e28866e976
@ -155,12 +155,17 @@ var _ = SIGDescribe("Deleted pods handling [NodeConformance]", func() {
|
|||||||
Image: imageutils.GetE2EImage(imageutils.BusyBox),
|
Image: imageutils.GetE2EImage(imageutils.BusyBox),
|
||||||
Command: []string{"sh", "-c"},
|
Command: []string{"sh", "-c"},
|
||||||
Args: []string{`
|
Args: []string{`
|
||||||
|
sleep 9999999 &
|
||||||
|
PID=$!
|
||||||
_term() {
|
_term() {
|
||||||
|
kill $PID
|
||||||
echo "Caught SIGTERM signal!"
|
echo "Caught SIGTERM signal!"
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trap _term SIGTERM
|
trap _term SIGTERM
|
||||||
while true; do sleep 5; done
|
wait $PID
|
||||||
|
|
||||||
|
exit 0
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -560,6 +560,11 @@ func getPriorityClass(name string, value int32) *schedulingv1.PriorityClass {
|
|||||||
}
|
}
|
||||||
return priority
|
return priority
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getGracePeriodOverrideTestPod returns a new Pod object containing a container
|
||||||
|
// runs a shell script, hangs the process until a SIGTERM signal is received.
|
||||||
|
// The script waits for $PID to ensure that the process does not exist.
|
||||||
|
// If priorityClassName is scheduling.SystemNodeCritical, the Pod is marked as critical and a comment is added.
|
||||||
func getGracePeriodOverrideTestPod(name string, node string, gracePeriod int64, priorityClassName string) *v1.Pod {
|
func getGracePeriodOverrideTestPod(name string, node string, gracePeriod int64, priorityClassName string) *v1.Pod {
|
||||||
pod := &v1.Pod{
|
pod := &v1.Pod{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
@ -576,12 +581,15 @@ func getGracePeriodOverrideTestPod(name string, node string, gracePeriod int64,
|
|||||||
Image: busyboxImage,
|
Image: busyboxImage,
|
||||||
Command: []string{"sh", "-c"},
|
Command: []string{"sh", "-c"},
|
||||||
Args: []string{`
|
Args: []string{`
|
||||||
|
sleep 9999999 &
|
||||||
|
PID=$!
|
||||||
_term() {
|
_term() {
|
||||||
echo "Caught SIGTERM signal!"
|
echo "Caught SIGTERM signal!"
|
||||||
while true; do sleep 5; done
|
wait $PID
|
||||||
}
|
}
|
||||||
|
|
||||||
trap _term SIGTERM
|
trap _term SIGTERM
|
||||||
while true; do sleep 5; done
|
wait $PID
|
||||||
`},
|
`},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user