feat: add consumer group describe command#536
Conversation
craicoverflow
left a comment
There was a problem hiding this comment.
❯ ./rhoas kafka consumergroup describe --id consumer_group_1
Consumer group ID: consumer_group_1
MEMBER ID PARTITION LOG END OFFSET CURRENT OFFSET OFFSET LAG
------------------------ ----------- ---------------- ---------------- ------------
consumer_group_member1 0 5 5 0
consumer_group_member2 1 3 3 0I'd like to see this formatted a little bit better - a space between the top level info and the table headers will make it easier to read.
The UI also has Active members and Partitions with Lag at the top level, should we do the same?
| }, | ||
| } | ||
|
|
||
| cmd.Flags().StringVar(&opts.id, "id", "", localizer.MustLocalizeFromID("kafka.consumerGroup.describe.flag.id.description")) |
There was a problem hiding this comment.
I wonder if we should use a positional argument instead: rhoas kafka consumergroup describe consumer_group_1. Wdyt?
There was a problem hiding this comment.
It occured to me, dropped the idea since we use positional arg for names and flags for id. I would suggest we go with --id flag or both flag and argumnet, what do you think?
There was a problem hiding this comment.
We use --id for service accounts only, but this is because service accounts have a name also, and service account ID is a UUID which is not friendly to dynamic auto completion, whereas consumer group IDs are, so I think we should use positionals.
There was a problem hiding this comment.
Okay, sounds fair.
Let us stick to positionals.
Yes that would be nice, missed it somehow. We should keep it as similar to UI as possible |
craicoverflow
left a comment
There was a problem hiding this comment.
Code looks great, but some changes required in how we display stuff.
| [kafka.consumerGroup.describe.cmd.example] | ||
| one = ''' | ||
| # describe a consumer group | ||
| $ rhoas kafka consumergroup describe --id consumer_group_1 -o json |
| Args: cobra.ExactArgs(1), | ||
| RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
|
|
||
| opts.id = args[0] |
There was a problem hiding this comment.
We should having dynamic auto completion for the ID.
| fmt.Fprintln(stdout, localizer.MustLocalize(&localizer.Config{ | ||
| MessageID: "kafka.consumerGroup.describe.output.id", | ||
| TemplateData: map[string]interface{}{ | ||
| "ID": consumerGroupData.GetId(), | ||
| }, | ||
| })) | ||
| fmt.Fprintln(stdout, localizer.MustLocalize(&localizer.Config{ | ||
| MessageID: "kafka.consumerGroup.describe.output.activeMembers", | ||
| TemplateData: map[string]interface{}{ | ||
| "ActiveMembers": len(consumerGroupData.GetConsumers()), | ||
| }, | ||
| })) | ||
| fmt.Fprintln(stdout, localizer.MustLocalize(&localizer.Config{ | ||
| MessageID: "kafka.consumerGroup.describe.output.partitionsWithLag", | ||
| TemplateData: map[string]interface{}{ | ||
| "LaggingPartitions": consumergroup.GetPartitionsWithLag(consumerGroupData.GetConsumers()), | ||
| }, | ||
| })) |
There was a problem hiding this comment.
We should explore a neater approach for this - there is no alignment in the indentation and it is a bit difficult to read in my opinion. Check out the formatting of rhoas status to see whether the same could be used here.
f4c503e to
635665f
Compare
635665f to
1e237e8
Compare
9ce7da4 to
f835a5d
Compare
Co-authored-by: Enda Phelan <[email protected]>
Description
Subcommand to view a consumer group.
fixes #385
Verification Steps
make mock-api/startto start the mock API.go run ./cmd/rhoas login --api-gateway=http://localhost:8000to use the mock API.go run ./cmd/rhoas kafka use somekafkato use a Kafka instance (this will always pick the same one, it is not dynamic).go run ./cmd/rhoas kafka consumergroup describe consumer_group_1to view a consumer group.Type of change
Checklist