Skip to content

Commit

Permalink
handle new docker events in API 1.24
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Sep 20, 2019
1 parent 2d496b8 commit 6e8a661
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions src/Linux/mod_docker.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ extern "C" {
HSP_EV_destroy,
HSP_EV_oom,
HSP_EV_rm,
HSP_EV_attach,
HSP_EV_commit,
HSP_EV_copy,
HSP_EV_detach,
HSP_EV_exec_create,
HSP_EV_exec_detach,
HSP_EV_exec_start,
HSP_EV_export,
HSP_EV_health_status,
HSP_EV_rename,
HSP_EV_resize,
HSP_EV_top,
HSP_EV_update,
HSP_EV_NUM_CODES
} EnumHSPContainerEvent;

Expand All @@ -53,7 +66,20 @@ extern "C" {
"die",
"destroy",
"oom",
"rm"
"rm", // taken out
"attach", // added for 1.24 vvv
"commit",
"copy",
"detach",
"exec_create",
"exec_detach",
"exec_start",
"export",
"health_status",
"rename",
"resize",
"top",
"update"
};

typedef enum {
Expand Down Expand Up @@ -1213,6 +1239,10 @@ extern "C" {
&& ctname->valuestring) {
HSPVMState_DOCKER *container;
EnumHSPContainerEvent ev = containerEvent(status->valuestring);
if(ev == HSP_EV_UNKNOWN) {
myDebug(1, "unrecognized event status: %s", status->valuestring);
return;
}
EnumHSPContainerState st = HSP_CS_UNKNOWN;
switch(ev) {
case HSP_EV_create:
Expand All @@ -1236,8 +1266,23 @@ extern "C" {
st = HSP_CS_exited;
break;
case HSP_EV_destroy:
default:
st = HSP_CS_deleted;
case HSP_EV_attach:
case HSP_EV_commit:
case HSP_EV_copy:
case HSP_EV_detach:
case HSP_EV_exec_create:
case HSP_EV_exec_detach:
case HSP_EV_exec_start:
case HSP_EV_export:
case HSP_EV_health_status:
case HSP_EV_rename:
case HSP_EV_resize:
case HSP_EV_top:
case HSP_EV_update:
// leave as HSP_CS_UNKNOWN so as not to trigger a state-change below,
// but still allow for a name update.
break;
}

container = getContainer(mod, id->valuestring, (st == HSP_CS_running));
Expand All @@ -1251,7 +1296,7 @@ extern "C" {
}
container->lastEvent = ev;
if(container->state == HSP_CS_running) {
// TODO: is this name or hostname?
// note that "rename" event will get here
setContainerName(mod, container, ctname->valuestring);
if(!container->inspect_tx) {
// new entry - get meta-data
Expand Down

0 comments on commit 6e8a661

Please sign in to comment.