[UX-889] rpk: fill in --format json/yaml support#30194
[UX-889] rpk: fill in --format json/yaml support#30194graham-rp merged 2 commits intoredpanda-data:devfrom
Conversation
d37fe4a to
6e1dffd
Compare
7782ae2 to
1e58bd5
Compare
Retry command for Build#83403please wait until all jobs are finished before running the slash command |
1e58bd5 to
f3ad110
Compare
Retry command for Build#83408please wait until all jobs are finished before running the slash command |
c-julin
left a comment
There was a problem hiding this comment.
Its a massive PR but its safe to do as we're adding json responses in addition to the current output so functionality isn't impacted. I do think the two things codex picked up on are very good finds and we should address before putting out but very nice qol improvment!
f3ad110 to
40e70ac
Compare
Retry command for Build#83460please wait until all jobs are finished before running the slash command |
Retry command for Build#83465please wait until all jobs are finished before running the slash command |
0b5b99a to
cd80869
Compare
Retry command for Build#83493please wait until all jobs are finished before running the slash command |
cd80869 to
f9d0fbb
Compare
Retry command for Build#83505please wait until all jobs are finished before running the slash command |
f9d0fbb to
8be0e4d
Compare
Retry command for Build#83508please wait until all jobs are finished before running the slash command |
|
/retest |
c1a4f0a to
8b9cdd3
Compare
* cloud auth list * cluster config status * cluster logdirs describe * cluster maintenance status * cluster partitions balancer-status * cluster partitions move-cancel * cluster partitions move-status * cluster selftest status * group delete * group list * group offset-delete * group seek * plugin list * profile list * redpanda admin brokers decommission-status * redpanda admin partitions list * security acl delete * security secret list * topic add-partitions * topic alter-config * topic delete
The ducktape integration tests parse `rpk group offset-delete` output by splitting on whitespace with no expectation of a header line. Adding a TOPIC/PARTITION/STATUS header broke int() parsing of the partition field in the Python client. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
8b9cdd3 to
9502ab9
Compare
Adds
--format json|yaml|text|helpto 20 rpk commands that previously only supported plain text output.Pattern
All changes follow the same pattern established by existing commands like
rpk redpanda admin brokers list:p.InstallFormatFlag(cmd)to register--formatf.Help(...)guard at the top of Run for--format helpf.Format(data)for JSON/YAML output; text path unchangedjson/yamltags replacing ad-hoc table printingprint*helpers extracted from command Run functionsTest results
All commands verified against a live 3-node
rpk containercluster.security secret listrequires cloud credentials and was unit-tested only.cluster maintenance status
Setup: Maintenance mode enabled on broker 1.
[ {"node_id":0,"enabled":false}, {"node_id":1,"enabled":true,"finished":true,"errors":false,"partitions":11,"eligible":0,"transferring":4,"failed":0}, {"node_id":2,"enabled":false} ]cluster config status
[ {"node":0,"config_version":2,"needs_restart":false,"invalid":[],"unknown":[]}, {"node":1,"config_version":2,"needs_restart":false,"invalid":[],"unknown":[]}, {"node":2,"config_version":2,"needs_restart":false,"invalid":[],"unknown":[]} ]profile list
[ {"name":"local-console","description":"","current":false}, {"name":"rpk-cloud","description":"Redpanda Production \"gcs-test/gcs-test\"","current":false}, {"name":"rpk-container","description":"Automatically generated profile from 'rpk container start'","current":true} ]The current profile is represented by
current: truein JSON/YAML. In textoutput, the current profile's
NAMEcolumn is suffixed with*(matchingcloud auth list).plugin list --local
Setup: fake
.rpk-testplugininstalled in~/.local/bin; two managed plugins already present.[ {"name":"byoc","path":"/Users/graham.smith/.local/bin/.rpk.managed-byoc"}, {"name":"connect","path":"/Users/graham.smith/.local/bin/.rpk.managed-connect"}, {"name":"testplugin","path":"/Users/graham.smith/.local/bin/.rpk-testplugin"} ]cluster partitions move-cancel
Setup:
raft_learner_recovery_ratethrottled to 1000 B/s; all 3format-addpartspartitions (RF=1) moved simultaneously then immediately cancelled.[ {"namespace":"kafka","topic":"format-addparts","partition":0,"result":"Success"}, {"namespace":"kafka","topic":"format-addparts","partition":1,"result":"Success"}, {"namespace":"kafka","topic":"format-addparts","partition":2,"result":"Success"} ]redpanda admin brokers decommission-status
Setup:
raft_learner_recovery_ratethrottled to 1000 B/s; broker 2 decommissioned then status captured immediately. All partitions fail reallocation — 3-node cluster with RF=3 topics leaves no eligible destination node.{ "reallocation_failures": [ {"partition":"kafka/format-test/0","reason":"No eligible node found to move replica"}, {"partition":"kafka/format-test/1","reason":"No eligible node found to move replica"}, {"partition":"kafka/format-test/2","reason":"No eligible node found to move replica"}, {"partition":"kafka/__consumer_offsets/0","reason":"No eligible node found to move replica"}, {"partition":"kafka/__consumer_offsets/1","reason":"No eligible node found to move replica"}, {"partition":"kafka/__consumer_offsets/2","reason":"No eligible node found to move replica"}, {"partition":"kafka/format-seek-topic/0","reason":"No eligible node found to move replica"}, {"partition":"kafka/format-seek-topic/1","reason":"No eligible node found to move replica"}, {"partition":"kafka/format-seek-topic/2","reason":"No eligible node found to move replica"}, {"partition":"kafka_internal/id_allocator/0","reason":"No eligible node found to move replica"} ], "partitions": [] }redpanda admin partitions list 0
[ {"topic":"__consumer_offsets","partition":0,"is_leader":false}, {"topic":"__consumer_offsets","partition":1,"is_leader":false}, {"topic":"__consumer_offsets","partition":2,"is_leader":true}, {"topic":"format-seek-topic","partition":0,"is_leader":true}, {"topic":"format-seek-topic","partition":1,"is_leader":false}, {"topic":"format-seek-topic","partition":2,"is_leader":false}, {"topic":"format-test","partition":0,"is_leader":false}, {"topic":"format-test","partition":1,"is_leader":true}, {"topic":"format-test","partition":2,"is_leader":false} ]cloud auth list
[ {"name":"...-sso Redpanda Integration","kind":"sso","organization":"Redpanda Integration","organization_id":"a845616f-0484-4506-9638-45fe28f34865"}, {"name":"...-sso Redpanda Production","kind":"sso","organization":"Redpanda Production","organization_id":"617d637f-4645-4627-8841-c24be02f8817","current":true} ]cluster partitions balancer-status
{ "status": "ready", "seconds_since_last_tick": 14, "current_reassignments_count": 0, "partitions_pending_force_recovery_count": 0, "broker_replica_distribution": [ {"node_id":0,"count":11}, {"node_id":1,"count":10}, {"node_id":2,"count":11} ] }cluster logdirs describe
[ {"broker":0,"dir":"/var/lib/redpanda/data","topic":"format-test","partition":0,"size":465}, {"broker":0,"dir":"/var/lib/redpanda/data","topic":"format-test","partition":1,"size":155}, {"broker":0,"dir":"/var/lib/redpanda/data","topic":"format-test","partition":2,"size":423}, "..." ]group list
[{"broker":0,"group":"format-group","state":"Stable"}]cluster partitions move-status
No movements in progress — returns
[]. Empty-result path verified to route through formatter.security acl delete
{ "deletions": [ {"principal":"User:alice","host":"*","resource_type":"TOPIC","resource_name":"format-test","resource_pattern_type":"LITERAL","operation":"READ","permission":"ALLOW","message":""} ] }cluster selftest status
Full self-test run (~6 min, disk + network). Three nodes, all
"status":"idle"after completion.[ {"node_id":2,"status":"idle","stage":"cloud","results":[{"name":"512KB sequential r/w","test_type":"disk","p50":191,"p90":271,"p99":415,"rps":17660,"bps":9258961032},{"name":"8Kb Network Throughput Test","test_type":"network","p50":67,"rps":68925,"bps":564635511},"..."]}, {"node_id":0,"status":"idle","stage":"cloud","results":["..."]}, {"node_id":1,"status":"idle","stage":"cloud","results":["..."]} ]topic delete
[{"topic":"format-delete-me","status":"OK"}]topic add-partitions
[{"topic":"format-addparts","status":"OK"}]topic alter-config
[{"topic":"format-test","status":"OK"}]group seek
Group was active; seek rejected with
INVALID_OPERATIONfor all partitions.[ {"topic":"format-seek-topic","partition":0,"prior_offset":-1,"current_offset":0,"error":"INVALID_OPERATION: seeking a non-empty group is not allowed."}, {"topic":"format-seek-topic","partition":1,"prior_offset":1,"current_offset":0,"error":"INVALID_OPERATION: seeking a non-empty group is not allowed."}, {"topic":"format-seek-topic","partition":2,"prior_offset":-1,"current_offset":0,"error":"INVALID_OPERATION: seeking a non-empty group is not allowed."} ]group offset-delete
Group put into Empty state first.
[ {"topic":"format-seek-topic","partition":0,"status":"OK"}, {"topic":"format-seek-topic","partition":1,"status":"OK"}, {"topic":"format-seek-topic","partition":2,"status":"OK"} ]Release Notes
Improvements
--format json|yaml|text|helpto 20 rpk commands:cluster maintenance status,cluster config status,profile list,plugin list,cluster partitions move-cancel,redpanda admin brokers decommission-status,redpanda admin partitions list,cloud auth list,cluster partitions balancer-status,cluster logdirs describe,security secret list,group list,group delete,cluster partitions move-status,security acl delete,cluster selftest status,topic delete,topic add-partitions,topic alter-config,group seek,group offset-delete