Skip to content

Commit

Permalink
Refactor I/O and add SD_NOTIFY proxy support
Browse files Browse the repository at this point in the history
Refactored all the conn_sock functionality to be more generic. It can deal
with different types of sockets, stream vs dgram, and reuses all the same
callbacks, shutdown and async functionality.

Conmon creates a notify socket which podman bind-mounts into the container,
and passes in via the spec's environment variables.  Conmon relays the
READY=1 signal.  This is similar to what runc and crun do, but doing it in
conmon and NOT passing NOTIFY_SOCKET to the OCI runtime allows us to start
up properly without runc and crun blocking on the "start" command.

It would also be trivial to add more proxied sockets, i.e. the /dev/log
proof of concept I did would now be super easy, if we wanted to revisit that.

Signed-off-by: Joseph Gooch <[email protected]>
  • Loading branch information
goochjj committed Sep 11, 2020
1 parent dd4fc17 commit 6628524
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 102 deletions.
3 changes: 3 additions & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ char *opt_log_level = NULL;
char *opt_log_tag = NULL;
gboolean opt_sync = FALSE;
gboolean opt_no_sync_log = FALSE;
char *opt_sdnotify_socket = NULL;
GOptionEntry opt_entries[] = {
{"terminal", 't', 0, G_OPTION_ARG_NONE, &opt_terminal, "Terminal", NULL},
{"stdin", 'i', 0, G_OPTION_ARG_NONE, &opt_stdin, "Stdin", NULL},
Expand Down Expand Up @@ -94,6 +95,8 @@ GOptionEntry opt_entries[] = {
{"no-sync-log", 0, 0, G_OPTION_ARG_NONE, &opt_no_sync_log, "Do not manually call sync on logs after container shutdown", NULL},
{"sync", 0, 0, G_OPTION_ARG_NONE, &opt_sync, "Allowing caller to keep the main conmon process as its child by only forking once",
NULL},
{"sdnotify-socket", 0, 0, G_OPTION_ARG_STRING, &opt_sdnotify_socket, "Path to the host's sd-notify socket to relay messages to",
NULL},
{NULL, 0, 0, 0, NULL, NULL, NULL}};


Expand Down
1 change: 1 addition & 0 deletions src/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern char *opt_log_level;
extern char *opt_log_tag;
extern gboolean opt_no_sync_log;
extern gboolean opt_sync;
extern char *opt_sdnotify_socket;
extern GOptionEntry opt_entries[];

int initialize_cli(int argc, char *argv[]);
Expand Down
5 changes: 5 additions & 0 deletions src/conmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ int main(int argc, char *argv[])
/* before we fork, ensure our children will be reaped */
atexit(reap_children);

/* If we were passed a sd-notify socket to use, set it up now */
if (opt_sdnotify_socket) {
setup_notify_socket(opt_sdnotify_socket);
}

/* Environment variables */
sync_pipe_fd = get_pipe_fd_from_env("_OCI_SYNCPIPE");

Expand Down
Loading

0 comments on commit 6628524

Please sign in to comment.