Skip to content

Commit 2366d01

Browse files
author
Mladen Rusev
committed
try sending sigquit signal
1 parent c304321 commit 2366d01

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

hack/e2e/test.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,26 @@ getCertificate() {
251251
for ((i=0;;i++)); do if getCertificate; then exit 0; fi; sleep 30; done | timeout -v -- 5m cat
252252

253253
export AGENT_POD_NAME=$(kubectl get pods -n venafi -l app.kubernetes.io/name=venafi-kubernetes-agent -o jsonpath="{.items[0].metadata.name}")
254-
echo "Scaling down agent deployment to kill pod and flush coverage to the PVC..."
254+
255+
echo "Sending SIGQUIT to agent pod '${AGENT_POD_NAME}' to trigger graceful shutdown and flush coverage..."
256+
# Use kubectl debug to attach a busybox container to the running pod.
257+
# --target specifies the container to share the process space with.
258+
# --share-processes allows our new container to see and signal the agent process.
259+
# We then run 'kill -s QUIT 1' to signal PID 1 (the agent) to quit gracefully.
260+
kubectl debug -q -n venafi "${AGENT_POD_NAME}" \
261+
--image=busybox:1.36 \
262+
--target=venafi-kubernetes-agent \
263+
--share-processes \
264+
-- sh -c 'kill -s QUIT 1'
265+
266+
echo "Waiting for agent pod '${AGENT_POD_NAME}' to terminate gracefully..."
267+
# The pod will now terminate because its main process is exiting.
268+
# We wait for Kubernetes to recognize this and delete the pod object.
269+
kubectl wait --for=delete pod/${AGENT_POD_NAME} -n venafi --timeout=90s
270+
271+
echo "Scaling down deployment to prevent pod from restarting..."
272+
# Now that the pod is gone and coverage is flushed, we scale the deployment
273+
# to ensure the ReplicaSet controller doesn't create a new one.
255274
kubectl scale deployment venafi-kubernetes-agent -n venafi --replicas=0
256275
echo "Waiting for agent pod '${AGENT_POD_NAME}' to terminate as a result of the scale-down..."
257276
kubectl wait --for=delete pod/${AGENT_POD_NAME} -n venafi --timeout=90s

0 commit comments

Comments
 (0)