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

use the correct informer/lister pair #123

Merged
merged 1 commit into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ require (
go.uber.org/zap v1.15.0
golang.org/x/tools v0.0.0-20200929223013-bf155c11ec6f // indirect
gotest.tools v2.2.0+incompatible
honnef.co/go/tools v0.0.1-2020.1.5 // indirect
k8s.io/api v0.18.8
k8s.io/apiextensions-apiserver v0.18.8 // indirect
k8s.io/apimachinery v0.18.8
k8s.io/client-go v12.0.0+incompatible
k8s.io/code-generator v0.18.8
k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
knative.dev/eventing v0.18.1-0.20201012172617-7d981f818ef0
knative.dev/pkg v0.0.0-20201012163217-54ad6c6d39a7
knative.dev/test-infra v0.0.0-20201009204121-322fb08edae7
knative.dev/eventing v0.18.1-0.20201013101330-20784916d379
knative.dev/pkg v0.0.0-20201013083930-bcdd7509c05f
knative.dev/test-infra v0.0.0-20201013072830-525526118518
)

replace (
Expand Down
12 changes: 9 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ github.com/google/go-containerregistry v0.0.0-20200115214256-379933c9c22b/go.mod
github.com/google/go-containerregistry v0.0.0-20200123184029-53ce695e4179/go.mod h1:Wtl/v6YdQxv397EREtzwgd9+Ud7Q5D8XMbi3Zazgkrs=
github.com/google/go-containerregistry v0.0.0-20200331213917-3d03ed9b1ca2/go.mod h1:pD1UFYs7MCAx+ZLShBdttcaOSbyc8F9Na/9IZLNwJeA=
github.com/google/go-containerregistry v0.1.1/go.mod h1:npTSyywOeILcgWqd+rvtzGWflIPPcBQhYoOONaY4ltM=
github.com/google/go-containerregistry v0.1.3/go.mod h1:3Wg/Hjgn/ZDxrYYhtzZJWdThOd8zeI2zAmn4oVfm1Wg=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-github/v27 v27.0.6 h1:oiOZuBmGHvrGM1X9uNUAUlLgp5r1UUO/M/KnbHnLRlQ=
Expand Down Expand Up @@ -1646,6 +1647,7 @@ golang.org/x/tools v0.0.0-20200731060945-b5fad4ed8dd6/go.mod h1:njjCfa9FT2d7l9Bc
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200828161849-5deb26317202/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/tools v0.0.0-20200929223013-bf155c11ec6f h1:7+Nz9MyPqt2qMCTvNiRy1G0zYfkB7UCa+ayT6uVvbyI=
golang.org/x/tools v0.0.0-20200929223013-bf155c11ec6f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down Expand Up @@ -1947,8 +1949,8 @@ k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7Mpm
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
knative.dev/caching v0.0.0-20190719140829-2032732871ff/go.mod h1:dHXFU6CGlLlbzaWc32g80cR92iuBSpsslDNBWI8C7eg=
knative.dev/caching v0.0.0-20200116200605-67bca2c83dfa/go.mod h1:dHXFU6CGlLlbzaWc32g80cR92iuBSpsslDNBWI8C7eg=
knative.dev/eventing v0.18.1-0.20201012172617-7d981f818ef0 h1:xaxzN7rw7b8138EPO0aRxnzBtcQ7+ZZQZLVuxnFhA/A=
knative.dev/eventing v0.18.1-0.20201012172617-7d981f818ef0/go.mod h1:XauX28MhTjF3pmC0TK6wQS5uPfBnFYlfFKw9wdsxnws=
knative.dev/eventing v0.18.1-0.20201013101330-20784916d379 h1:CEUHlLaYqUFyaV6ucP14ai89MkfshirVsqDMp54dhWk=
knative.dev/eventing v0.18.1-0.20201013101330-20784916d379/go.mod h1:dIbqoAIH478sSQtf0fYqASQTSqMWlCpVsE7doUl8kck=
knative.dev/eventing-contrib v0.6.1-0.20190723221543-5ce18048c08b/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g=
knative.dev/eventing-contrib v0.11.2/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g=
knative.dev/pkg v0.0.0-20191101194912-56c2594e4f11/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
Expand All @@ -1959,16 +1961,20 @@ knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaC
knative.dev/pkg v0.0.0-20200515002500-16d7b963416f/go.mod h1:tMOHGbxtRz8zYFGEGpV/bpoTEM1o89MwYFC4YJXl3GY=
knative.dev/pkg v0.0.0-20200528142800-1c6815d7e4c9/go.mod h1:QgNZTxnwpB/oSpNcfnLVlw+WpEwwyKAvJlvR3hgeltA=
knative.dev/pkg v0.0.0-20200711004937-22502028e31a/go.mod h1:AqAJV6rYi8IGikDjJ/9ZQd9qKdkXVlesVnVjwx62YB8=
knative.dev/pkg v0.0.0-20201012033616-18350095f500/go.mod h1:jF4YcBevlRFKFChkMhmMyyf5HzTQRssqV/dKNaDajiw=
knative.dev/pkg v0.0.0-20201012163217-54ad6c6d39a7 h1:5wPnSasRXIh/nMLZJNYtEVxLs/f4dFlWsAxSI+irm0w=
knative.dev/pkg v0.0.0-20201012163217-54ad6c6d39a7/go.mod h1:jF4YcBevlRFKFChkMhmMyyf5HzTQRssqV/dKNaDajiw=
knative.dev/pkg v0.0.0-20201012221417-e3b4e9c22943/go.mod h1:jF4YcBevlRFKFChkMhmMyyf5HzTQRssqV/dKNaDajiw=
knative.dev/pkg v0.0.0-20201013083930-bcdd7509c05f h1:aP0cCf/toE2Sz/cIhiju3hkdideWgJSo7xev/YYcY8I=
knative.dev/pkg v0.0.0-20201013083930-bcdd7509c05f/go.mod h1:jF4YcBevlRFKFChkMhmMyyf5HzTQRssqV/dKNaDajiw=
knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU=
knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9/go.mod h1:A5b2OAXTOeHT3hHhVQm3dmtbuWvIDP7qzgtqxA3/2pE=
knative.dev/test-infra v0.0.0-20200707183444-aed09e56ddc7/go.mod h1:RjYAhXnZqeHw9+B0zsbqSPlae0lCvjekO/nw5ZMpLCs=
knative.dev/test-infra v0.0.0-20201009204121-322fb08edae7 h1:2peeccxecZH3kBH8g9U+We3kjstgX8LLloO//ndrxnQ=
knative.dev/test-infra v0.0.0-20201009204121-322fb08edae7/go.mod h1:W4EfffNKnIkYuBHdOjw0UP3YtFbK4ImwDiEoIAbG1zk=
knative.dev/test-infra v0.0.0-20201013072830-525526118518 h1:+W1I52bvqwalVPGqPJPAn5m3PsldmABwv49HedQLhNs=
knative.dev/test-infra v0.0.0-20201013072830-525526118518/go.mod h1:lm0U0k6ARXr8Po0LcSTCfETg63LOF3ajUxcoqy5JSH0=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/trigger/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
triggerreconciler "knative.dev/eventing/pkg/client/injection/reconciler/eventing/v1/trigger"
"knative.dev/eventing/pkg/duck"
"knative.dev/pkg/client/injection/ducks/duck/v1/addressable"
"knative.dev/pkg/client/injection/ducks/duck/v1/conditions"
"knative.dev/pkg/client/injection/ducks/duck/v1/source"
deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment"

"knative.dev/pkg/configmap"
Expand Down Expand Up @@ -92,7 +92,7 @@ func NewController(

logging.FromContext(ctx).Info("Setting up event handlers")

r.kresourceTracker = duck.NewListableTracker(ctx, conditions.Get, impl.EnqueueKey, controller.GetTrackerLease(ctx))
r.sourceTracker = duck.NewListableTracker(ctx, source.Get, impl.EnqueueKey, controller.GetTrackerLease(ctx))
r.addressableTracker = duck.NewListableTracker(ctx, addressable.Get, impl.EnqueueKey, controller.GetTrackerLease(ctx))
r.uriResolver = resolver.NewURIResolver(ctx, impl.EnqueueKey)

Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/trigger/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
_ "knative.dev/eventing/pkg/client/injection/informers/eventing/v1/broker/fake"
_ "knative.dev/eventing/pkg/client/injection/informers/eventing/v1/trigger/fake"
_ "knative.dev/pkg/client/injection/ducks/duck/v1/addressable/fake"
_ "knative.dev/pkg/client/injection/ducks/duck/v1/conditions/fake"
_ "knative.dev/pkg/client/injection/ducks/duck/v1/source/fake"
_ "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment/fake"
_ "knative.dev/pkg/client/injection/kube/informers/core/v1/configmap/fake"
_ "knative.dev/pkg/injection/clients/dynamicclient/fake"
Expand Down
8 changes: 4 additions & 4 deletions pkg/reconciler/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type Reconciler struct {
brokerClass string

// Dynamic tracker to track KResources. In particular, it tracks the dependency between Triggers and Sources.
kresourceTracker duck.ListableTracker
sourceTracker duck.ListableTracker

// Dynamic tracker to track AddressableTypes. In particular, it tracks Trigger subscribers.
addressableTracker duck.ListableTracker
Expand Down Expand Up @@ -299,7 +299,7 @@ func (r *Reconciler) checkDependencyAnnotation(ctx context.Context, t *eventingv
t.Status.MarkDependencyFailed("ReferenceError", "Unable to unmarshal objectReference from dependency annotation of trigger: %v", err)
return fmt.Errorf("getting object ref from dependency annotation %q: %v", dependencyAnnotation, err)
}
trackKResource := r.kresourceTracker.TrackInNamespace(ctx, t)
trackKResource := r.sourceTracker.TrackInNamespace(ctx, t)
// Trigger and its dependent source are in the same namespace, we already did the validation in the webhook.
if err := trackKResource(dependencyObjRef); err != nil {
return fmt.Errorf("tracking dependency: %v", err)
Expand All @@ -314,7 +314,7 @@ func (r *Reconciler) checkDependencyAnnotation(ctx context.Context, t *eventingv
}

func (r *Reconciler) propagateDependencyReadiness(ctx context.Context, t *eventingv1.Trigger, dependencyObjRef corev1.ObjectReference) error {
lister, err := r.kresourceTracker.ListerFor(dependencyObjRef)
lister, err := r.sourceTracker.ListerFor(dependencyObjRef)
if err != nil {
t.Status.MarkDependencyUnknown("ListerDoesNotExist", "Failed to retrieve lister: %v", err)
return fmt.Errorf("retrieving lister: %v", err)
Expand All @@ -328,7 +328,7 @@ func (r *Reconciler) propagateDependencyReadiness(ctx context.Context, t *eventi
}
return fmt.Errorf("getting the dependency: %v", err)
}
dependency := dependencyObj.(*duckv1.KResource)
dependency := dependencyObj.(*duckv1.Source)

// The dependency hasn't yet reconciled our latest changes to
// its desired state, so its conditions are outdated.
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/trigger/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
v1addr "knative.dev/pkg/client/injection/ducks/duck/v1/addressable"
"knative.dev/pkg/client/injection/ducks/duck/v1/conditions"
"knative.dev/pkg/client/injection/ducks/duck/v1/source"
v1a1addr "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/addressable"
v1b1addr "knative.dev/pkg/client/injection/ducks/duck/v1beta1/addressable"
fakekubeclient "knative.dev/pkg/client/injection/kube/client/fake"
Expand Down Expand Up @@ -688,7 +688,7 @@ func TestReconcile(t *testing.T) {
ctx = v1a1addr.WithDuck(ctx)
ctx = v1b1addr.WithDuck(ctx)
ctx = v1addr.WithDuck(ctx)
ctx = conditions.WithDuck(ctx)
ctx = source.WithDuck(ctx)
fakeServer := server.NewServer(rabbitURL)
fakeServer.Start()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -702,7 +702,7 @@ func TestReconcile(t *testing.T) {
brokerLister: listers.GetBrokerLister(),
triggerLister: listers.GetTriggerLister(),
deploymentLister: listers.GetDeploymentLister(),
kresourceTracker: duck.NewListableTracker(ctx, conditions.Get, func(types.NamespacedName) {}, 0),
sourceTracker: duck.NewListableTracker(ctx, source.Get, func(types.NamespacedName) {}, 0),
addressableTracker: duck.NewListableTracker(ctx, v1addr.Get, func(types.NamespacedName) {}, 0),
uriResolver: resolver.NewURIResolver(ctx, func(types.NamespacedName) {}),
brokerClass: "RabbitMQBroker",
Expand Down
5 changes: 0 additions & 5 deletions vendor/github.com/BurntSushi/toml/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions vendor/github.com/BurntSushi/toml/.travis.yml

This file was deleted.

3 changes: 0 additions & 3 deletions vendor/github.com/BurntSushi/toml/COMPATIBLE

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/BurntSushi/toml/COPYING

This file was deleted.

19 changes: 0 additions & 19 deletions vendor/github.com/BurntSushi/toml/Makefile

This file was deleted.

Loading