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

Switch filters to use rfc-3339 for time string encoding #7466

Merged

Conversation

Cali0707
Copy link
Member

@Cali0707 Cali0707 commented Nov 22, 2023

Fixes #7465

Currently, we are seeing some inconsistency on time comparisons with filters. This is because we are using a string representation of the time which is explicitly marked as:

The returned string is meant for debugging; for a stable serialized representation, use t.MarshalText, t.MarshalBinary, or t.Format with an explicit format string.

CloudEvents spec states that we should use RFC-3339 for encoding timestamps as strings:
https://github.com/cloudevents/spec/blob/130ba0d183f5e45c1d141f5c1f272cf71d898623/cloudevents/spec.md?plain=1#L244

This PR switches our time.Time.String calls with code that converts the time.Time to RFC-3339 compliant strings.

Proposed Changes

  • Use RFC 3339 encoding for all time strings in filter comparisons

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note

Filters now use RFC-3339 compliant string encodings for attributes of type time.

Docs

Signed-off-by: Calum Murray <cmurray@redhat.com>
@knative-prow knative-prow bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 22, 2023
@Cali0707
Copy link
Member Author

/cc @pierDipi

should we backport this?

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 22, 2023
Copy link

codecov bot commented Nov 22, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (64b4847) 76.79% compared to head (ac94eea) 76.68%.
Report is 18 commits behind head on main.

Files Patch % Lines
pkg/eventfilter/attributes/filter.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7466      +/-   ##
==========================================
- Coverage   76.79%   76.68%   -0.11%     
==========================================
  Files         253      253              
  Lines       14098    14173      +75     
==========================================
+ Hits        10826    10869      +43     
- Misses       2732     2751      +19     
- Partials      540      553      +13     

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

@Cali0707
Copy link
Member Author

/hold until I add some tests to make sure the issue is resolved

@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 Nov 23, 2023
@pierDipi
Copy link
Member

/cc @pierDipi

should we backport this?

Yes

Signed-off-by: Calum Murray <cmurray@redhat.com>
@knative-prow knative-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 23, 2023
@Cali0707
Copy link
Member Author

/unhold
Per conversation here, we won't be backporting this fix as it will be a breaking change

@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 Nov 23, 2023
Signed-off-by: Calum Murray <cmurray@redhat.com>
@Cali0707
Copy link
Member Author

/retest-required

@Cali0707 Cali0707 requested a review from matzew November 29, 2023 13:55
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 Dec 5, 2023
Copy link

knative-prow bot commented Dec 5, 2023

[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

Cali0707 commented Dec 5, 2023

/retest-required

@Cali0707
Copy link
Member Author

Cali0707 commented Dec 5, 2023

/test reconciler-tests

@knative-prow knative-prow bot merged commit 2ee2699 into knative:main Dec 5, 2023
38 of 41 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. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve exact time comparison
3 participants