Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: 容器环境,停止微服务没有触发shutdown hook #1251

Closed
wangyu096 opened this issue Sep 5, 2022 · 1 comment
Closed

bugfix: 容器环境,停止微服务没有触发shutdown hook #1251

wangyu096 opened this issue Sep 5, 2022 · 1 comment
Assignees
Labels
kind/bug 程序故障Bug,漏洞 stage/prod Production environment in tencent has been deploy stage/test Test environment in tencent has been deploy stage/uat UAT environment in tencent has been deploy

Comments

@wangyu096
Copy link
Collaborator

Version / Branch / tag

3.5.x/3.6.x

出了什么问题?(What Happened?)

容器环境,停止微服务没有触发shutdown hook

如何复现?(How to reproduce?)

容器环境,停止pod必现

预期结果(What you expect?)

容器环境,停止微服务需要触发shutdown hook

@wangyu096 wangyu096 added the kind/bug 程序故障Bug,漏洞 label Sep 5, 2022
@wangyu096 wangyu096 self-assigned this Sep 5, 2022
@wangyu096
Copy link
Collaborator Author

  • 原因分析
  1. k8s停止pod,TERM信号是发给pid=1的进程

image

2. job启动微服务是使用startup.sh脚本拉起java进程,所以java进程并不是pid=1 ``` # bachend.DockerFile ENTRYPOINT ["./tini", "--", "./startup.sh"]

startup.sh

java -server
$OTEL_OPTS
-Dfile.encoding=UTF-8
-Djob.log.dir=$BK_JOB_LOG_BASE_DIR
-Xloggc:$BK_JOB_LOG_DIR/gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=12
-XX:GCLogFileSize=1G
-XX:+PrintTenuringDistribution
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=heap.hprof
-XX:ErrorFile=$BK_JOB_LOG_DIR/error_sys.log
-Dspring.profiles.active=$BK_JOB_PROFILE
$BK_JOB_JVM_OPTION
-jar /data/job/exec/$BK_JOB_JAR

3. 进入pod内部,可以看到pid=1的进程为startup.sh脚本
<img width="1642" alt="企业微信截图_97016fe7-af5f-40db-ab0a-6ba65560063b" src="https://user-images.githubusercontent.com/28581184/188360911-aeec1464-e6e8-46b5-b0e9-b3c9acd9148c.png">

jsonwan added a commit that referenced this issue Sep 5, 2022
bugfix: 容器环境,停止微服务没有触发shutdown hook #1251
wangyu096 added a commit that referenced this issue Sep 5, 2022
bugfix: 容器环境,停止微服务没有触发shutdown hook #1251
@bkjob-bot bkjob-bot added the stage/test Test environment in tencent has been deploy label Sep 8, 2022
@bkjob-bot bkjob-bot added stage/prod Production environment in tencent has been deploy stage/uat UAT environment in tencent has been deploy labels Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug 程序故障Bug,漏洞 stage/prod Production environment in tencent has been deploy stage/test Test environment in tencent has been deploy stage/uat UAT environment in tencent has been deploy
Projects
None yet
Development

No branches or pull requests

2 participants