Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flux-kvs: improve eventlog error messages #6531

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/cmd/flux-kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,8 +2019,11 @@ void eventlog_get_continuation (flux_future_t *f, void *arg)
if (flux_kvs_lookup_get (f, &s) < 0)
log_err_exit ("flux_kvs_lookup_get");

if (!(a = eventlog_decode (s)))
if (!(a = eventlog_decode (s))) {
if (errno == EINVAL)
log_msg_exit ("cannot decode improperly formatted eventlog");
log_err_exit ("eventlog_decode");
}

json_array_foreach (a, index, value) {
if (optparse_hasopt (ctx->p, "watch")) {
Expand Down Expand Up @@ -2135,8 +2138,11 @@ void eventlog_wait_event_continuation (flux_future_t *f, void *arg)
log_err_exit ("flux_kvs_lookup_get");
}

if (!(a = eventlog_decode (s)))
if (!(a = eventlog_decode (s))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use log_msg_exit()

if (errno == EINVAL)
log_msg_exit ("cannot decode improperly formatted eventlog");
log_err_exit ("eventlog_decode");
}

json_array_foreach (a, index, value) {
const char *name;
Expand Down
11 changes: 11 additions & 0 deletions t/t1008-kvs-eventlog.t
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ test_expect_success 'flux kvs eventlog get fails on bad input' '
test_must_fail flux kvs eventlog get
'

test_expect_success 'flux kvs eventlog get fails on not an eventlog' '
flux kvs put test.noteventlog=foo &&
test_must_fail flux kvs eventlog get test.noteventlog 2> noteventlog1.err &&
grep "cannot decode" noteventlog1.err
'

test_expect_success 'flux kvs eventlog append fails on bad input' '
test_must_fail flux kvs eventlog append
'
Expand All @@ -236,6 +242,11 @@ test_expect_success 'flux kvs eventlog wait-event fails on bad input' '
test_must_fail flux kvs eventlog wait-event
'

test_expect_success 'flux kvs eventlog wait-event fails on not an eventlog' '
test_must_fail flux kvs eventlog wait-event test.noteventlog foo 2> noteventlog2.err &&
grep "cannot decode" noteventlog2.err
'

#
# ensure no lingering pending requests
#
Expand Down
Loading