-
Notifications
You must be signed in to change notification settings - Fork 120
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
EventType autocreate #3585
EventType autocreate #3585
Conversation
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>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3585 +/- ##
============================================
- Coverage 62.16% 62.10% -0.06%
- Complexity 859 874 +15
============================================
Files 189 190 +1
Lines 12937 13037 +100
Branches 276 284 +8
============================================
+ Hits 8042 8097 +55
- Misses 4265 4303 +38
- Partials 630 637 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/test upgrade-tests |
Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707 Tested in my local environment, the event type works perfectly! Great work!!! |
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.
Are you also planning to add E2E tests ?
this.messageDigest.reset(); | ||
this.messageDigest.update(suffixString.getBytes()); |
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.
what happens when this is called concurrently ? I guess this is not thread safe ?
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.
Yeah I doubt this is thread safe, but currently it is just used in the IngressRequestHandlerImpl
which I thought was 1 per verticle (so no concurrency worries?). Should I change this to be thread safe?
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.
Yes, I would opt to being safer here
final var suffix = Hex.encodeHexString(this.messageDigest.digest()); | ||
final var name = String.format("et-%s-%s", reference.getName(), suffix).toLowerCase(); | ||
if (name.length() > DNS1123_SUBDOMAIN_MAX_LENGTH) { | ||
return name.substring(0, DNS1123_SUBDOMAIN_MAX_LENGTH); | ||
} | ||
return name; |
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 the same algorithm we use in Eventing core ?
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 think so, I tried to copy from https://github.com/knative/eventing/blob/42af160c3cfc244e26fa7bcd5db2c670ebdcf326/pkg/eventtype/eventtypes.go#L48-L52
private boolean eventTypeExists(String etName, DataPlaneContract.Reference reference) { | ||
var et = this.eventTypeClient | ||
.inNamespace(reference.getNamespace()) | ||
.withName(etName) | ||
.get(); | ||
return et != null; | ||
} |
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.
Are we using an actual client ? should we use a lister here ?
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 is an actual client as I wasn't sure how to make a lister to our custom class - I'll try and update it to be a lister
.withSchema(event.getDataSchema()) | ||
.withDescription("Event Type auto-created by controller"); | ||
|
||
this.eventTypeClient.resource(et.build()).create(); |
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.
we should avoid failing when the resource exist (like when it is created by some other process between checking exists and this line)
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.
Hm yeah, as far as I can tell this method doesn't declare that it returns an error or throws an exception. Should I wrap this in a try catch just in case?
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.
We need to be sure on what happens when already exists and handle that case accordingly
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 looked on their github and they said that the methods generally throw exceptions, so I'll add a try-catch to handle that case
For E2E tests, I was planning on porting those from eventing core: https://github.com/knative/eventing/blob/42af160c3cfc244e26fa7bcd5db2c670ebdcf326/test/experimental/eventtype_autocreate_test.go#L32-L74 But, I'm not sure if we have a job for experimental tests so I think I need to set that up first |
Signed-off-by: Calum Murray <cmurray@redhat.com>
/test |
@Cali0707: The
The following commands are available to trigger optional jobs:
Use
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: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
try { | ||
this.messageDigest = MessageDigest.getInstance("MD5"); | ||
} catch (NoSuchAlgorithmException ignored) { | ||
this.messageDigest = null; | ||
} |
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.
Catching and leaving it to null will just delay the exception to the runtime, can we just not catch it or if it's unchecked exception, we could wrap it into a runtime exception?
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.
Currently it doesn't throw a runtime exception, the autocreate just becomes a no-op (no eventtype gets created). Do you think it's better to fail here instead?
if (this.eventTypeLister == null) { | ||
logger.debug("no eventtype lister, creating eventtype and might run into failure"); | ||
return null; | ||
} |
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.
Should we fail fast here in the constructor?
return eventTypeCreator | ||
.create(event, reference) | ||
.onFailure((exception) -> { | ||
logger.warn("failure occured, closing informer", exception); |
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.
"occured" is a misspelling of "occurred"
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.
Good catch, thanks!
Signed-off-by: Calum Murray <cmurray@redhat.com>
/cc @pierDipi |
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
Signed-off-by: Calum Murray <cmurray@redhat.com>
/lgtm |
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: Cali0707, 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 |
/test reconciler-tests-namespaced-broker |
1 similar comment
/test reconciler-tests-namespaced-broker |
/retest-required |
/test reconciler-tests |
f85af06
into
knative-extensions:main
Fixes #3174 #3181
Proposed Changes
These changes work as follows:
Release Note
Docs