Commit 186c6b7b authored by David Johnson's avatar David Johnson

Fix docker vnode rebuilds; return supporting image path info from tmcd.

Docker vnodes require the full image path anytime the vnode is created,
even if the image in question already exists on the vhost.  This is
because emulab custom docker images are fully-qualified with their
hosting private registry, so we need that detail even if we're not
re-pulling the image; i.e., if the vnode gets destroyed and recreated
after its initial reload.
parent 1f5ff983
...@@ -2835,11 +2835,17 @@ sub vnodeCreate($$$$) ...@@ -2835,11 +2835,17 @@ sub vnodeCreate($$$$)
chomp($pass); chomp($pass);
close(FD); close(FD);
print "raref:" . Dumper($raref) . "\n"; if (exists($raref->{"PATH"}) && $raref->{"PATH"}) {
if (!exists($raref->{"PATH"}) || !$raref->{"PATH"}) { $imagename = $raref->{"PATH"};
fatal("reload specified, but not external image, and no image PATH!"); }
elsif (exists($vnconfig->{"config"}->{'IMAGEPATH'})
&& $vnconfig->{"config"}->{'IMAGEPATH'}) {
$imagename = $vnconfig->{"config"}->{'IMAGEPATH'};
}
else {
fatal("reload or image specified, but not external image," .
" and no image PATH nor jailconfig IMAGEPATH!");
} }
$imagename = $raref->{"PATH"};
} }
else { else {
$imagename = $defaultImage{'name'}; $imagename = $defaultImage{'name'};
......
...@@ -185,6 +185,7 @@ typedef struct { ...@@ -185,6 +185,7 @@ typedef struct {
char gid[TBDB_FLEN_GID]; char gid[TBDB_FLEN_GID];
char name[TBDB_FLEN_IMAGENAME]; char name[TBDB_FLEN_IMAGENAME];
char version[11]; /* Max size of a 32-bit int in string form. */ char version[11]; /* Max size of a 32-bit int in string form. */
char *path; /* A dynamically-allocated path string, if relevant. */
} imstrings_t; } imstrings_t;
int debug = 0; int debug = 0;
...@@ -298,6 +299,7 @@ static int checkdbredirect(tmcdreq_t *); ...@@ -298,6 +299,7 @@ static int checkdbredirect(tmcdreq_t *);
static int sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd, static int sendstoreconf(int sock, int tcp, tmcdreq_t *reqp, char *bscmd,
char *vname, int dopersist, char *localproto); char *vname, int dopersist, char *localproto);
static int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings); static int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings);
static void free_imagestrings_content(imstrings_t *imstrings);
#ifdef EVENTSYS #ifdef EVENTSYS
int myevent_send(address_tuple_t address); int myevent_send(address_tuple_t address);
...@@ -8734,6 +8736,12 @@ COMMAND_PROTOTYPE(dojailconfig) ...@@ -8734,6 +8736,12 @@ COMMAND_PROTOTYPE(dojailconfig)
imstrings.version); imstrings.version);
} }
bufp += OUTPUT(bufp, ebufp - bufp, "\"\n"); bufp += OUTPUT(bufp, ebufp - bufp, "\"\n");
if (imstrings.path) {
bufp += OUTPUT(bufp, ebufp - bufp,
"IMAGEPATH=\"%s\"\n",
imstrings.path);
}
free_imagestrings_content(&imstrings);
} }
client_writeback(sock, buf, strlen(buf), tcp); client_writeback(sock, buf, strlen(buf), tcp);
return 0; return 0;
...@@ -8750,6 +8758,7 @@ COMMAND_PROTOTYPE(doimageid) ...@@ -8750,6 +8758,7 @@ COMMAND_PROTOTYPE(doimageid)
imstrings.pid, imstrings.gid, imstrings.pid, imstrings.gid,
imstrings.name, imstrings.version); imstrings.name, imstrings.version);
client_writeback(sock, buf, strlen(buf), tcp); client_writeback(sock, buf, strlen(buf), tcp);
free_imagestrings_content(&imstrings);
} }
return 0; return 0;
...@@ -8768,7 +8777,8 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings) ...@@ -8768,7 +8777,8 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings)
} }
/* We want data on the default OS set for this node. */ /* We want data on the default OS set for this node. */
res = mydb_query("select p.pid,g.gid,iv.imagename,iv.version " res = mydb_query("select p.pid,g.gid,iv.imagename,iv.version,"
" iv.format,iv.path "
" from nodes as n " " from nodes as n "
"left join `partitions` as pa on " "left join `partitions` as pa on "
" pa.node_id=n.node_id and " " pa.node_id=n.node_id and "
...@@ -8779,7 +8789,7 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings) ...@@ -8779,7 +8789,7 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings)
"left join projects as p on iv.pid_idx=p.pid_idx " "left join projects as p on iv.pid_idx=p.pid_idx "
"left join groups as g on iv.gid_idx=g.gid_idx " "left join groups as g on iv.gid_idx=g.gid_idx "
"where n.node_id='%s'", "where n.node_id='%s'",
4, reqp->nodeid); 6, reqp->nodeid);
if (!res) { if (!res) {
error("get_imagestrings: %s: DB Error getting image info!\n", error("get_imagestrings: %s: DB Error getting image info!\n",
...@@ -8790,7 +8800,7 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings) ...@@ -8790,7 +8800,7 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings)
/* Fill out the imstrings struct passed in with info from the DB. */ /* Fill out the imstrings struct passed in with info from the DB. */
if (mysql_num_rows(res)) { if (mysql_num_rows(res)) {
row = mysql_fetch_row(res); row = mysql_fetch_row(res);
if (!row[0] || !row[1] || !row[3] || !row[4]) { if (!row[0] || !row[1] || !row[2] || !row[3]) {
error("get_imagestrings: %s: invalid data returned " error("get_imagestrings: %s: invalid data returned "
"from DB query!\n", reqp->nodeid); "from DB query!\n", reqp->nodeid);
return 1; return 1;
...@@ -8799,12 +8809,23 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings) ...@@ -8799,12 +8809,23 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings)
strncpy(imstrings->gid, row[1], sizeof(imstrings->gid)); strncpy(imstrings->gid, row[1], sizeof(imstrings->gid));
strncpy(imstrings->name, row[2], sizeof(imstrings->name)); strncpy(imstrings->name, row[2], sizeof(imstrings->name));
strncpy(imstrings->version, row[3], sizeof(imstrings->version)); strncpy(imstrings->version, row[3], sizeof(imstrings->version));
if (row[4] && row[4][0] && strcmp("docker",row[4]) == 0
&& row[5] && row[5][0]) {
imstrings->path = strdup(row[5]);
}
else {
imstrings->path = NULL;
}
if (debug) if (debug) {
info("get_imagestrings: %s: PID=%s GID=%s NAME=%s " info("get_imagestrings: %s: PID=%s GID=%s NAME=%s "
"VERSION=%s", "VERSION=%s",
reqp->nodeid, imstrings->pid, imstrings->gid, reqp->nodeid, imstrings->pid, imstrings->gid,
imstrings->name, imstrings->version); imstrings->name, imstrings->version);
if (imstrings->path)
info("get_imagestrings: %s: IMAGEPATH=%s",
reqp->nodeid, imstrings->path);
}
retval = 0; retval = 0;
} else { } else {
error("get_imagestrings: %s: No info returned for image " error("get_imagestrings: %s: No info returned for image "
...@@ -8816,6 +8837,18 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings) ...@@ -8816,6 +8837,18 @@ int get_imagestrings(tmcdreq_t *reqp, imstrings_t *imstrings)
return retval; return retval;
} }
void free_imagestrings_content(imstrings_t *imstrings)
{
/* Sanity. */
if (imstrings == NULL) {
error("free_imagestrings_content: NULL pointer argument!\n");
}
if (imstrings->path) {
free(imstrings->path);
imstrings->path = NULL;
}
}
/* /*
* Return the config for a virtual Plab node. * Return the config for a virtual Plab node.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment