Skip to content

Commit 8761ca1

Browse files
garlickmergify[bot]
authored andcommitted
broker: use module stats for log debug stuff
Problem: broker attributes reflect live usage stats of the log ring buffer for testing, but in other parts of the broker we have migrated that sort of stuff to the stats.get RPC. Add RPC handler for stats object. Drop log-count and log-ring-used broker attributes. Update dmesg sharness test. Drop those attributes from flux-broker-attributes(7).
1 parent ac15d03 commit 8761ca1

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

doc/man7/flux-broker-attributes.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,10 @@ tbon.tcp_user_timeout
211211
LOGGING
212212
=======
213213

214-
log-ring-used
215-
The number of log entries currently stored in the ring buffer.
216-
217214
log-ring-size [Updates: C, R]
218215
The maximum number of log entries that can be stored in the ring buffer.
219216
Default: ``1024``.
220217

221-
log-count
222-
The number of log entries ever stored in the ring buffer.
223-
224218
log-forward-level [Updates: C, R]
225219
Log entries at :linux:man3:`syslog` level at or below this value
226220
are forwarded to rank zero for permanent capture. Default ``7``

src/broker/log.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,6 @@ static int attr_get_log (const char *name, const char **val, void *arg)
264264
*val = logbuf->stderr_mode == MODE_LEADER ? "leader" : "local";
265265
else if (!strcmp (name, "log-ring-size"))
266266
*val = int_to_string (logbuf->ring_size);
267-
else if (!strcmp (name, "log-ring-used"))
268-
*val = int_to_string (zlist_size (logbuf->buf));
269-
else if (!strcmp (name, "log-count"))
270-
*val = int_to_string (logbuf->seq);
271267
else if (!strcmp (name, "log-filename"))
272268
*val = logbuf->filename;
273269
else if (!strcmp (name, "log-level"))
@@ -360,12 +356,6 @@ static int logbuf_register_attrs (logbuf_t *logbuf, attr_t *attrs)
360356
if (attr_add_active (attrs, "log-ring-size", 0,
361357
attr_get_log, attr_set_log, logbuf) < 0)
362358
goto done;
363-
if (attr_add_active (attrs, "log-ring-used", 0,
364-
attr_get_log, NULL, logbuf) < 0)
365-
goto done;
366-
if (attr_add_active (attrs, "log-count", 0,
367-
attr_get_log, NULL, logbuf) < 0)
368-
goto done;
369359
rc = 0;
370360
done:
371361
return rc;
@@ -571,12 +561,29 @@ static void cancel_request_cb (flux_t *h,
571561
flux_msglist_cancel (h, logbuf->followers, msg);
572562
}
573563

564+
static void stats_request_cb (flux_t *h,
565+
flux_msg_handler_t *mh,
566+
const flux_msg_t *msg,
567+
void *arg)
568+
{
569+
logbuf_t *logbuf = arg;
570+
571+
if (flux_respond_pack (h,
572+
msg,
573+
"{s:i s:i}",
574+
"ring-used", (int)zlist_size (logbuf->buf),
575+
"count", logbuf->seq) < 0)
576+
flux_log_error (h, "error responding to log.stats.get");
577+
}
578+
579+
574580
static const struct flux_msg_handler_spec htab[] = {
575581
{ FLUX_MSGTYPE_REQUEST, "log.append", append_request_cb, 0 },
576582
{ FLUX_MSGTYPE_REQUEST, "log.clear", clear_request_cb, 0 },
577583
{ FLUX_MSGTYPE_REQUEST, "log.dmesg", dmesg_request_cb, 0 },
578584
{ FLUX_MSGTYPE_REQUEST, "log.disconnect", disconnect_request_cb, 0 },
579585
{ FLUX_MSGTYPE_REQUEST, "log.cancel", cancel_request_cb, 0 },
586+
{ FLUX_MSGTYPE_REQUEST, "log.stats.get", stats_request_cb, 0 },
580587
FLUX_MSGHANDLER_TABLE_END,
581588
};
582589

t/t0009-dmesg.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ waitfile="${SHARNESS_TEST_SRCDIR}/scripts/waitfile.lua"
99

1010
test_under_flux 4 minimal
1111

12-
test_expect_success 'flux getattr log-count counts log messages' '
13-
OLD_VAL=`flux getattr log-count` &&
12+
test_expect_success 'module stats --parse count log counts log messages' '
13+
OLD_VAL=$(flux module stats --parse count log) &&
1414
flux logger hello &&
15-
NEW_VAL=`flux getattr log-count` &&
15+
NEW_VAL=$(flux module stats --parse count log) &&
1616
test "${OLD_VAL}" -lt "${NEW_VAL}"
1717
'
18-
test_expect_success 'flux getattr log-ring-used counts log messages' '
19-
OLD_VAL=`flux getattr log-ring-used` &&
18+
test_expect_success 'module stats --parse ring-used log counts log messages' '
19+
OLD_VAL=$(flux module stats --parse ring-used log) &&
2020
flux logger hello &&
21-
NEW_VAL=`flux getattr log-ring-used` &&
21+
NEW_VAL=$(flux module stats --parse ring-used log) &&
2222
test "${OLD_VAL}" -lt "${NEW_VAL}"
2323
'
2424
test_expect_success 'flux dmesg -C clears ring buffer' '

0 commit comments

Comments
 (0)