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

Apiserversource defaults conversion #3616

Conversation

capri-xiyue
Copy link
Contributor

Helps #3611

Proposed Changes

  • 🎁 Adding ApiServerSource v1beta1 defaults and conversion.
None

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 16, 2020
@knative-prow-robot knative-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 16, 2020
@capri-xiyue
Copy link
Contributor Author

capri-xiyue commented Jul 16, 2020

/hold wait until #3614 gets merged and then rebase

@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 Jul 16, 2020
@capri-xiyue capri-xiyue changed the title Apiserversource defaults conversion [WIP]Apiserversource defaults conversion Jul 16, 2020
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 16, 2020
@capri-xiyue
Copy link
Contributor Author

/assign @nachocano @lionelvillard

@capri-xiyue
Copy link
Contributor Author

The coverage is low is because pkg/apis/sources/v1alpha2/apiserver_conversion.go.
I don't add additional UT to it because all needed UT has been covered in pkg/apis/sources/v1alpha1/apiserver_conversion_test.go

@capri-xiyue
Copy link
Contributor Author

capri-xiyue commented Jul 17, 2020

Got kind of confused because the coding style when doing conversion is not quite consistent in the codebase.
For example in the codebase
Both CloudEventOverrides and ResourceOwner are pointer. Sometimes we use deep copy, sometimes we don't.
I thought as long as the object is a pointer or the struct contains pointer or array, we should use deep copy when doing conversion. But I checked the codebase, it's quite inconsistent. Not sure whether deep copy really matters when doing conversion.
Or deep copy is just a good habit when doing conversion.
Please correct me if I'm wrong.

sink.Spec.CloudEventOverrides = source.Spec.CloudEventOverrides

if source.Spec.CloudEventOverrides != nil {

if source.Spec.ResourceOwner != nil {

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 17, 2020
@capri-xiyue
Copy link
Contributor Author

/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 Jul 17, 2020
@capri-xiyue capri-xiyue changed the title [WIP]Apiserversource defaults conversion Apiserversource defaults conversion Jul 17, 2020
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2020
@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/apis/sources/v1alpha2/apiserver_conversion.go 100.0% 39.0% -61.0

},
URI: path,
}
sinkUri, _ := apis.ParseURL("http://example.com/path")
Copy link
Member

Choose a reason for hiding this comment

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

You can use apis.HTTP() here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

apis.ParseURL is used in a lot of places in the codebase. I will just keep it for now. We can change all of them in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

another clean up issue created #3623


tests := []struct {
name string
in apis.Convertible
Copy link
Member

Choose a reason for hiding this comment

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

Changing this with *v1beta1.ApiServerSource could make things easier later.
Examples I saw so far are like that.
But not a big deal.

Copy link
Contributor Author

@capri-xiyue capri-xiyue Jul 17, 2020

Choose a reason for hiding this comment

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

I followed the

here. I think at first we use apis.Convertible so that we will be able provide different versions of sources as in. But now we use proxy when doing the conversion and the api v1beta1 and v1alpha2 apiserversource are the same, therefore if the in in the UT is the highest verison, when it does conversion, it will also test the conversion between middle versions and lowest version, so both *v1beta1.ApiServerSource and apis.Convertible work

Copy link
Contributor Author

@capri-xiyue capri-xiyue Jul 17, 2020

Choose a reason for hiding this comment

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

For now, I will keep apis.Convertible since it's more flexible

Copy link
Member

@aliok aliok left a comment

Choose a reason for hiding this comment

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

/lgtm

Added some minor comments, feel free to skip it

@lionelvillard
Copy link
Member

DeepCopy is not needed in the conversion code.

@nachocano
Copy link
Contributor

/lgtm
/approve

@capri-xiyue can you address @aliok comments in the reconciler/e2e follow up?
If DeepCopy is not needed as @lionelvillard mentioned, I think it might be worth creating a separate issue to track it, and change everywhere. I think we are DeepCopying in multiple places, not just sources.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 17, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aliok, capri-xiyue, nachocano

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 17, 2020
@capri-xiyue
Copy link
Contributor Author

/lgtm
/approve

@capri-xiyue can you address @aliok comments in the reconciler/e2e follow up?
If DeepCopy is not needed as @lionelvillard mentioned, I think it might be worth creating a separate issue to track it, and change everywhere. I think we are DeepCopying in multiple places, not just sources.

#3622 and #3623 created

@nachocano
Copy link
Contributor

nachocano commented Jul 17, 2020 via email

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-knative-eventing-integration-tests 0/3
pull-knative-eventing-upgrade-tests 0/3

Failed non-flaky tests preventing automatic retry of pull-knative-eventing-upgrade-tests:

test/upgrade.TestPreUpgrade
test/upgrade.TestPreUpgrade/InMemoryChannel-messaging.knative.dev/v1beta1

@capri-xiyue
Copy link
Contributor Author

/test pull-knative-eventing-upgrade-tests

@knative-prow-robot knative-prow-robot merged commit 5f23f34 into knative:master Jul 17, 2020
@aliok aliok mentioned this pull request Sep 25, 2020
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. cla: yes Indicates the PR's author has signed the CLA. 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.

8 participants