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

Cleanup channel template internal types #4749

Merged

Conversation

slinkydeveloper
Copy link
Contributor

While working on #4652, we found out that we have these internal types, necessary to implement some duck typing magic, that are implementation details that shouldn't be exposed and shouldn't be versioned. This PR cleanup that code and adds a single entrypoint to create from the various ducks a physical channel, removing the various duplicated code in each controller.

Signed-off-by: Francesco Guardiani francescoguard@gmail.com

Proposed Changes

  • 🧹 Cleanup channel internal templates and moved logic to create physical channel in eventing/pkg/duck

Release Note

Cleanup channel duck types internals

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Jan 15, 2021
@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release Test infrastructure, tests or release labels Jan 15, 2021
@devguyio
Copy link
Contributor

/assign

@vaikas
Copy link
Contributor

vaikas commented Jan 15, 2021

I'm loving the red lines. Could you add more comprehensive UT so we get more coverage?

@codecov
Copy link

codecov bot commented Jan 15, 2021

Codecov Report

Merging #4749 (f05842a) into master (8e0e286) will increase coverage by 0.14%.
The diff coverage is 78.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4749      +/-   ##
==========================================
+ Coverage   81.11%   81.25%   +0.14%     
==========================================
  Files         291      291              
  Lines        8239     8281      +42     
==========================================
+ Hits         6683     6729      +46     
+ Misses       1156     1143      -13     
- Partials      400      409       +9     
Impacted Files Coverage Δ
pkg/reconciler/mtbroker/resources/channel.go 100.00% <ø> (+8.33%) ⬆️
pkg/duck/channel.go 54.54% <54.54%> (ø)
pkg/reconciler/channel/channel.go 71.60% <100.00%> (+4.46%) ⬆️
pkg/reconciler/mtbroker/broker.go 80.46% <100.00%> (+2.02%) ⬆️
pkg/reconciler/parallel/parallel.go 58.82% <100.00%> (+3.77%) ⬆️
pkg/reconciler/sequence/sequence.go 71.00% <100.00%> (+3.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e0e286...ce87ac2. Read the comment docs.

Copy link
Contributor

@devguyio devguyio left a comment

Choose a reason for hiding this comment

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

Just a comment about maybe trying to document the channel duck package more. +1 on more UT coverage. Other than that, lgtm.


duckv1 "knative.dev/eventing/pkg/apis/duck/v1"
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, seeing this is very essential package in eventing pkg to be used in gazillion of other components, I think it would be great to add a more detailed generic comment explaining the context here. Example points to cover:

  • What is the physical channel?
  • How do the different structs relate to the Channel type.
  • Maybe with an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point, let me add some additional docs to NewPhysicalChannel so it explains why this thing is important

@slinkydeveloper
Copy link
Contributor Author

@vaikas now the tests should cover a good amount of code
@devguyio added a big godoc block that should answer your questions

@slinkydeveloper
Copy link
Contributor Author

/retest

},
},
},
"KafkaChannel": {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems okay to remove some of these tests, especially the KafkaChannel test, as it should be the responsibility of eventing-kafka. But there seem to be other things being thrown out by removing this test entirely, e.g., the BrokerChannelName check. Any reason for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason is that the tested function here doesn't exist anymore. There is still a test for BrokerChannelName

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. And the OwnerReferences test done by assertSoleOwner?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

assertSoleOwner was an assert executed by the deleted test, and note that now the OwnerReferences is set by the caller of NewPhysicalChannel

@slinkydeveloper
Copy link
Contributor Author

/retest

…venting/pkg/duck module

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/duck/channel.go Do not exist 76.7%
pkg/reconciler/mtbroker/resources/channel.go 90.0% 100.0% 10.0

@vaikas
Copy link
Contributor

vaikas commented Jan 18, 2021

/lgtm
/approve
/hold
since @devguyio had some comments as well, if you're ok with the changes requested, just remove the hold.

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 18, 2021
@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2021
Copy link
Contributor

@devguyio devguyio left a comment

Choose a reason for hiding this comment

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

great work!
/lgtm
/unhold

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 18, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: devguyio, slinkydeveloper, vaikas

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 [slinkydeveloper,vaikas]

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

@slinkydeveloper
Copy link
Contributor Author

/retest
some flakyness not related to this pr

@knative-prow-robot knative-prow-robot merged commit d395f6f into knative:master Jan 18, 2021
@slinkydeveloper slinkydeveloper deleted the cleanup_template_duck_types branch January 18, 2021 11:33
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/test-and-release Test infrastructure, tests or release cla: yes Indicates the PR's author has signed the CLA. 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.

6 participants