Commit Graph

29 Commits

Author SHA1 Message Date
knative-automation e61a20dd64
Update actions (#2313)
Signed-off-by: Knative Automation <automation@knative.team>
2021-10-15 12:26:13 -07:00
Matt Moore a00ba48712
Add unit test coverage of cluster-scoped tracker. (#2306) 2021-10-05 13:36:44 -07:00
Matt Moore b4b8bcac11
Allow tracking Cluster-scoped resources. (#2304)
Previously we required namespace to be non-empty, but it never is for Cluster-scoped resources.

This change elides validation for missing namespaces, assuming cluster-scoping.
2021-10-05 12:55:44 -07:00
Markus Thömmes 2bd91f7557
Bump K8s dependencies to 1.21.4 (#2242)
* Bump apimachinery

* Update code-generator

* Update API and client, some progress

* Hack the generator to work at all

* Hack the PodDisruptionBudget extension to fulfill the interfaces

* Bump apiextensions as well

* Fix conflict

* Better condition

* Roll back unnecessary codegen change

* Fix PodDisruptionBudget extensions

* Panic on not-yet-implemented like others
2021-08-27 11:45:38 -07:00
Julian Friedman 50410e0b83
Use consistent case for "Deprecated" comments (#2216)
* Use consistent case for "Deprecated" comments

Not the most important thing ever, but the canonical string to use for
Deprecated warnings is case sensitive, and also it's nice to be
consistent.

* Add nolint comment
2021-08-17 09:15:16 -07:00
Dave Protasowski eaa823c765
bump k8s to v1.20.7 (#2145)
* bump k8s deps to v1.20.7

* fix migrator test pkg

* dynamicclient now expects List types to be declare either via a scheme or manually

* fix error message comparison

* drop excess vendor licenses

* Using the injection fake dynamic client will preserve pre-1.20 behaviour

This is accomplished by preprocessing the scheme/fixtures and declaring
a custom scheme were we map our types & lists to unstructured.* types

* revert webhook factory changes

* ensure objects to the dynamic client are unstructured

* seed the default dynamic client with k8s scheme

* include duckv1 types in default fake dynamic client scheme

* use default k8s scheme
looks like eventing adds to this scheme but we should import the correct one vs the one from the  fake package

* drop duckv1 from default scheme

* set APIVersion/Kind if empty

* refactor ToUnstructured helper to a new package
2021-06-10 06:56:43 -07:00
Dave Protasowski 6484377731
update boilerplate date (#2134) 2021-05-28 13:21:29 -07:00
Markus Thömmes cc77cba3ea
Add GetObservers to tracker interface (#1896)
* Add GetObservers to tracker interface

This allows an arbitrary client to fetch all the observers of a given object. Ultimately, this enables an informer setup that can use this knowledge as a filter to decide whether or not the current object is actually watched by anything.

* Fix log line
2020-11-10 10:19:59 -08:00
Josh Soref b39d5da935
Spelling (#1797)
* spelling: adopted

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: aliased

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: apierrs

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: assignment

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: available

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: coexistence

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: commit

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: conversions

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: creates

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: custom

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: determine

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: different

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: distribution

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: duplicate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: editing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: endpoint

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: environment

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: generate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: implementation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: identified

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ignore

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: indicates

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interface

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interleaved

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: labels

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: label

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: mimic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: namespaced

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: necessary

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: organization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: populatable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: prometheus

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: refer

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: reference

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: repetitive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: response

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: something

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: specable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: spoofing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: synchronized

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: this

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trailing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unsupported

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: validation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* chore: reviewdog go header boilerplate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-10-18 14:22:57 -07:00
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Victor Agababov 1ceb875570
Fix \" escaping and other nits in the pkg (#1339) 2020-05-16 09:36:02 -07:00
Markus Thömmes 3a2ec57c2c
Add specific callback for the tracker to delete items eagerly. (#1235)
* Add specific callback for the tracker to delete items eagerly.

* Rename to OnDeletedObserver.

* Enhance FakeTracker and add tests.
2020-04-24 09:17:50 -07:00
Markus Thömmes 689dff7dc0
Replace deprecated 'Track' with 'TrackReference'. (#1198) 2020-04-06 08:15:19 -07:00
Matt Moore df0629984f
Don't call the callback with the lock held (#862) 2020-02-13 13:28:36 -08:00
Scott Nichols 298f22bea6 update boilerplate to use 2020 (#979) 2020-01-07 16:04:51 -08:00
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
Victor Agababov 74c5d67ea0 Fix the issues pointed out by staticcheck (#541)
* Fix the issues pointed out by staticcheck

* review fix
2019-07-23 13:13:36 -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