Commit 969f9237 authored by Mike Hibler's avatar Mike Hibler

A variety of tweaks to make up/download of images on vnodes work.

In the master server, recognize "sharedhost" as a valid proxy node so
that shared vnode host nodes can upload and download images on behalf
of hosted vnodes that are not in the same experiment.

Add "-P <node-i-am-a-proxy-for>" options to frisbee and frisupload clients
allowing them to request images on behalf of other nodes. Previously,
proxying was only really supported in nested instances of the master server.

Make sure that such proxying works when a shared vnode host is serviced by
a subboss; i.e., subboss is proxying for the vnode host which in turn is
proxying for the vnode.
parent 00aca002
......@@ -223,6 +223,7 @@ main(int argc, char **argv)
int dostype = -1;
int slice = 0;
char *sig_keyfile = 0, *enc_keyfile = 0, *uuidstr = 0;
int islocalproxy = 0;
while ((ch = getopt(argc, argv, "dqhp:m:s:i:tbznT:r:E:D:C:W:S:M:R:I:ONc:e:u:K:B:F:Q:P:X:f")) != -1)
switch(ch) {
......@@ -440,6 +441,14 @@ main(int argc, char **argv)
fatal("Could not resolve host '%s'\n",
proxyfor);
host = ntohl(in.s_addr);
/*
* XXX make a note if localhost is the server.
* This is a special case of proxying, see
* proxyfor comment below.
*/
if (ntohl(serverip.s_addr) == INADDR_LOOPBACK)
islocalproxy = 1;
}
while (1) {
if (!ClientNetFindServer(ntohl(serverip.s_addr),
......@@ -497,12 +506,16 @@ main(int argc, char **argv)
}
/*
* XXX if proxying for another node, assume that we are only
* interested in starting up the frisbeed and don't care about
* the image ourselves. So, our work is done!
* XXX if proxying for another node from localhost, assume that
* we are only interested in starting up the frisbeed and don't
* care about the image ourselves. So, our work is done!
*
* This is a special case for implementing backward compatibility
* on Emulab. We should instead have a client timeout option that
* we can set to really small value to handle immediate termination.
*/
if (proxyfor) {
log("server started on behalf of %s", proxyfor);
if (proxyfor && islocalproxy) {
log("frisbeed server started on behalf of %s", proxyfor);
exit(0);
}
#endif
......
......@@ -989,8 +989,8 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
/*
* If the requester is not the same as the host, then it is a proxy
* request. In Emulab, the only proxy scenarios we support are
* elabinelab inner bosses and subbosses. So we first ensure that
* the requester is listed as one of those.
* elabinelab inner bosses, subbosses and shared vnode hosts.
* So we first ensure that the requester is listed as one of those.
*/
if (req->s_addr != host->s_addr) {
#ifdef USE_LOCALHOST_PROXY
......@@ -1011,7 +1011,7 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
return 1;
}
/* Make sure the node really is a inner-boss/subboss */
/* Check the role of the node */
res = mydb_query("SELECT erole,inner_elab_role FROM reserved"
" WHERE node_id='%s'", 2, proxy);
assert(res != NULL);
......@@ -1036,7 +1036,10 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
/* or a subboss? */
else if (row[0] && strcmp(row[0], "subboss") == 0)
role = "subboss";
/* neither, return an error */
/* or a shared vnode host? */
else if (row[0] && strcmp(row[0], "sharedhost") == 0)
role = "sharedhost";
/* none of the above, return an error */
else {
mysql_free_result(res);
free(proxy);
......@@ -1070,8 +1073,9 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
/*
* We have a proxy node. It should be one of:
* - boss (for any node)
* - a subboss (that is a frisbee subboss for the node)
* - a subboss (that is a frisbee subboss for the node or node host)
* - an inner-boss (in the same experiment as the node)
* - a sharedhost (that is hosting the node)
* Note that we could not do this check until we had the node name.
* Note also that we no longer care about proxy or not after this.
*/
......@@ -1082,15 +1086,17 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
} else
#endif
if (strcmp(role, "subboss") == 0) {
res = mydb_query("SELECT node_id"
" FROM subbosses"
" WHERE subboss_id='%s'"
" AND node_id='%s'"
" AND service='frisbee'"
" AND disabled=0",
res = mydb_query("SELECT s.node_id"
" FROM subbosses as s,"
" nodes as n"
" WHERE s.subboss_id='%s'"
" AND s.service='frisbee'"
" AND s.disabled=0"
" AND n.node_id='%s'"
" AND s.node_id=n.phys_nodeid",
1, proxy, node);
assert(res != NULL);
} else {
} else if (strcmp(role, "innerboss") == 0) {
res = mydb_query("SELECT r1.node_id"
" FROM reserved as r1,"
" reserved as r2"
......@@ -1100,6 +1106,17 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
" AND r1.eid=r2.eid",
1, proxy, node);
assert(res != NULL);
} else if (strcmp(role, "sharedhost") == 0) {
res = mydb_query("SELECT node_id"
" FROM nodes"
" WHERE phys_nodeid='%s'"
" AND node_id='%s'",
1, proxy, node);
assert(res != NULL);
} else {
/* XXX just make it fail */
res = NULL;
assert(res != NULL);
}
if (res) {
if (mysql_num_rows(res) == 0) {
......
......@@ -448,12 +448,15 @@ null_get_host_authinfo(struct in_addr *req, struct in_addr *host,
int exists;
char *path = NULL;
/* XXX don't worry about this right now; breaks virthosts under subboss */
#if 0
/*
* If the requester is not the same as the host, then it is a proxy
* request. We don't do proxying.
*/
if (req->s_addr != host->s_addr)
return 1;
#endif
/*
* If an imageid is specified, convert it into a plausible path.
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2010-2011 University of Utah and the Flux Group.
* Copyright (c) 2010-2012 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -39,6 +39,7 @@ static int bufsize = (64 * 1024);;
static int timeout = -1;
static int usessl = 0;
static int verify = 1;
static in_addr_t proxyip = 0;
/* Globals */
int debug = 0;
......@@ -96,7 +97,7 @@ main(int argc, char **argv)
}
if (imageid) {
if (!put_request(imageid, ntohl(msip.s_addr), msport, 0,
if (!put_request(imageid, ntohl(msip.s_addr), msport, proxyip,
filesize, mtime, timeout, askonly, timo,
&reply))
fatal("Could not get upload info for '%s'", imageid);
......@@ -158,7 +159,7 @@ main(int argc, char **argv)
while (1) {
sleep(1);
if (!put_request(imageid, ntohl(msip.s_addr), msport,
0, 0, 0, 0, 1, timo, &reply)) {
proxyip, 0, 0, 0, 1, timo, &reply)) {
warning("%s: status request failed",
imageid);
goto vdone;
......@@ -220,7 +221,7 @@ static void
parse_args(int argc, char **argv)
{
int ch;
while ((ch = getopt(argc, argv, "S:p:F:Q:sb:T:N")) != -1) {
while ((ch = getopt(argc, argv, "S:p:F:Q:sb:T:NP:")) != -1) {
switch (ch) {
case 'S':
mshost = optarg;
......@@ -257,6 +258,19 @@ parse_args(int argc, char **argv)
case 'N':
verify = 0;
break;
case 'P':
{
struct in_addr in;
if (!GetIP(optarg, &in)) {
fprintf(stderr,
"Invalid node name '%s' for -P\n",
optarg);
exit(1);
}
proxyip = ntohl(in.s_addr);
break;
}
default:
break;
}
......
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