Commit e08bfeec authored by Mike Hibler's avatar Mike Hibler

Add a 'disabled' field to the subbosses table.

This allows us to more easily disable a subboss in the event of a temporary
subboss outage (e.g., hardware failure). Previously we would have to remove
the related rows from the DB and restore them later.
parent 1985b793
......@@ -1086,7 +1086,8 @@ emulab_get_host_authinfo(struct in_addr *req, struct in_addr *host,
" FROM subbosses"
" WHERE subboss_id='%s'"
" AND node_id='%s'"
" AND service='frisbee'",
" AND service='frisbee'"
" AND disabled=0",
1, proxy, node);
assert(res != NULL);
} else {
......
......@@ -185,7 +185,7 @@ while (my %row = $query_result->fetchhash()) {
$query_result =
DBQueryWarn("select s.node_id, s.service, s.subboss_id, i.IP ".
"from subbosses as s left join interfaces as i on ".
"s.subboss_id=i.node_id where i.role='$CRTLTAG'");
"s.subboss_id=i.node_id where i.role='$CRTLTAG' and s.disabled=0");
if (! $query_result) {
fatal("Could not dhcpd data from DB!");
}
......
......@@ -3647,6 +3647,7 @@ CREATE TABLE `subbosses` (
`node_id` varchar(32) NOT NULL default '',
`service` varchar(20) NOT NULL default '',
`subboss_id` varchar(20) NOT NULL default '',
`disabled` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`node_id`,`service`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......
#
# Add a disabled slot to subbosses table.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (! DBSlotExists("subbosses", "disabled")) {
DBQueryFatal("alter table subbosses add ".
" `disabled` tinyint(1) NOT NULL default '0' ".
" after subboss_id");
}
return 0;
}
1;
......@@ -4595,7 +4595,8 @@ COMMAND_PROTOTYPE(doloadinfo)
" from interfaces as i, subbosses as s "
" where i.node_id=s.subboss_id and "
" i.role='ctrl' and "
" s.node_id='%s' and s.service='frisbee'",
" s.node_id='%s' and s.service='frisbee'"
" and s.disabled=0",
1, reqp->isvnode ? reqp->pnodeid : reqp->nodeid);
if (!res2) {
error("doloadinfo: %s: DB Error getting subboss info!\n",
......@@ -8082,7 +8083,7 @@ COMMAND_PROTOTYPE(dofwinfo)
res = mydb_query("select node_id,IP,mac from interfaces "
"where role='ctrl' and (node_id in "
"('boss','ops','fs') or node_id in "
"(select distinct subboss_id from subbosses))",
"(select distinct subboss_id from subbosses where disabled=0))",
3);
if (!res) {
error("FWINFO: %s: DB Error getting server info!\n",
......@@ -9516,7 +9517,7 @@ COMMAND_PROTOTYPE(dodhcpdconf)
"left join interfaces as i on n.node_id = i.node_id "
"left join reserved as r on n.node_id = r.node_id "
"where s.subboss_id = '%s' and "
"s.service='dhcp' and i.role='ctrl' "
"s.service='dhcp' and s.disabled=0 and i.role='ctrl' "
"order by n.priority", 12, reqp->nodeid);
if (!res) {
......@@ -9615,7 +9616,8 @@ COMMAND_PROTOTYPE(dodhcpdconf)
res2 = mydb_query("select s.subboss_id,s.service,i.IP from subbosses as s, "
"interfaces as i where s.node_id = '%s' and s.service != 'dhcp' "
"interfaces as i where s.node_id = '%s' and "
"s.service != 'dhcp' and s.disabled=0 "
"and s.subboss_id = i.node_id and i.role = 'ctrl'", 3,
row[0]);
if (!res) {
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -26,10 +26,10 @@ sub sync_tftpboot($)
}
my $query_result =
DBQueryWarn("select n.node_id from nodes as n left join reserved as r on " .
DBQueryWarn("select distinct n.node_id from nodes as n left join reserved as r on " .
"n.node_id = r.node_id left join subbosses as s on " .
"n.node_id = s.subboss_id where r.erole = 'subboss' and " .
"s.service = 'tftp' and n.eventstate = 'ISUP'");
"s.service = 'tftp' and s.disabled = 0 and n.eventstate = 'ISUP'");
if (! $query_result) {
fatal("Could not subboss data from DB!");
}
......
......@@ -1029,7 +1029,7 @@ class Node
$query_result =
DBQueryFatal("select service,subboss_id from subbosses ".
"where node_id ='$node_id'");
"where node_id ='$node_id' and disabled=0");
while ($row = mysql_fetch_array($query_result)) {
$service = $row["service"];
......
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