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

KAFKA-18134: Disallow group upgrades when custom assignors are used #18046

Conversation

squah-confluent
Copy link
Contributor

Disallow upgrades from classic groups to consumer groups when any
member's assignment has non-empty userData.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Disallow upgrades from classic groups to consumer groups when any
member's assignment has non-empty userData.
@dajac dajac added KIP-848 The Next Generation of the Consumer Rebalance Protocol ci-approved labels Dec 5, 2024
Copy link
Member

@dajac dajac left a comment

Choose a reason for hiding this comment

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

@squah-confluent Thanks for the patch! I left a few small comments.

Comment on lines 1062 to 1063
throw new GroupIdNotFoundException("Cannot upgrade the classic group " + classicGroup.groupId() +
" to consumer group because a custom assignor is in use.");
Copy link
Member

Choose a reason for hiding this comment

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

Completely unrelated but I wonder if we always provide such good error message when the upgrade is not possible. Do you mind checking?

Copy link
Member

Choose a reason for hiding this comment

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

nit: I wonder if we could extend the error message a bit more. We actually support upgrading while using a custom assignor but only if it does not have user data associated to the assignment. We could perhaps explain why they should do in this case (e.g. move to a default assignor and then upgrade?)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Completely unrelated but I wonder if we always provide such good error message when the upgrade is not possible. Do you mind checking?

I had a look and there are three reasons in validateOnlineUpgrade that we convert to "Group %s is not a consumer group":

  • Cannot upgrade classic group {} to consumer group because the online upgrade is disabled.
  • Cannot upgrade classic group {} to consumer group because the group does not use the consumer embedded protocol.
  • Cannot upgrade classic group {} to consumer group because the group size exceeds the consumer group maximum size.

Apart from that and SchemaException when subscriptions or metadata are malformed, I can't see any other error paths directly related to the upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! I've reworked the error message. Let me know what you think.

Copy link
Member

Choose a reason for hiding this comment

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

I had a look and there are three reasons in validateOnlineUpgrade that we convert to "Group %s is not a consumer group":

I wonder whether we should extend the error message that we provide to the user. "not a consumer group" does not say much. What do you think?

Copy link
Contributor Author

@squah-confluent squah-confluent Dec 9, 2024

Choose a reason for hiding this comment

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

I think it's a good idea. I've updated validateOnlineUpgrade to throw an exception with the appropriate message instead. And tweaked some of the error wording to be consistent with the rest.

);
if (assignment.userData() != null &&
assignment.userData().hasRemaining()) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: We could bring it back on the previous line. There is enough space.

Comment on lines 10187 to 10188
assertFalse(expectUpgrade);
assertEquals("Cannot upgrade the classic group group-id to consumer group because a custom assignor is in use.", ex.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

nit: It is usually better to use assertThrows. Would it be possible to use it in this case?

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've updated the test. Let me know what you think.

" to consumer group: " + e.getMessage() + ".", e);

throw new GroupIdNotFoundException("Cannot upgrade the classic group " + classicGroup.groupId() +
" to consumer group because a custom assignor with userData is in use. " +
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could make userData clearer. Most of the users won't understand it. Should we perhaps say ... because an unsupported custom assignor is in use. Please refer to the document or switch to ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify, which document should I direct users to?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant documentation, which implies the Kafka doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reworded the error to Cannot upgrade classic group %s to consumer group because an unsupported custom assignor is in use. Please refer to the documentation or switch to a default assignor before re-attempting the upgrade.

"Switch to a default assignor before re-attempting the upgrade.", ex.getMessage());
}
}

Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether we could add an integration test in ConsumerProtocolMigrationTest. Is it worth?

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 didn't know we had integration tests for group upgrades. This is definitely worth an integration test. I've gone ahead and added one. Let me know what you think.

@github-actions github-actions bot added the core Kafka Broker label Dec 9, 2024
Copy link
Member

@dajac dajac left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@dajac dajac merged commit 9ae1b0f into apache:trunk Dec 9, 2024
8 checks passed
@dajac dajac deleted the squah-disallow-classic-group-upgrades-with-assignment-userdata branch December 9, 2024 08:39
peterxcli pushed a commit to peterxcli/kafka that referenced this pull request Dec 18, 2024
…pache#18046)

Disallow upgrades from classic groups to consumer groups when any member's assignment has non-empty userData.

Reviewers: David Jacot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved core Kafka Broker KIP-848 The Next Generation of the Consumer Rebalance Protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants