Skip to content

Commit

Permalink
redfishpower: support setstatuspollinginterval
Browse files Browse the repository at this point in the history
Problem: The wait until on/off polling interval in redfishpower
is currently hard coded to 1 second.  On some slow systems, it has
been observed that on/off can take upwards of a minute.  On that
hardware, a 1 second retry delay can lead to an excess amount of
traffic on the network.

Support a prompt command that will allow change of the status polling
interval.  Document new command in redfishpower(8).  Update redfishpower
test helper to parse setstatuspollinginterval.
  • Loading branch information
chu11 committed Mar 1, 2024
1 parent ebdabf3 commit aaa8f5d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
4 changes: 4 additions & 0 deletions man/redfishpower.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Set path and optional post data to turn off node.
.I "settimeout <seconds>"
Set command timeout in seconds.
.TP
.I "setstatuspollinginterval <seconds>"
Set status polling interval in seconds. This is the polling interval
to determine an on/off command has completed.
.TP
.I "stat [nodes]"
Get power status of all nodes or specified subset of nodes.
.TP
Expand Down
35 changes: 31 additions & 4 deletions src/redfishpower/redfishpower.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <sys/select.h>
#include <limits.h>
#include <sys/time.h>
#include <limits.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
Expand Down Expand Up @@ -64,11 +65,13 @@ static zhashx_t *test_power_status;

/* in usec
*
* status polling interval of 1 second may seem long, but testing
* shows wait ranges from a few seconds to 20 seconds
* status polling interval of 1 second may seem long, but testing shows wait ranges
* from a few seconds to almost a minute. Device files should adjust
* to longer times for really bad systems.
*/
#define STATUS_POLLING_INTERVAL 1000000
#define STATUS_POLLING_INTERVAL_DEFAULT 1000000

#define USEC_IN_SEC 1000000
#define MS_IN_SEC 1000

#define CMD_STAT "stat"
Expand Down Expand Up @@ -138,6 +141,10 @@ static struct option longopts[] = {
};

static time_t cmd_timeout = CMD_TIMEOUT_DEFAULT;
/* typically is of type suseconds_t, but has questionable portability,
* so use 'long int' instead
*/
static long int status_polling_interval = STATUS_POLLING_INTERVAL_DEFAULT;

void help(void)
{
Expand All @@ -148,6 +155,7 @@ void help(void)
printf(" setonpath path [postdata]\n");
printf(" setoffpath path [postdata]\n");
printf(" settimeout seconds\n");
printf(" setstatuspollinginterval seconds\n");
printf(" stat [nodes]\n");
printf(" on [nodes]\n");
printf(" off [nodes]\n");
Expand Down Expand Up @@ -569,7 +577,7 @@ static void send_status_poll(struct powermsg *pm)
statpath,
NULL,
&pm->start,
STATUS_POLLING_INTERVAL,
status_polling_interval,
STATE_WAIT_UNTIL_ON_OFF);
if (!(nextpm->handle = zlistx_add_end(delayedcmds, nextpm)))
err_exit(true, "zlistx_add_end");
Expand Down Expand Up @@ -749,6 +757,23 @@ static void settimeout(char **av)
}
}

static void setstatuspollinginterval(char **av)
{
if (av[0]) {
char *endptr;
long tmp;

errno = 0;
tmp = strtol (av[0], &endptr, 10);
if (errno
|| endptr[0] != '\0'
|| tmp <= 0
|| (tmp > (LONG_MAX / USEC_IN_SEC)))
printf("invalid status polling interval specified\n");
status_polling_interval = tmp * USEC_IN_SEC;
}
}

static void process_cmd(CURLM *mh, char **av, int *exitflag)
{
if (av[0] != NULL) {
Expand All @@ -768,6 +793,8 @@ static void process_cmd(CURLM *mh, char **av, int *exitflag)
setpowerpath(av + 1, &offpath, &offpostdata);
else if (strcmp(av[0], "settimeout") == 0)
settimeout(av + 1);
else if (strcmp(av[0], "setstatuspollinginterval") == 0)
setstatuspollinginterval(av + 1);
else if (strcmp(av[0], CMD_STAT) == 0)
stat_cmd(mh, av + 1);
else if (strcmp(av[0], CMD_ON) == 0)
Expand Down

0 comments on commit aaa8f5d

Please sign in to comment.