Skip to content

Commit

Permalink
Add support to restart crio via the socket
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyShepherd committed Jul 22, 2023
1 parent 3b5d290 commit af814cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkgs/bin/init/src/exe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkgs/bin/init/src/include/exe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions pkgs/bin/init/src/include/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkgs/bin/init/src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit af814cd

Please sign in to comment.