Commit f0aaf892 authored by Mike Hibler's avatar Mike Hibler

Add logging so we know if bootinfo sent a state event.

Helps with debugging of lost state events. Also nit: fix the tmcd makefile
so it would correctly build the bootinfo modules if we make in the tmcd
directory before the pxe directory.
parent 45ec3557
/*
* Copyright (c) 2000-2009 University of Utah and the Flux Group.
* Copyright (c) 2000-2012 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -79,7 +79,7 @@ bootinfo_init(void)
int
bootinfo(struct in_addr ipaddr, char *node_id, struct boot_info *boot_info,
void *opaque, int no_event_send)
void *opaque, int no_event_send, int *event_sent)
{
#ifdef EVENTSYS
int needevent = 0;
......@@ -117,6 +117,10 @@ bootinfo(struct in_addr ipaddr, char *node_id, struct boot_info *boot_info,
default:
info("%s: invalid packet %d\n",
inet_ntoa(ipaddr), boot_info->opcode);
#ifdef EVENTSYS
if (event_sent)
*event_sent = 0;
#endif
return -1;
}
if (err)
......@@ -153,6 +157,11 @@ bootinfo(struct in_addr ipaddr, char *node_id, struct boot_info *boot_info,
}
#endif
}
#ifdef EVENTSYS
if (event_sent)
*event_sent = needevent;
#endif
return 0;
}
......@@ -187,13 +196,14 @@ static int
bicache_needevent(struct in_addr ipaddr)
{
DBT key, item;
time_t tt = time(NULL);
time_t tt;
int rval = 1, r;
/* So we can include bootinfo into tmcd; always send the event. */
if (!dbp)
return 1;
tt = time(NULL);
key.data = (void *) &ipaddr;
key.size = sizeof(ipaddr);
......
/*
* Copyright (c) 2000-2004, 2007 University of Utah and the Flux Group.
* Copyright (c) 2000-2012 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -28,7 +28,7 @@ int close_bootinfo_db(void);
int bootinfo_init(void);
int bootinfo(struct in_addr ipaddr, char *node_id,
struct boot_info *info, void *opaque,
int no_event_send);
int no_event_send, int *event_sent);
int query_bootinfo_db(struct in_addr ipaddr, char *node_id,
int version, struct boot_what *info,
char *key);
......
/*
* Copyright (c) 2000-2004 University of Utah and the Flux Group.
* Copyright (c) 2000-2012 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -156,7 +156,7 @@ main(int argc, char **argv)
while (1) {
struct sockaddr_in client;
int length;
socklen_t length;
cc = sendto(sock, &boot_info, sizeof(boot_info), 0,
(struct sockaddr *)&target, sizeof(target));
......
......@@ -47,7 +47,7 @@
*/
#define MINEVENTTIME 10
static void log_bootwhat(struct in_addr ipaddr, boot_what_t *bootinfo);
static void log_bootwhat(struct in_addr, boot_what_t *, int);
static void onhup(int sig);
static char *progname;
static char pidfile[MAXPATHLEN];
......@@ -159,6 +159,8 @@ main(int argc, char **argv)
signal(SIGHUP, onhup);
while (1) {
int esent = 0;
if ((mlen = recvfrom(sock, &boot_info, sizeof(boot_info),
0, (struct sockaddr *)&client, &length))
< 0) {
......@@ -166,12 +168,12 @@ main(int argc, char **argv)
exit(1);
}
err = bootinfo(client.sin_addr, (char *) NULL,
&boot_info, (void *) NULL, 0);
&boot_info, (void *) NULL, 0, &esent);
if (err < 0)
continue;
if (boot_info.status == BISTAT_SUCCESS)
log_bootwhat(client.sin_addr,
(boot_what_t *) &boot_info.data);
(boot_what_t *) &boot_info.data, esent);
boot_info.opcode = BIOPCODE_BOOTWHAT_REPLY;
......@@ -202,45 +204,50 @@ onhup(int sig)
}
static void
log_bootwhat(struct in_addr ipaddr, boot_what_t *bootinfo)
log_bootwhat(struct in_addr ipaddr, boot_what_t *bootinfo, int esent)
{
char ipstr[32];
char infostr[48];
strncpy(ipstr, inet_ntoa(ipaddr), sizeof ipstr);
snprintf(infostr, sizeof(infostr), "%s: REPLY(%d): ",
inet_ntoa(ipaddr), esent);
switch (bootinfo->type) {
case BIBOOTWHAT_TYPE_PART:
info("%s: REPLY: boot from partition %d\n",
ipstr, bootinfo->what.partition);
info("%sboot from partition %d\n",
infostr,
bootinfo->what.partition);
break;
case BIBOOTWHAT_TYPE_DISKPART:
info("%s: REPLY: boot from disk/partition 0x%x/%d\n",
ipstr, bootinfo->what.dp.disk,
info("%sboot from disk/partition 0x%x/%d\n",
infostr,
bootinfo->what.dp.disk,
bootinfo->what.dp.partition);
break;
case BIBOOTWHAT_TYPE_SYSID:
info("%s: REPLY: boot from partition with sysid %d\n",
ipstr, bootinfo->what.sysid);
info("%sboot from partition with sysid %d\n",
infostr,
bootinfo->what.sysid);
break;
case BIBOOTWHAT_TYPE_MB:
info("%s: REPLY: boot multiboot image %s:%s\n",
ipstr, inet_ntoa(bootinfo->what.mb.tftp_ip),
bootinfo->what.mb.filename);
info("%sboot multiboot image %s:%s\n",
infostr,
inet_ntoa(bootinfo->what.mb.tftp_ip),
bootinfo->what.mb.filename);
break;
case BIBOOTWHAT_TYPE_WAIT:
info("%s: REPLY: wait mode\n", ipstr);
info("%swait mode\n", infostr);
break;
case BIBOOTWHAT_TYPE_MFS:
info("%s: REPLY: boot from mfs %s\n", ipstr, bootinfo->what.mfs);
info("%sboot from mfs %s\n", infostr, bootinfo->what.mfs);
break;
case BIBOOTWHAT_TYPE_REBOOT:
info("%s: REPLY: reboot (alternate PXE boot)\n", ipstr);
info("%sreboot (alternate PXE boot)\n", infostr);
break;
default:
info("%s: REPLY: UNKNOWN (type=%d)\n", ipstr, bootinfo->type);
info("%sUNKNOWN (type=%d)\n", infostr, bootinfo->type);
break;
}
if (bootinfo->cmdline[0]) {
info("%s: REPLY: command line: %s\n", ipstr, bootinfo->cmdline);
info("%scommand line: %s\n", infostr, bootinfo->cmdline);
}
}
#
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2011 , 2012University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -122,6 +122,12 @@ $(INSTALL_BINDIR)/tmcd/%: %
-mkdir -p $(INSTALL_BINDIR)/tmcd
$(INSTALL_PROGRAM) $< $@
# XXX using ${OBJDIR}/pxe/% didn't seem to work
${OBJDIR}/pxe/bootinfo.o:
cd ${OBJDIR}/pxe && gmake bootinfo.o
${OBJDIR}/pxe/bootinfo_mysql.o:
cd ${OBJDIR}/pxe && gmake bootinfo_mysql.o
#
# Here so that the event system libraries, and libraries they depend upon,
# can get made.
......
......@@ -10001,7 +10001,8 @@ COMMAND_PROTOTYPE(dobootwhat)
}
if (bootinfo(reqp->client, (reqp->isvnode) ? reqp->nodeid : NULL,
&boot_info, (void *) reqp, (reqp->isvnode) ? 1 : 0)) {
&boot_info, (void *) reqp,
(reqp->isvnode) ? 1 : 0, NULL)) {
OUTPUT(buf, sizeof(buf), "STATUS=failed\n");
}
else {
......
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