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
CCDB-4354: preflight cross-fields validation for configuration PK_MODE #1157
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.
Thanks @fzhong-connect. I've left a few comments; anything beginning with "nit: " can be implemented or ignored at your discretion. The only significant one has to do with providing clear error messages to users; let me know what you think.
Also, what's the reasoning for targeting 10.2.x with this change? Based on https://docs.confluent.io/platform/current/installation/versions-interoperability.html#cp-and-apache-ak-compatibility, we're still providing support as far back as 5.2.x; if it's not too difficult with merge conflicts and the like, could we consider targeting that branch instead?
.findFirst() | ||
.orElse(Collections.emptyList()); | ||
|
||
assertTrue(pkModeError.isEmpty()); |
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.
Nit: I prefer to do a comparison for tests like this since it gives a more informative message if the assertion fails:
assertTrue(pkModeError.isEmpty()); | |
assertEquals(Optional.empty(), pkModeError); |
.findFirst() | ||
.orElse(Collections.emptyList()); | ||
|
||
assertTrue(pkModeError.isEmpty()); |
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.
(Same nit RE: comparison for assertion)
assertTrue(pkModeError.isEmpty()); | |
assertEquals(Optional.empty(), pkModeError); |
src/test/java/io/confluent/connect/jdbc/JdbcSinkConnectorTest.java
Outdated
Show resolved
Hide resolved
Thank you for taking time @C0urante . The reason it's targeting 10.2.x is Nathan believes it mostly benefits user of the fully-managed connector on CCloud, he asked to start from the latest version on CC. |
if (!pkMode.recommendedValues().contains(pkMode.value())) { | ||
pkMode.addErrorMessage("'" + pkMode.value() + "' is invalid:" | ||
+ " Deletes are only supported for pk.mode 'record_key'"); | ||
} |
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.
Is this susceptible to false positives if the user gives a value for the pk.mode
property that is invalid not because of conflict with delete.enabled
but just because it doesn't correspond to a recognized primary key mode? For example, something like pk.mode = not_a_real_mode
.
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.
that is great catch! thank you.
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.
LGTM, thanks Frank!
Problem
Misconfigured
pk.mode
anddelete.enabled
combination should not be surfaced by throwing an exception when the connector or task starts. Instead, the connector should notify the user that it is configured incorrectly via the Connector::validate method.Solution
Do cross-fields configuration validation in
Connector::validate
method, utilizing existing logic from PrimaryKeyModeRecommender.Ref:
Does this solution apply anywhere else?
If yes, where?
Test Strategy
Testing done:
Release Plan