-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat: add consumer group describe command #536
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❯ ./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 0
I'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs updating.
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
|
||
opts.id = args[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/start
to start the mock API.go run ./cmd/rhoas login --api-gateway=http://localhost:8000
to use the mock API.go run ./cmd/rhoas kafka use somekafka
to use a Kafka instance (this will always pick the same one, it is not dynamic).go run ./cmd/rhoas kafka consumergroup describe consumer_group_1
to view a consumer group.Type of change
Checklist