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

Update eventtype v1beta3 type to reflect spec changes #7708

Merged
merged 8 commits into from
Mar 27, 2024

Conversation

Cali0707
Copy link
Member

Part of #7265

Proposed Changes

  • Update the eventtype CRD to have the new v1beta3 schema
  • Update the eventtype v1beta3 type and validation to reflect the new schema
  • Fix unit tests

@knative-prow knative-prow bot requested review from aliok and Leo6Leo February 20, 2024 16:36
@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 20, 2024
@Cali0707
Copy link
Member Author

/cc @dsimansk @matzew @pierDipi

Copy link

codecov bot commented Feb 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.22%. Comparing base (580f3c7) to head (2c3a610).
Report is 29 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7708      +/-   ##
==========================================
+ Coverage   69.04%   69.22%   +0.17%     
==========================================
  Files         338      339       +1     
  Lines       19350    19494     +144     
==========================================
+ Hits        13360    13494     +134     
- Misses       5328     5337       +9     
- Partials      662      663       +1     

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

Comment on lines 76 to 84
type EventAttributeDefinition struct {
// Required determines whether this attribute must be set on corresponding CloudEvents.
Required bool `json:"required"`
// Value is a string representing the allowable values for the EventType attribute.
// It may be a single value such as "/apis/v1/namespaces/default/pingsource/ps", or it could be a template
// for the allowed values, such as "/apis/v1/namespaces/{namespace}/pingsource/{sourceName}.
// To specify a section of the string value which may change between different CloudEvents
// you can use curly brackets {} and optionally a variable name between them.
Value string `json:"value,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I'd argue that the original proposed name is useful, to identify what the attr def is is about, is useful. see:

spec:
  attributes:
    - name: type
      value: com.shop.domain.order.new
      required: true
    - name: specversion
      value: "1.0"
    - name: id
      required: true
    - name: source
      value: "/customer-system/node/some-id-value"
    - name: time
      required: true
    - name: myextension
      required: false
...

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense @matzew , I was basing this off of your earlier WIP PR, where I think this would end up mapping to a CRD like:

spec:
  attributes:
    type:
      value: com.shop.domain.order.new
      required: true
    specversion:
      value: "1.0"

...

If you think the proposed version with name makes more sense, I'm happy to update this to reflect that idea instead - I just had guessed that the PR was a "newer" version of the idea than the issue :)

@Cali0707
Copy link
Member Author

/cc @matzew @pierDipi @dsimansk

@knative-prow knative-prow bot requested a review from matzew February 27, 2024 16:05
@@ -22,6 +22,132 @@ metadata:
spec:
group: eventing.knative.dev
versions:
- name: v1beta3
served: false
Copy link
Contributor

Choose a reason for hiding this comment

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

The new version is not served as a precaution for now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I figured we could serve it when we update the reconciler to reconcile the new type

Name string `json:"name"`
// Required determines whether this attribute must be set on corresponding CloudEvents.
Required bool `json:"required"`
// Value is a string representing the allowable values for the EventType attribute.
Copy link
Contributor

Choose a reason for hiding this comment

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

Allowed values are derived from CloudEvent Spec? Should we have a mechanism to specify validation ruleset or validation strictness perhaps?

/cc @pierDipi @matzew

Copy link
Member Author

Choose a reason for hiding this comment

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

@dsimansk I was thinking maybe something like #7729 could work? This way various eventtype producers could provide rules/guidance over what potential values their eventtype attribute would have.

Copy link
Contributor

@dsimansk dsimansk left a comment

Choose a reason for hiding this comment

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

@Cali0707 thanks for taking over this part! Looks good to me, I've added 2 question in the review, but none is a blocker to be resolved for the merge.

Adding hold for other reviews.
/hold

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 28, 2024
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 28, 2024
@Cali0707
Copy link
Member Author

/cc @matzew @pierDipi

Any thoughts on this PR? Can we unhold, or are there more changes needed?

Schema: testSchema,
Attributes: []EventAttributeDefinition{
EventAttributeDefinition{
Value: "test-type",
Copy link
Member

Choose a reason for hiding this comment

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

would name not also really make sense here?

should we require name? for the attr def?

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

/cc @matzew @dsimansk

@knative-prow knative-prow bot requested a review from dsimansk March 18, 2024 16:38
items:
type: object
required:
- name
Copy link
Member

Choose a reason for hiding this comment

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

isn't value also required ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not currently, no. Currently you can just add a name and whether or not that attribute is required without specifying what value it may have. I think of this as a way of saying "the event may have attribute xyz". But, I could understand making this field required too. WDYT we should do @pierDipi ?

Copy link
Member

Choose a reason for hiding this comment

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

yes, that is exactly what I was thinking too. IMO this is useful for "extensions",

the following is IMO valid:

    - name: myextension
      required: false

while some attribute names are requied to have a value (e.g. all the CE "required" attrs)

Comment on lines 132 to 135
jsonPath: ".spec.attributes.type.value"
- name: Source
type: string
jsonPath: ".spec.attributeds.source.value"
Copy link
Member

Choose a reason for hiding this comment

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

I don't see these 2 attributes

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah good catch! I wrote these when we were using a map to hold all the attributes, rather than an array

@Cali0707
Copy link
Member Author

/cc @pierDipi

@knative-prow knative-prow bot requested a review from pierDipi March 25, 2024 12:53
@matzew
Copy link
Member

matzew commented Mar 25, 2024

/test reconciler-tests

Comment on lines +73 to +78
if _, ok := attributes["specversion"]; !ok {
missingFields = append(missingFields, "specversion")
}
if _, ok := attributes["id"]; !ok {
missingFields = append(missingFields, "id")
}
Copy link
Member

@pierDipi pierDipi Mar 25, 2024

Choose a reason for hiding this comment

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

I'm wondering that to make the usage easier we could have id and specversion be optional even if it's technically required

Copy link
Member

Choose a reason for hiding this comment

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

but I think starting with required is fine as making it optional would be a non-breaking change while the opposite is not true

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense to me, especially if id is going to just be a UUID, and specversion will probably just be 1.0

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 Mar 25, 2024
Copy link

knative-prow bot commented Mar 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707, dsimansk, 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:
  • OWNERS [Cali0707,dsimansk,pierDipi]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pierDipi
Copy link
Member

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 27, 2024
@pierDipi
Copy link
Member

/test reconciler-tests

@knative-prow knative-prow bot merged commit e581d36 into knative:main Mar 27, 2024
33 of 39 checks passed
@Cali0707
Copy link
Member Author

/test reconciler-tests

Copy link

knative-prow bot commented Mar 27, 2024

@Cali0707: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
reconciler-tests_eventing_main 2c3a610 link unknown /test reconciler-tests

Your PR dashboard.

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. I understand the commands that are listed here.

@Cali0707
Copy link
Member Author

/test reconciler-tests

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. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants