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

Consumer group reset offset #960

Merged
merged 6 commits into from
Sep 13, 2024
Merged

Consumer group reset offset #960

merged 6 commits into from
Sep 13, 2024

Conversation

hemahg
Copy link
Contributor

@hemahg hemahg commented Aug 9, 2024

Consumer group reset offset

consumer group reset offset page
Screenshot 2024-09-11 at 1 28 20 PM

Dryrun page
Screenshot 2024-09-11 at 1 39 02 PM

@hemahg hemahg marked this pull request as ready for review August 30, 2024 13:09
Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

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

@hemahg , I noticed that the topics were not appearing for empty consumer groups. This is because the members will also be empty. However, the offsets can also be used to obtain the topic information as long as offsets have been committed for a topic/partition. This might improve the experience in those cases. I suggest defining allTopics[1] like this:

const allTopics: { topicId: string; topicName: string; }[] = [];
row.attributes.members?.
    flatMap((m) => m.assignments ?? []).
    forEach(a => allTopics.push({ topicId: a.topicId, topicName: a.topicName }));
row.attributes.offsets?.
    forEach(a => allTopics.push({ topicId: a.topicId, topicName: a.topicName }));

[1] https://github.com/streamshub/console/pull/960/files#diff-b4f415e287dedebced21247b153a6aad3642bf3edd6355587cdddd93065866f0R192-R193

Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

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

@hemahg the API doesn't currently support dry-run operations for the consumer group reset. We can add it in this PR or a separate one, what do you think?

Copy link
Collaborator

@riccardo-forina riccardo-forina left a comment

Choose a reason for hiding this comment

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

Changes look good. Please do a round of prettify on the changed files, rebase, update the test that’s failing (I didn’t check which one it is), and we can move this to the dev end and test it on the field

@hemahg hemahg force-pushed the consumergroup-reset-offset branch 2 times, most recently from 519c637 to 0c99bd9 Compare September 11, 2024 11:12
@MikeEdgar
Copy link
Member

Can we remove the delete button and make the reset offset button usable? Otherwise, both should be removed (or hidden for now).

image

Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

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

A few additional comments.

Another problem that I am having is that the members table does not update after resetting the offsets. I suspect this is a similar problem to the consumer group list page where the initial value when navigating to the page are always out of date and do not update until the refresh function runs. My guess is that this is somehow due to server-side rendering never being updated, but maybe we can figure it out and fix it with this PR? Something for sure will need to be done about the members page because it never updates currently.

cc: @hemahg @riccardo-forina

ui/api/consumerGroups/schema.ts Outdated Show resolved Hide resolved
typeof UpdateConsumerGroupErrorSchema
>;

export const ConsumerGroupDryrunResponseSchema = z.object({
Copy link
Member

Choose a reason for hiding this comment

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

This should be the same schema as ConsumerGroupResponse. It looks like all the optional fields are already correctly set in ConsumerGroupResponse. Can we use a single schema definition instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked the ConsumerGroupSchema before implementing it and noticed it contains several fields that are not required for the dry run. For example:

typescript
Copy code
offsets: z.array(OffsetAndMetadataSchema).optional()

const OffsetAndMetadataSchema = z.object({
    topicId: z.string(),
    topicName: z.string(),
    partition: z.number(),
    offset: z.number(),
    logEndOffset: z.number().optional(),
    lag: z.number().optional(),
    metadata: z.string(),
    leaderEpoch: z.number().optional()
});

Fields like offset, logEndOffset, and lag are not needed for the dry run, so I created a new response schema for dryrun

Copy link
Member

Choose a reason for hiding this comment

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

Right, the dry run will return a subset of the data that you would get from the describe/fetch operator. The back-end API uses the same data model for both. Just mentioning it because it might help reduce maintenance in the future and make it clear that they are the same response schema from the API.

@hemahg
Copy link
Contributor Author

hemahg commented Sep 13, 2024

@MikeEdgar, can we merge this PR? If there are more updates I will do them in another PR

@MikeEdgar
Copy link
Member

@hemahg I'm doing another round of testing and I'll merge before EOD.

Copy link

sonarcloud bot commented Sep 13, 2024

@MikeEdgar MikeEdgar merged commit cb88f98 into main Sep 13, 2024
9 checks passed
@MikeEdgar MikeEdgar deleted the consumergroup-reset-offset branch September 13, 2024 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants