move apiserver source to eventing#1108
Conversation
|
Hi @lionelvillard. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
vaikas
left a comment
There was a problem hiding this comment.
Thanks for doing this! Super useful!!!
| type: object | ||
| spec: | ||
| properties: | ||
| serviceAccountName: |
There was a problem hiding this comment.
Can we add a "description" to all these fields? Most of the existing ones don't specify them, but we should so that you get a more descriptive message what these fields are. This can be done as a follow on, just jotting it down as I see them.
| for { | ||
| stri := strconv.Itoa(i) | ||
|
|
||
| apiVersion, defined := os.LookupEnv(envAPIVersion + stri) |
There was a problem hiding this comment.
I'd use this package for env variables.
"github.com/kelseyhightower/envconfig"
You can see a use here:
https://github.com/vaikas-google/twitter/blob/master/cmd/source/main.go#L26
Filing an issue and doing in a follow up is totes fine. If you do this, please tag it as good first issue.
|
|
||
| // OwnerReferences is the list of dependents to watch. | ||
| // Only APIVersion and Kind are used. The other fields are ignored. | ||
| OwnerReferences []metav1.OwnerReference `json:"ownerReferences"` |
There was a problem hiding this comment.
Why is this OwnerReference instead of ObjectReference?
There was a problem hiding this comment.
Because of the Controller field in OwnerReference. It's not currently used but eventually it will.
|
|
||
| "github.com/knative/eventing/pkg/adapter/apiserver" | ||
| _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" | ||
| "sigs.k8s.io/controller-runtime/pkg/client/config" |
There was a problem hiding this comment.
We're getting rid of the controller-runtime, so this should really be using the knative/pkg controller. I'd really prefer to do this before merging so we don't then have to migrate it later. Thoughts?
There was a problem hiding this comment.
I thought I could get away with this since this belongs to the receiver only. I'm fine removing the dependency on controller-runtime and migrate to pkg/controller
Out of curiosity, what the rationale behind the decision of getting rid of controller-runtime?
| return err | ||
| } | ||
|
|
||
| // Create one controller per watch |
There was a problem hiding this comment.
Why are we creating controllers for everything and not just create cache informers for each one that we care about? handler is all the same?
There was a problem hiding this comment.
the handler state is not the same: the gvk is different. Maybe by using pkg/controller we can use one controller.
There was a problem hiding this comment.
I was trying to say that we do not need a controller at all. You can just construct a duck type that watches for duck type that's type/objectmeta and just register handlers for each of them. So, in your main you'd construct a kubeclient (like the k8s watcher does today), then create a dynamic client:
"k8s.io/client-go/dynamic"
dynamicClient, err := dynamic.NewForConfig(cfg)
Then for each type that you need, you'd create one of these:
tif := &duck.TypedInformerFactory{
Client: dynamicClient,
Type: &<DUCK_TYPE_FOR_ALL_OBJECTS>,
ResyncPeriod: resyncPeriod,
StopChannel: stopCh,
}
for each of the watched object gvk {
gvr, _ := meta.UnsafeGuessKindToResource(gvk)
informer, lister, err := psif.Get(gvr)
informer.AddEventHandler(AddFunc: messageSender, UpdateFunc: messageSender, DeleteFunc: messageSender)
}
There was a problem hiding this comment.
We still need to create a controller in order to process multiple events concurrently. processorListener runs in one go routine only. Am I missing something?
There was a problem hiding this comment.
I think we need at least one deployment per service account. It could be something we optimize later.
There was a problem hiding this comment.
Ok I understand what Ville is saying a bit better now. The issue here is there is no need for the controller. This can just be a kube client and a dynamic.Interface that sets up duck.TypedInformerFactory
There was a problem hiding this comment.
Also, don't use processorListener, use the informer cache.
There was a problem hiding this comment.
I'm using the informer cache directly which under the cover uses processorListener. I also refactored the code to use dynamic.Interface and duck.TypedInformerFactory (not pushed yet). I still think the controller is needed to process events concurrently.
| apiserversource.NewController( | ||
| opt, | ||
| apiserverSourceInformer, | ||
| deploymentInformer, |
There was a problem hiding this comment.
Could we just pass the RA Image here instead of buried in the controller?
There was a problem hiding this comment.
I guess this is a general issue applying to other sources, like cronjob
| "k8s.io/apimachinery/pkg/api/errors" | ||
| "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" |
There was a problem hiding this comment.
Can we change this to use knative/pkg controller instead of controller runtime?
| return nil | ||
| } | ||
|
|
||
| func (r *Reconciler) getReceiveAdapterImage() string { |
There was a problem hiding this comment.
I'd prefer that we grab this in the main package and fail there if it's not around. Also I'd prefer we pass it into this method directly instead of panicing here.
There was a problem hiding this comment.
I guess this is a general issue applying to other sources, like cronjob
There was a problem hiding this comment.
Yeah, seems bad to me :) We should fix them all.
|
/ok-to-test |
35a24a4 to
e9e9675
Compare
1d70833 to
079f278
Compare
|
@vaikas-google @n3wscott I removed the dependency on I didn't implemented any e2e tests yet. I'm not sure yet how to do that. |
1cde8ee to
7bd6551
Compare
|
|
||
| event := cloudevents.Event{ | ||
| Context: cloudevents.EventContextV02{ | ||
| ID: string(object.GetUID()), |
There was a problem hiding this comment.
object.GetUID() will always return the same value so the cloudevent will not be unique.
There was a problem hiding this comment.
it satisfies https://github.com/cloudevents/spec/blob/v0.2/spec.md#id constraints, in particular MUST be unique within the scope of the producer. @n3wscott what is your concern?
|
the error is |
7bd6551 to
f077339
Compare
f077339 to
8dcada8
Compare
|
The following is the coverage report on pkg/.
|
|
Thanks a bunch! I think we should start with this and try it out, add some e2e tests... /lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lionelvillard, n3wscott The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
As a follow-up can you delete the api server source from eventing-sources? |
Proposed Changes