Skip to content

Update ApiServerSource#1175

Merged
knative-prow-robot merged 17 commits into
knative:masterfrom
n3wscott:k8s_source
May 9, 2019
Merged

Update ApiServerSource#1175
knative-prow-robot merged 17 commits into
knative:masterfrom
n3wscott:k8s_source

Conversation

@n3wscott
Copy link
Copy Markdown
Contributor

@n3wscott n3wscott commented May 7, 2019

Proposed Changes

  • do not use a controller to watch each type.
  • adds mode to ApiServerSource:
    • Ref (how it was)
    • Resource (full object contents.)

Release Note

Adds spec.mode to ApiServerSource.

@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 May 7, 2019
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 7, 2019
@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. labels May 7, 2019
@nachocano
Copy link
Copy Markdown
Contributor

/cc @nachocano

@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 8, 2019
@n3wscott n3wscott changed the title [WIP] Update ApiServerSource Update ApiServerSource May 8, 2019
@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 May 8, 2019
@n3wscott
Copy link
Copy Markdown
Contributor Author

n3wscott commented May 8, 2019

Follow-up to add event registry types.

@n3wscott
Copy link
Copy Markdown
Contributor Author

n3wscott commented May 8, 2019

/assign @lionelvillard

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@n3wscott: GitHub didn't allow me to assign the following users: lionelvillard.

Note that only knative members and repo collaborators can be assigned and that issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

/assign @lionelvillard

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.

@nachocano
Copy link
Copy Markdown
Contributor

Follow-up to add event registry types.

I have a working branch, need to properly set up the source and add some UTs.

@n3wscott
Copy link
Copy Markdown
Contributor Author

n3wscott commented May 8, 2019

/assign @vaikas-google

@n3wscott
Copy link
Copy Markdown
Contributor Author

n3wscott commented May 8, 2019

knative/eventing-contrib#404 removes the old k8s source.


// This is really bad.
gvr, _ := meta.UnsafeGuessKindToResource(gvk)
gvr, _ := meta.UnsafeGuessKindToResource(schema.GroupVersionKind{Kind: kind, Group: gv.Group, Version: gv.Version})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

re, the comment above, is there a TODO here?

Comment thread pkg/adapter/apiserver/adapter_test.go Outdated
go func() {
err = a.Start(stopCh)
}()
time.Sleep(1 * time.Millisecond)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this just to make sure we yield the processor? Perhaps use runtime.GoSched() instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it turns out the test does not work, I am not sure how to get the cache to do it's thing so I am going to skip the test with a TODO for now.

Comment thread pkg/adapter/apiserver/ref.go Outdated
if len(a.controlledGVRs) > 0 {
object := obj.(*unstructured.Unstructured)
gvk := object.GroupVersionKind()
// This is really bad.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TODO?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it is the tragedy of kubernetes.

// Mode is the mode the receive adapter controller runs under: Ref or Resource.
// `Ref` sends only the reference to the resource.
// `Resource` send the full resource.
Mode string `json:"mode,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be validated somewhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it defaults to ref if set to a random thing, see the Trash test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but it would be better if we could validate it when the resource is created.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah got it. How about we do a followup to wire in the event sources into the webhook and implement the validatable stuff?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread cmd/apiserver_receive_adapter/main.go
Comment thread pkg/adapter/apiserver/adapter.go Outdated
ListFunc: asUnstructuredLister(a.k8s.Resource(gvrc.GVR).Namespace(a.namespace).List),
WatchFunc: asUnstructuredWatcher(a.k8s.Resource(gvrc.GVR).Namespace(a.namespace).Watch),
}
informer = cache.NewSharedIndexInformer(lw, &unstructured.Unstructured{}, resyncPeriod, cache.Indexers{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@n3wscott have you considered getting rid of the informer altogether and use only Reflector?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a great idea. Thanks! Worked it in and updated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My understanding is that the informer will remove some possible duplicate information and give some serialization for us, but mayhaps for what we're doing here it's fine.

@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/adapter/apiserver/adapter.go Do not exist 76.7%
pkg/adapter/apiserver/events/events.go Do not exist 95.1%
pkg/adapter/apiserver/ref.go Do not exist 83.3%
pkg/adapter/apiserver/resource.go Do not exist 80.6%
pkg/apis/sources/v1alpha1/apiserver_types.go Do not exist 0.0%
pkg/reconciler/apiserversource/resources/receive_adapter.go Do not exist 100.0%

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented May 9, 2019

/approve

@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: n3wscott, vaikas-google

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [n3wscott,vaikas-google]

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

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented May 9, 2019

Leaving lgtm to @lionelvillard since he too had some comments about it so don't want to merge underneath...

@lionelvillard
Copy link
Copy Markdown
Contributor

it's working for me.

/lgtm

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@lionelvillard: changing LGTM is restricted to assignees, and only knative/eventing repo collaborators may be assigned issues.

Details

In response to this:

it's working for me.

/lgtm

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.

@nachocano
Copy link
Copy Markdown
Contributor

it's working for me.

/lgtm

let me try, apparently your lgtm didn't make it...

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label May 9, 2019
@knative-prow-robot knative-prow-robot merged commit fd45b55 into knative:master May 9, 2019
chizhg pushed a commit to chizhg/eventing that referenced this pull request May 13, 2019
* working through using the informer directly.

* getting closer.:

* working.

* cleanup.

* Working with controller flag.

* add todo.

* newline.

* fix the test.

* fix format.

* adding tests for event generation.

* Adding tests for ref and resource adapter event emitters.

* add adapter tests.

* trying to fix the tests but the cache is not playing with the fakes nicely.

* update lock.

* Use cache reflector.

* fix race.
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants