Commit Graph

13 Commits

Author SHA1 Message Date
Matt Moore 6d806b9983 Add support for Selector in tracker.Reference. (#861)
* Add support for Selector in tracker.Reference.

`tracker.Reference` may now optionally replace `Name` with `Selector` to track zero or multiple resources of a particular `apiVersion`, `kind` and `namespace`.

Fixes: https://github.com/knative/pkg/issues/859

* Address code review comments
2019-11-11 07:05:21 -08:00
Matt Moore a805b647f3 Expand the tracker interface to include a variant with its own type. (#860)
`TrackReference` is the same as `Track`, but takes a `tracker.Reference` instead.  This type has been seeded with the subset of `corev1.ObjectReference` that the tracker currently consumes / supports, but the intention is to expand this type to allow inexact references that (optionally) use label selectors in place of name to reference objects.

See also: https://github.com/knative/pkg/issues/859
2019-11-10 09:04:12 -08:00
Dave Protasowski f9aa7d2d11 pull out object reference helper function (#733) 2019-10-01 07:09:06 -07:00
Markus Thömmes b55b842259 Adjust tracker to take structured keys as well. (#706)
* Use structured keys in the tracker.

* Adjust the addressable resolver too.
2019-09-20 09:44:06 -07:00
Matt Moore 222dd25986 Migrate pkg to use the knative.dev/pkg import path (#489)
* Manual changes.

* scripted changes.
2019-06-26 13:02:06 -07:00
Matt Moore 01db4ead66 Refactor the tracker testing. (#483)
Stop using `t.Run` to segment things, since they aren't truly independent tests.

Use a longer lease/sleep as I have concerns that slow execution may be a part of the flakiness here.
2019-06-23 17:46:00 -07:00
Matt Moore 8a05c222ab Add an immediate callback for new registrations in Tracker. (#245)
This change adds an immediate callback to the tracker when a key is added to track an entity that previously lacked coverage.

Fixes: https://github.com/knative/serving/issues/2954
2019-01-28 09:30:36 -08:00
Victor Agababov a330baa9b0 Grep fix formatting issues (#233)
* Some fixes to the spoof.go and exporter.go

While reviewing some other CL, I saw some avenues for improving
spoof.go, to log the URL that's being fetched, which would help in test
debugging and to use switch construct, rather than nested if's.

While testing the change, I noticed some shifty loggin from the
exporter, so I fixed that as well while I was there.

* Continuation of the previous cleanups.

* Fix the issues with formatting by executing a grep

* and fix compilation error

* lowercase error

* fix the newly changed unit test
2019-01-18 14:33:32 -08:00
lichuqiang af2c4bc84e Update OnChanged in tracker to support deletion events (#160)
* define kmeta.Accessor interface

* update tracker and EnsureTypeMeta to support deletion events
2018-11-05 08:21:35 -08:00
Evan Anderson 7a435db409 Add additional validation for ObjectReferences (#156) 2018-11-01 15:47:34 -07:00
Matt Moore f83edbe3bc Reject ObjectReferences missing key elements. (#151)
Fixes: https://github.com/knative/pkg/issues/150
2018-11-01 10:48:34 -07:00
Ivan Mikushin f00975a13e Tracker: delete objRef's keyset when it is no longer needed (#110) 2018-10-01 17:10:23 -07:00
Matt Moore e653ef4b1b This change implements a more generalized form of the BuildTracker. (#95)
To use this with a typical informer, e.g. the way `Route` would monitor `Configurations` and `Revisions`, you'd do something like:
```go
	c := &Reconciler{
		Base:                 reconciler.NewBase(opt, controllerAgentName),
		...
	}
	impl := controller.NewImpl(c, c.Logger, "Routes")

        t := New(impl.EnqueueKey, 30*time.Minute)
        configInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
                AddFunc:    t.OnChanged,
                UpdateFunc: controller.PassNew(t.OnChanged),
        })
        revisionInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
                AddFunc:    t.OnChanged,
                UpdateFunc: controller.PassNew(t.OnChanged),
        })

        // Now use c.tracker.Track(revisionRef, route) or c.tracker.Track(configRef, route)
        // each Reconcile(route) to refresh the cross-object leases.
        c.tracker = t
```

To use this with a `duck.InformerFactory`, e.g. the way `Revision` will monitor `BuildRef`s you'd do something like:
```go
	c := &Reconciler{
		Base:             reconciler.NewBase(opt, controllerAgentName),
		...
	}
	impl := controller.NewImpl(c, c.Logger, "Revisions")

        t := New(impl.EnqueueKey, 30*time.Minute)
        cif := &duck.CachedInformerFactory{
                Delegate: &duck.EnqueueInformerFactory{
                        Delegate: buildInformerFactory,
                        EventHandler: cache.ResourceEventHandlerFuncs{
                                AddFunc:    t.OnChanged,
                                UpdateFunc: controller.PassNew(t.OnChanged),
                        },
                },
        }

        // Now use: `c.buildInformerFactory.Get()` to access ObjectReferences.
        c.buildInformerFactory = buildInformerFactory

        // Now use: `c.tracker.Track(rev.Spec.BuildRef, rev)` to queue `rev`
        // each time `rev.Spec.BuildRef` changes (expires 30 minutes after BuildRef
        // points to something else).
        c.tracker = t
```

Fixes: https://github.com/knative/pkg/issues/94
2018-09-26 17:31:21 -07:00