From fe498413b4d92863a00b4f7fafed2596e45b67ca Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Fri, 1 Mar 2024 11:58:40 -0800 Subject: [PATCH] redfishpower: add more debug/verbose info Problem: When powering on a target, it will sometimes enter the "PoweringOn" state but regress back to the "off" state. This is likely due to a hardware problem. It can be hard to diagnose when the only clue is a power on has "timed out". Add some additional output to help diagnose this situation. --- src/redfishpower/redfishpower.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/redfishpower/redfishpower.c b/src/redfishpower/redfishpower.c index 9a6939a3..53f0fdc3 100644 --- a/src/redfishpower/redfishpower.c +++ b/src/redfishpower/redfishpower.c @@ -587,9 +587,10 @@ static void on_off_process(zlistx_t *delayedcmds, struct powermsg *pm) } else if (pm->state == STATE_WAIT_UNTIL_ON_OFF) { const char *status_str; + const char *rstatus_str; struct timeval now; - parse_onoff(pm, &status_str, NULL); + parse_onoff(pm, &status_str, &rstatus_str); if (strcmp(status_str, pm->cmd) == 0) { printf("%s: %s\n", pm->hostname, "ok"); return; @@ -598,7 +599,31 @@ static void on_off_process(zlistx_t *delayedcmds, struct powermsg *pm) /* check if we've timed out */ gettimeofday(&now, NULL); if (timercmp(&now, &pm->timeout, >)) { - printf("%s: %s\n", pm->hostname, "timeout"); + /* if target is not what it should be, this is unexpected, likely + * hardware problem */ + if ((strcmp(pm->cmd, CMD_ON) == 0 + && strcmp(status_str, STATUS_OFF) == 0) + || (strcmp(pm->cmd, CMD_OFF) == 0 + && strcmp(status_str, STATUS_ON) == 0)) + printf("%s: timeout - unexpected %s\n", + pm->hostname, status_str); + /* if still powering on/off, this is the "normal" timeout + * scenario, timeout should be increased + */ + else if ((strcmp(pm->cmd, CMD_ON) == 0 + && strcmp(rstatus_str, STATUS_POWERING_ON) == 0) + || (strcmp(pm->cmd, CMD_OFF) == 0 + && strcmp(rstatus_str, STATUS_POWERING_OFF) == 0)) + printf("%s: timeout - %s still in progress\n", + pm->hostname, pm->cmd); + else { + if (verbose) + printf("%s: timeout - unknown status %s\n", + pm->hostname, rstatus_str); + else + printf("%s: timeout\n", + pm->hostname); + } return; }