Commit 47462f46 authored by Mike Hibler's avatar Mike Hibler

Much Ado About Nothing: changes to support un-proxied calls from jails

(only problem is, tmcd doesn't allow them...)

1. tmcc (the perl version) has -D flag to support "direct" unproxied call
2. watchdog has a -n flag to support "non-proxied" operation
3. libtmcc has a "noproxy" option, can be set globally or per-call

Oh, and made a per-call version of the "nocache" option for libtmcc:
cleaned up a hack in the watchdog.
parent 3d0b4078
......@@ -73,6 +73,7 @@ my $beproxy = 0;
"logfile" => undef,
"nocache" => 0,
"clrcache" => 0,
"noproxy" => 0,
);
# The cache directory is named by the vnodeid. This avoids some confusion.
......@@ -330,10 +331,26 @@ sub tmcc ($;$$%)
tmccgetconfig();
}
#
# Allow per-command setting of nocache and noproxy
#
my $nocache;
if (defined($opthash{"nocache"})) {
$nocache = $opthash{"nocache"};
} else {
$nocache = $config{"nocache"};
}
my $noproxy;
if (defined($opthash{"noproxy"})) {
$noproxy = $opthash{"noproxy"};
} else {
$noproxy = $config{"noproxy"};
}
#
# See if this is a cmd we can get from the local config stash.
#
if (!$config{"nocache"} && (!defined($args) || $args eq "")) {
if (!$nocache && (!defined($args) || $args eq "")) {
foreach my $key (keys(%commandset)) {
my $tag = $commandset{$key}->{TAG};
......@@ -367,9 +384,10 @@ sub tmcc ($;$$%)
}
#
# Check for proxypath file, but do not override config option.
# If proxypath was not specified, check for a proxypath file,
# unless they explicilty specified not to use a proxy.
#
if (!$config{"dounix"} && -e $PROXYDEF) {
if (!$config{"dounix"} && !$noproxy && -e $PROXYDEF) {
#
# Suck out the path and untaint.
#
......
......@@ -27,9 +27,10 @@ sub usage()
print STDERR " -x path Be a proxy using the unix domain socket\n";
print STDERR " -o path Specify log file name for -x option\n";
print STDERR " -c Clear tmcc cache first (must be root)\n";
print STDERR " -D Force command to use a direct, UDP request\n";
exit(1);
}
my $optlist = "ds:p:v:n:k:ul:t:x:o:bc";
my $optlist = "ds:p:v:n:k:ul:t:x:o:bcD";
my $debug = 0;
my $CMD;
my $ARGS;
......@@ -125,6 +126,9 @@ sub ParseOptions()
if (defined($options{"o"})) {
libtmcc::configtmcc("logfile" , $options{"o"});
}
if (defined($options{"D"})) {
libtmcc::configtmcc("noproxy", 1);
}
$CMD = "";
$ARGS = "";
......
......@@ -15,10 +15,10 @@ use POSIX qw(strftime);
#
sub usage()
{
print "Usage: watchdog [-dv] [start | stop]\n";
print "Usage: watchdog [-dvn] [start | stop]\n";
exit(1);
}
my $optlist = "Fdv";
my $optlist = "Fdvn";
#
# Turn off line buffering on output
......@@ -53,6 +53,7 @@ my @keylist = ("ssh_host_key", "ssh_host_dsa_key", "ssh_host_rsa_key");
my $debug = 0;
my $verbose = 0;
my $updatefailed= 0;
my $noproxy = 0;
my $driftfile;
my $lastdrift;
my $rusagestr;
......@@ -130,6 +131,9 @@ if (defined($options{"d"})) {
if (defined($options{"v"})) {
$verbose = 1;
}
if (defined($options{"n"})) {
$noproxy = 1;
}
if (defined($options{"F"})) {
$fakeit = 1;
}
......@@ -202,9 +206,14 @@ $SIG{INT} = \&handler;
#
if (JAILED() || PLAB()) {
my $vnodeid = libsetup_getvnodeid();
# Tell the tmcc library. Note that its actually been done via libsetup
# but I duplicate it here to make it explicit.
configtmcc("subnode", $vnodeid);
# This doesn't work yet, at least for jails since tmcd
# doesn't accept requests from them
#configtmcc("noproxy", $noproxy);
}
#
......@@ -308,6 +317,7 @@ sub sendisalive($)
}
my %tmccargs = ();
$tmccargs{nocache} = 1;
$tmccargs{timeout} = 3;
$tmccargs{useudp} = 1
if (!$trytcp || $retry{isalive} != $maxretries);
......@@ -381,16 +391,14 @@ sub setintervals($)
logmsg("setintervals: refetching intervals, retry=$retry{check}\n", 1);
}
# XXX fake an argument to force request to TMCD and avoid the cache
my $arg = "foo";
my %tmccargs = ();
$tmccargs{nocache} = 1;
$tmccargs{timeout} = 3;
$tmccargs{useudp} = 1
if (!$trytcp || $retry{check} != $maxretries);
my @tmccresults;
if (tmcc(TMCCCMD_WATCHDOGINFO, $arg, \@tmccresults, %tmccargs) != 0 ||
if (tmcc(TMCCCMD_WATCHDOGINFO, undef, \@tmccresults, %tmccargs) != 0 ||
scalar(@tmccresults) == 0) {
#
# Failed, schedule a retry using a backoff.
......@@ -621,6 +629,7 @@ sub sendrusage($)
logmsg("rusage: sending: $rusagestr\n", 1);
my %tmccargs = ();
$tmccargs{nocache} = 1;
$tmccargs{timeout} = 3;
$tmccargs{useudp} = 1
if (!$trytcp || $retry{rusage} != $maxretries);
......
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