From ffbd1d3969b149d34e4830e5d9df12255ef69bc5 Mon Sep 17 00:00:00 2001 From: r-vasquez Date: Mon, 25 Nov 2024 10:40:00 -0800 Subject: [PATCH] rpk: add err message of CreateACL response Response of CreateACL contains an ErrMessage field that can provide more information about unknown failures. --- src/go/rpk/pkg/cli/security/acl/create.go | 6 +++++- tests/rptest/tests/acls_test.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/go/rpk/pkg/cli/security/acl/create.go b/src/go/rpk/pkg/cli/security/acl/create.go index c23f38b301a32..4d556f69d0369 100644 --- a/src/go/rpk/pkg/cli/security/acl/create.go +++ b/src/go/rpk/pkg/cli/security/acl/create.go @@ -69,6 +69,10 @@ Allow write permissions to user buzz to transactional ID "txn": tw := out.NewTable(headersWithError...) defer tw.Flush() for _, c := range results { + errMsg := kafka.ErrMessage(c.Err) + if c.ErrMessage != "" { + errMsg = fmt.Sprintf("%v: %v", errMsg, c.ErrMessage) + } tw.PrintStructFields(aclWithMessage{ c.Principal, c.Host, @@ -77,7 +81,7 @@ Allow write permissions to user buzz to transactional ID "txn": c.Pattern, c.Operation, c.Permission, - kafka.ErrMessage(c.Err), + errMsg, }) } }, diff --git a/tests/rptest/tests/acls_test.py b/tests/rptest/tests/acls_test.py index f6629efe3c50c..1d829648648ae 100644 --- a/tests/rptest/tests/acls_test.py +++ b/tests/rptest/tests/acls_test.py @@ -307,7 +307,8 @@ def test_invalid_acl_topic_name(self): acl = [acl for acl in acls if acl.resource_name == resource] assert len(acl) == 1, f'Expected match for {resource} not found' - assert acl[0].error == 'INVALID_REQUEST' + assert 'INVALID_REQUEST' in acl[ + 0].error, f'expected INVALID_REQUEST to be in {acl[0].error}' ''' The old config style has use_sasl at the top level, which enables