spring-cloud / spring-cloud-deployer-kubernetes

The Spring Cloud Deployer implementation for Kubernetes
Apache License 2.0
157 stars 98 forks source link

Spring Cloud Data Flow Stop Job Issue #526

Closed umutcann closed 1 year ago

umutcann commented 1 year ago

Hi,

When we use "stop execution" service for a Spring Batch application on SCDF, task status stays as RUNNING even though pod is terminated. Terminating time of pod takes 30 seconds approximately. Batch app in Pod was still processing data while terminating pod. By my research on line, When the grace period expires(default 30 seconds), Kubernetes issues a SIGKILL to any processes still running in the Pod. Then I thought that maybe it causes problem. Spring Batch couldn't receive the graceful shutdown signal in default gracePeriod and killed forcibly. Therefore Spring Batch Metadata DB Table couldn't be updated. Is there any option to increase to 'gracePeriodSeconds' over SCDF?

https://unofficial-kubernetes.readthedocs.io/en/latest/concepts/abstractions/pod-termination/

SCDF Version : 2.9.0-SNAPSHOT

umutcann commented 1 year ago

Hi,

I dig into code. I think there is no support to change gracePeriod over spring-cloud-deployer kubernetes.

When I deep down on line, I assume that it is kubernetes problem. The problem I mentioned occurs in pods with sidecar container. If sidecar shutdown before the batch application container, app is not receiving sigterm signal in graceperiod(30sec). Then app process is killed by SIGKILL command. Therefore batch status is not updated in DB.

https://banzaicloud.com/blog/k8s-sidecars/#pod-shutdown

I think we have to wait lifecycle.type enhancement.

https://github.com/kubernetes/enhancements/issues/753