open-horizon / anax

Horizon agent control system
https://open-horizon.github.io/docs/anax/docs/
Apache License 2.0
70 stars 99 forks source link

Add signal handling to agbot_start.sh and css_start.sh #4039

Open lbergesio opened 2 months ago

lbergesio commented 2 months ago

Description

When run in a container anax is run via a shell script that does not handle SIGTERM and hence when the container is stopped this signal does not arrive to the binary for graceful exit. A consequence of this is when run via docker compose up, docker compose down will have to wait until the timeout in order to kill the process.

The same happens for the ccs-api.

This change adds proper SIGTERM handling to agbot_start.sh and css_start.sh.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Running the container image with docker compose up and checking the output of docker compose down: Running docker compose down -t 20s without this change :

✔ Container agbot                              Removed                       21.9s
✔ Container css-api                            Removed                       20.4s

With this change:

✔ Container agbot                              Removed                       3.4s
✔ Container css-api                            Removed                       4.2s

Checklist:

lbergesio commented 2 months ago

Not sure why the ci failed, any hint with that would be appreciated

lbergesio commented 2 months ago

Hi @LiilyZhang is anything preventing this to be merge I should address?

LiilyZhang commented 2 months ago

we are still investigating how to test this in openshift environment @lbergesio

lbergesio commented 2 months ago

we are still investigating how to test this in openshift environment @lbergesio

I think kubelet works with the pod the same way than docker with the container: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination I would say just run the pod, get in, check the process is running. Destroy the pod, this will send sigterm to the pod process?

lbergesio commented 2 weeks ago

Hi! any update on this? Thanks