-
Notifications
You must be signed in to change notification settings - Fork 117
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
Adding a filter for custom error respnse codes to be added as CE extensions #2657
Adding a filter for custom error respnse codes to be added as CE extensions #2657
Conversation
TODO: will add test(s) |
@@ -77,6 +78,7 @@ public class RecordDispatcherImpl implements RecordDispatcher { | |||
private static final String KN_ERROR_DEST_EXT_NAME = "knativeerrordest"; | |||
private static final String KN_ERROR_CODE_EXT_NAME = "knativeerrorcode"; | |||
private static final String KN_ERROR_DATA_EXT_NAME = "knativeerrordata"; | |||
private static final String EKB_ERROR_PREFIX = "kne-"; |
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.
@pierDipi I have no idea what is better kne-
as in Knative Error?
Or ekb-
, as in "eventing kafka broker", as that is more generic
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 like kne-
@@ -292,6 +294,13 @@ private ConsumerRecordContext errorTransform(final ConsumerRecordContext recordC | |||
extensions.put(KN_ERROR_DEST_EXT_NAME, destination); | |||
extensions.put(KN_ERROR_CODE_EXT_NAME, String.valueOf(response.statusCode())); | |||
|
|||
// transform all headers keys to be lowercase and filter by prefix. | |||
// afterwards extract the prefix and add them to the extensions map | |||
response.headers().entries().stream().collect(Collectors.toMap(entry -> entry.getKey().toLowerCase(), entry -> entry.getValue())) |
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.
works, but perhaps can be written "nicer" ...
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.
This should be much faster with less allocations and IMHO cleaner:
response.headers().forEach((k, v) -> {
if (k.regionMatches(true, 0, EKB_ERROR_PREFIX, 0, EKB_ERROR_PREFIX.length())) { // aka startsWithIgnoreCase
extensions.put(k.substring(EKB_ERROR_PREFIX.length()).toLowerCase(), v);
}
});
Codecov Report
@@ Coverage Diff @@
## main #2657 +/- ##
============================================
+ Coverage 55.92% 62.13% +6.21%
- Complexity 0 723 +723
============================================
Files 75 148 +73
Lines 7864 10406 +2542
Branches 0 229 +229
============================================
+ Hits 4398 6466 +2068
- Misses 3150 3489 +339
- Partials 316 451 +135
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
d2e91c3
to
86d702c
Compare
…nsions Signed-off-by: Matthias Wessendorf <[email protected]>
Signed-off-by: Matthias Wessendorf <[email protected]>
6312452
to
9baa960
Compare
Signed-off-by: Matthias Wessendorf <[email protected]>
// transform all headers keys to be lowercase and filter by prefix. | ||
// afterwards extract the prefix and add them to the extensions map |
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.
The comment isn't true anymore.
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.
@pierDipi I updated the comment
Signed-off-by: Matthias Wessendorf <[email protected]>
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
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: matzew, pierDipi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cherry-pick release-1.7 |
@matzew: once the present PR merges, I will cherry-pick it on top of release-1.7 in a new PR and assign it to you. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cherry-pick release-1.6 |
@matzew: once the present PR merges, I will cherry-pick it on top of release-1.6 in a new PR and assign it to you. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/retest |
1 similar comment
/retest |
/test integration-tests |
/test reconciler-tests-namespaced-broker |
/test channel-integration-tests-sasl-plain |
@matzew: new pull request created: #2659 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@matzew: new pull request created: #2660 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: Matthias Wessendorf [email protected]
Fixes #2376
Proposed Changes
Release Note
Docs