From af814cd39aef55b16ff90391fbc9d0bbe289159c Mon Sep 17 00:00:00 2001 From: Emily Shepherd Date: Sat, 22 Jul 2023 23:34:42 +0100 Subject: [PATCH] Add support to restart crio via the socket --- pkgs/bin/init/src/exe.c | 4 ++++ pkgs/bin/init/src/include/exe.h | 1 + pkgs/bin/init/src/include/socket.h | 2 ++ pkgs/bin/init/src/socket.c | 3 +++ 4 files changed, 10 insertions(+) diff --git a/pkgs/bin/init/src/exe.c b/pkgs/bin/init/src/exe.c index e616f96..4f7a312 100644 --- a/pkgs/bin/init/src/exe.c +++ b/pkgs/bin/init/src/exe.c @@ -103,6 +103,10 @@ void stop_kubelet(void) { kill(kubelet_pid, SIGTERM); } +void stop_container_runtime(void) { + kill(crio_pid, SIGTERM); +} + /** * Helper function which checks if the given character is an acceptable * character in a node label diff --git a/pkgs/bin/init/src/include/exe.h b/pkgs/bin/init/src/include/exe.h index 79f418e..89181a4 100644 --- a/pkgs/bin/init/src/include/exe.h +++ b/pkgs/bin/init/src/include/exe.h @@ -16,6 +16,7 @@ extern int should_restart_processes; void start_container_runtime(void); +void stop_container_runtime(void); void start_kubelet(void); void stop_kubelet(void); diff --git a/pkgs/bin/init/src/include/socket.h b/pkgs/bin/init/src/include/socket.h index 8f7d58d..de9ede8 100644 --- a/pkgs/bin/init/src/include/socket.h +++ b/pkgs/bin/init/src/include/socket.h @@ -12,10 +12,12 @@ * SHUTDOWN Request a system shutdown * CONTINUE_SHUTDOWN Continue the shutdown procedure by killing processes and umounting all file systems. * RESTART_KUBELET Requests that the kubelet should be restarted + * RESTART_CRIO Requests that the container runtime should be restarted */ #define CMD_SHUTDOWN 0x01 #define CMD_CONTINUE_SHUTDOWN 0x02 #define CMD_RESTART_KUBELET 0x03 +#define CMD_RESTART_CRIO 0x04 /** * Events send out by the system diff --git a/pkgs/bin/init/src/socket.c b/pkgs/bin/init/src/socket.c index 1b3032c..bf0f284 100644 --- a/pkgs/bin/init/src/socket.c +++ b/pkgs/bin/init/src/socket.c @@ -102,6 +102,9 @@ void client_thread(int *connection) { // loop will notice and restart it for us. stop_kubelet(); break; + case CMD_RESTART_CRIO: + stop_container_runtime(); + break; } } close(*connection);