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

Add kafka ce extensions for partition and offset #3464

Merged
merged 14 commits into from
Jan 24, 2024

Conversation

Cali0707
Copy link
Member

Fixes #3072

Proposed Changes

  • Expose kafka partition and offset as new CE extensions

Release Note

Events coming from kafka components now have knativekafkaoffset and knativekafkapartition cloudevents extension attributes set

Docs

Copy link

knative-prow bot commented Nov 13, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 13, 2023
@Cali0707
Copy link
Member Author

/test all

@knative-prow knative-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/data-plane labels Nov 13, 2023
@knative-prow knative-prow bot requested review from Leo6Leo and matzew November 13, 2023 17:34
@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 13, 2023
@Cali0707
Copy link
Member Author

@matzew @pierDipi it looks like a lot of tests are failing because they don't expect the event to have the two new extensions I've added. Since the issue doesn't specify that this needs to be an CE extension, I'm wondering - should I switch my implementation to just set a header (and not a CE extension)?

I personally think the CE extension approach is better since it will let users write filters for different conditions if they want to on their triggers. However, I'd rather check first before I fix all the tests :)

@pierDipi
Copy link
Member

@Cali0707 the spec says this https://github.com/knative/specs/blob/main/specs/eventing/data-plane.md#event-acknowledgement-and-delivery-retry:

In general, senders MAY add or update other CloudEvent attributes on each delivery attempt; see observability for an example case.

so tests should not fail when attributes are added

@pierDipi
Copy link
Member

Also we can ask the author of the issue to give us feedback as the exit criteria on the issue may be ambiguous as we're using binary content mode to send events over HTTP, so CE attributes are headers

The incoming HTTP request contains the offset and partition information.

@Cali0707
Copy link
Member Author

@Cali0707 the spec says this https://github.com/knative/specs/blob/main/specs/eventing/data-plane.md#event-acknowledgement-and-delivery-retry:

In general, senders MAY add or update other CloudEvent attributes on each delivery attempt; see observability for an example case.

so tests should not fail when attributes are added

I think the issue is the tests are expecting a specific cloud event currently, which we aren't matching?

For example:

     topology.go:179: unexpected event routing behaviour (-want, +got) =   []event.Event{
          	{
          		Mode: "",
          		Attributes: event.ContextAttributes{
          			... // 1 ignored and 7 identical fields
          			DataContentEncoding: "",
          			DataContentType:     "text/json",
          			Extensions: event.Extensions{
          				... // 4 identical entries
          				"extime":                "2020-03-21T12:34:56.78Z",
          				"exurl":                 "http://example.com/source",
        + 				"knativekafkaoffset":    "0",
        + 				"knativekafkapartition": "0",
          			},
          		},
          		TransportExtensions: nil,
          		Data:                `"hello"`,
          	},
          } 

Should I be fixing these @pierDipi ?

@matzew
Copy link
Contributor

matzew commented Nov 15, 2023

well:


        + 				"knativekafkaoffset":    "0",
        + 				"knativekafkapartition": "0",

when we add those to each request, I guess we either need to check they are there, or ignore them (being more lenient on extra headers, which may have a downside)

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707 Cali0707 force-pushed the expose-partition-offset branch from 3208d66 to 8381272 Compare November 21, 2023 19:38
@Cali0707
Copy link
Member Author

/test all

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bfeb3c3) 62.30% compared to head (59220e8) 62.24%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3464      +/-   ##
============================================
- Coverage     62.30%   62.24%   -0.06%     
- Complexity      843      844       +1     
============================================
  Files           186      186              
  Lines         12588    12579       -9     
  Branches        272      272              
============================================
- Hits           7843     7830      -13     
- Misses         4133     4136       +3     
- Partials        612      613       +1     
Flag Coverage Δ
java-unittests 74.80% <100.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Member Author

/test all

Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Member Author

/test reconciler-tests

Comment on lines +67 to +68
builder.withExtension("knativekafkapartition", partition);
builder.withExtension("knativekafkaoffset", offset);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make those private static final String ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the prefix of knative... but wondering if the actual upstream/spec, would want to say something on the metadata in https://github.com/cloudevents/spec/blob/main/cloudevents/bindings/kafka-protocol-binding.md ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't see anything in particular while reading the docs there, I'll ask at the serverless WG meeting tomorrow

Copy link
Member Author

Choose a reason for hiding this comment

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

From today's cloudevents call, we should use our own attribute names prefixed by knative and then document those in our repo

Copy link
Contributor

Choose a reason for hiding this comment

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

that's fair and thanks for raising this

@@ -172,7 +172,7 @@ func assertExpectedRoutedEvents(prober *eventshub.EventProber, expected map[stri
if len(want) != 0 && len(got) != 0 {
// ID is adjusted by eventshub.
except := []cmp.Option{
cmpopts.IgnoreFields(conformanceevent.ContextAttributes{}, "ID"),
cmpopts.IgnoreFields(conformanceevent.ContextAttributes{}, "ID", "Extensions"),
Copy link
Contributor

Choose a reason for hiding this comment

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

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 12, 2024
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Member Author

/cc @pierDipi
Do you think we can get this into the release?

@knative-prow knative-prow bot requested a review from pierDipi January 16, 2024 15:15
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Member Author

/retest

Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 22, 2024
Copy link

knative-prow bot commented Jan 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Cali0707
Copy link
Member Author

@pierDipi do you think this needs a corresponding docs update?

@Cali0707
Copy link
Member Author

/retest

1 similar comment
@Cali0707
Copy link
Member Author

/retest

@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2024
@Cali0707
Copy link
Member Author

/cc @pierDipi @Leo6Leo

could I get an LGTM again after fixing the build issue?

@knative-prow knative-prow bot requested a review from pierDipi January 23, 2024 15:57
@Cali0707
Copy link
Member Author

/retest

@Leo6Leo
Copy link
Contributor

Leo6Leo commented Jan 23, 2024

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 23, 2024
@Cali0707
Copy link
Member Author

/retest-required

@Cali0707
Copy link
Member Author

/retest

@knative-prow knative-prow bot merged commit e2bd457 into knative-extensions:main Jan 24, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/data-plane area/test lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose Kafka record offset and partition
5 participants