Commit Graph

1694 Commits

Author SHA1 Message Date
Matt Moore 71508fc69a
Introduce `duckv1.Pod`. (#2280)
This is mostly for symmetry since many folks that validate PodSpecable types often also want to validate `Pod`, so while `Pod` isn't as often a duck-type, the main value of this is exposing similar mechanisms to #2279 for `corev1.Pod` without folks needing to define their own `corev1.Pod` clone.
2021-09-07 19:59:33 -07:00
Matt Moore 26db1ba732
Enable using `duckv1.WithPod` with our webhook infra. (#2279)
Today you can't use `duckv1.WithPod` to author webhooks because it doesn't implement the `Validate` or `SetDefaults` methods, and that makes sense since they are (by definition) a generic encapsulation of a number of types.

However, if we could infuse `ctx` with appropriate callbacks for `Validate` and `SetDefaults` then folks can use our types, but infuse `ctx` with callbacks that perform the appropriate validation.

What I have in mind is something along these lines:

```go
return defaulting.NewAdmissionController(ctx,
	// Name of the resource webhook.
	"foo.bar.dev",

	// The path on which to serve the webhook.
	"/defaulting",

	// The resources to default.
	map[schema.GroupVersionKind]resourcesemantics.GenericCRD{
		appsv1.SchemeGroupVersion.WithKind("Deployment"):  &duckv1.WithPod{},
		appsv1.SchemeGroupVersion.WithKind("ReplicaSet"):  &duckv1.WithPod{},
		appsv1.SchemeGroupVersion.WithKind("StatefulSet"): &duckv1.WithPod{},
		appsv1.SchemeGroupVersion.WithKind("DaemonSet"):   &duckv1.WithPod{},
		batchv1.SchemeGroupVersion.WithKind("Job"):        &duckv1.WithPod{},
	},

	// A function that infuses the context passed to Validate/SetDefaults with custom metadata.
	func(ctx context.Context) context.Context{
		return duckv1.WithPodSpecDefaulter(ctx, myFancyLogic)
	},

	// Whether to disallow unknown fields.
	false,
)
```

It is roughly equivalent for validation.
2021-09-07 16:24:33 -07:00
Markus Thömmes 73d4fe679a
Drop Retrying and EventuallyMatchesBody checks (#2278) 2021-09-07 04:23:19 -07:00
Markus Thömmes bb433c9814
Add tests for retriable errors to the spoof client (#2277)
* Simplify spoof tests a bit

* Add tests for retriable errors
2021-09-06 03:54:43 -07:00
Kenjiro Nakayama b09fa45a1d
Declare `DefaultErrorRetryChecker` as `ErrorRetryChecker` type (#2276)
This patch changes `DefaultErrorRetryChecker` to `ErrorRetryChecker`
type before adding in the interface array.

Without it, the type of DefaultErrorRetryChecker is still `func(error) (bool, error)`.
2021-09-06 01:43:43 -07:00
Dave Protasowski dec98b4261
fix a small lint warning (#2270) 2021-09-02 22:55:57 -07:00
Markus Thömmes fbe9e7ed4d
Widen the error checker interface to allow response error checking (#2253)
* Widen the error checker interface to allow response error checking

* Fix grammar
2021-09-02 21:55:57 -07:00
Dave Protasowski 7a61343b36
only test downstream tekton with HEAD (#2271) 2021-09-02 13:24:57 -07:00
Markus Thömmes c69aba0aae
Deduplicate Check and Poll functions on the spoof client (#2264) 2021-09-02 10:59:07 -07:00
Fabian Lopez b721b0b90c
fix check calls being unreliable (#2250)
* fix check calls being unreliable

Signed-off-by: Fabian Lopez <lfabian@vmware.com>

* move log output inside error check if statement

Signed-off-by: Fabian Lopez <lfabian@vmware.com>
2021-09-02 10:31:07 -07:00
Matt Moore d60f1a4998
Avoid double-resyncs without leader election. (#2252)
* Avoid double-resyncs without leader election.

tl;dr Without leader election enabled, we've been suffering from double resyncs, this fixes that.

Essentially when the informers are started, prior to starting the controllers, they fill the controller's workqueue with ~the world.  Once we start the controllers, the leader election code calls `Promote` on a `Bucket` so that it starts processing them as their leader, and then is requeues every key that falls into that `Bucket`.

When leader election is disabled, we use the `UniversalBucket`, which always owns everything.  This means that the first pass through the workqueue was already hitting every key, so re-enqueuing every key results in superfluous processing of those keys.

This change makes the `LeaderAwareFuncs` elide the call to `PromoteFunc` when the `enq` function passed is `nil`, and makes the `unopposedElector` have a `nil` `enq` field when we explicitly pass it the `UniversalBucket` because leader election is disabled.

* Add more unit test coverage
2021-09-02 09:46:06 -07:00
Dave Protasowski 0482448aac
allow unknown metadata fields (#2249)
* allow unknown metadata fields

* fix lint warnings

* include tests for nested structures in the metadata value
this is for catching any regressions
2021-09-02 07:33:06 -07:00
Lionel Villard f39ea04a48
Add eventing-redis to downstream test (#2247) 2021-09-01 10:11:33 -07:00
Matt Moore 82f3a9f1c5
Add triggers to the downstream test (#2236) 2021-08-30 15:40:55 -07:00
Matt Moore e957ee54fa
Drop several deprecated APIs. (#2228) 2021-08-30 13:25:54 -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
Markus Thömmes 4472e04552
Bump golangci-lint timeout to 10m for github actions (#2241) 2021-08-27 04:26:38 -07:00
Markus Thömmes fac4920fca
Update assorted dependencies (#2240) 2021-08-27 02:10:38 -07:00
Matt Moore 263ce4067b
Add chains to the downstream test (#2237) 2021-08-26 17:55:37 -07:00
Kenjiro Nakayama ddd97e9fb8
Remove obsolete verbose log message for pre-release (#2235)
The error was obsoleted by https://github.com/knative/pkg/pull/1944.

As we can see this test case
a70bb26767/version/version_test.go (L68-L71)

pre-release version is __NOT__ smaller than the corresponding release
version anymore.
2021-08-26 08:40:32 -07:00
Lionel Villard a7f5b39b89
Addressable resolver now accepts custom resolvers (#2195)
* addressable resolver now accepts custom resolvers

* apply comments from review

* add comment about ignoring error
2021-08-26 07:21:32 -07:00
knative-automation 2b66fdd241
Update community files (#2239)
Signed-off-by: Knative Automation <automation@knative.team>
2021-08-26 06:50:33 -07:00
knative-automation 51f5642feb
Update actions (#2238)
Signed-off-by: Knative Automation <automation@knative.team>
2021-08-25 23:03:31 -07:00
Matt Moore 46a3611ec2
Add Tekton downstream test (#2233)
* Add Tekton downstream test

* Use matrix.org per ImJasonH

* Bump to new downstream action version to test

* Fix year on copyright
2021-08-25 13:18:31 -07:00
Yanwei Guo a70bb26767
Add length limit for the generated names used in tests (#2217)
* add limit

* typo

* remove childname
2021-08-25 00:00:25 -07:00
Kenjiro Nakayama a4ed097995
Update version check comment (#2234) 2021-08-24 23:29:25 -07:00
jwcesign a94f5f07b3
Trim the space in configmap/registriesSkippingTagResolving's url. (#2231)
* Trim space of confguration registriesSkippingTagResolving's url, delete
head's and tail's space

* Add test case for trim spaces
2021-08-24 05:08:23 -07:00
Markus Thömmes 12d915ede2
Update prometheus dep to 0.30.0 (#2227) 2021-08-23 06:36:35 -07:00
Matt Moore 3bed4dcf17
Make the configmap update logging Debugf (#2226) 2021-08-22 13:30:34 -07:00
Matt Moore 44fffc8b6e
This implements the EventExpansion needed to emit K8s events. (#2224)
With this change, I was able to pass some downstream e2e tests that check for event emission with this path enabled, which previously failed.

The relevant hand-rolled bits in Kubernetes client-go is here: 35bf219cc6/kubernetes/typed/core/v1/event_expansion.go (L49)

I opted to avoid copy/pasting the generated code, and instead used a trick that let me call into the generated code.

Going through this exercise also (likely) uncovered a Kubernetes bug: https://github.com/kubernetes/kubernetes/issues/104495
2021-08-21 16:23:34 -07:00
Matt Moore 6ef763ddee
Remove long deprecated NewImplWithStats (#2223) 2021-08-21 14:43:34 -07:00
Matt Moore 9c7fd8e14f
Introduce `NewContext`, deprecate `NewImplFull`. (#2222)
* Introduce `NewContext`, deprecate `NewImplFull`.

Our generated `NewImpl` methods have long taken `context.Context`, but despite many iterations the forms we expose from our `controller` package never have.  This change contains several elements:
1. Expose a new `NewContext` method that takes `context.Context` in addition to the current `NewImplFull` signature.
2. Call `NewContext` instead of the deprecated `NewImpl` from our generated controller code.
3. Call `NewContext` from all our webhook reconcilers.

* Add a Tracker to controller.Impl to cut down on downstream boilerplate.
2021-08-21 14:00:34 -07:00
Matt Moore 766b8f7bd2
Have the addressable resolver take a tracker. (#2220)
I noticed in a few places downstream that reconcilers were creating both trackers and Addressable resolvers, which seems superfluous.  As part of examining the way we use the tracker, I'm experimenting with changing this to just take a tracker.
2021-08-21 13:50:34 -07:00
Matt Moore 9b9bc2a226
Run codegen (#2221) 2021-08-20 16:55:05 -07:00
Markus Thömmes 52d2a0db1e
Deprecate ReadOnlyFinalizer interface over OnDeletionInterface (#2212)
* Deprecate ReadOnlyFinalizer interface over OnDeletionInterface

* Fix deprecated
2021-08-20 09:41:05 -07:00
knative-automation 44fc074919
Update community files (#2219)
Signed-off-by: Knative Automation <automation@knative.team>
2021-08-19 23:32:07 -07:00
knative-automation bda81c0291
upgrade to latest dependencies (#2218)
bumping knative.dev/hack e28525d...815cd31:
  > 815cd31 Stop performing pre-releases (# 77)

Signed-off-by: Knative Automation <automation@knative.team>
2021-08-18 22:44:04 -07:00
Matt Moore 7b5ecbc0e4
Sketch out an alternate way of injecting clients/informers (#2210)
* This commit contains the actual changes to support dynamic client injection.

* Incorporate n3wscott review nits

* This includes the code-generation for the dynamic client-based injection.

This also includes a number of manually created files of the form `*_expansion.go`, which are needed to satisfy some of the Kubernetes manual type "expansions".  At present, these are all simply `panic("NYI")`, but may become more than that in the future.
2021-08-18 06:52:08 -07:00
Markus Thömmes 8c88fa2764
Revert "Remove the unused file (#1935)" (#2213)
* Revert "Remove the unused file (#1935)"

This reverts commit e45bbefd1d.

* Add deprecation notice

* Ignore deprecation error of the alias
2021-08-18 03:57:08 -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
Markus Thömmes 35bcd16656
Drop redundant pointers and decoders (#2211) 2021-08-17 02:04:16 -07:00
Matt Moore bf176d5654
Sink two codegen passes below loop. (#2209)
I noticed doing some tinkering that these were running on every iteration, but the inputs don't change.  This sinks the calls to below the loop, and reduces things to a single call for each.
2021-08-16 15:37:16 -07:00
knative-automation 2c8a7b6bd7
Update community files (#2208)
Signed-off-by: Knative Automation <automation@knative.team>
2021-08-12 07:32:36 -07:00
knative-automation 23b0147246
Update actions (#2206)
Signed-off-by: Knative Automation <automation@knative.team>
2021-08-05 00:38:52 -07:00
Markus Thömmes 21eb4c167c
Bump assorted dependencies to their latest versions (#2205) 2021-08-03 09:00:15 -07:00
Matt Moore 552bbc1061
Support the webhook serving over non-TLS. (#2204)
This reworks the way we setup the TLS Config for the webhook, so that when the `opts.SecretName` is omitted we serve over non-TLS.
2021-08-02 20:22:47 -07:00
Shashankft9 64ab22bbaa
k8s-service-trailing-slash-fix (#2178) 2021-07-31 00:28:40 -07:00
Matt Moore c367a9d696
Drop Client as it is only used in tests (#2203) 2021-07-30 18:05:05 -07:00
Matt Moore bb4aaf09c4
Ignore special errors in codegen for events (#2202) 2021-07-30 10:21:32 -07:00
Matt Moore 3826bb2436
Add a new mechanism for requeuing a key. (#2201)
This is modelled after some of the semantics available in controller-runtime's `Result` type, which allows reconcilers to indicate a desire to reprocess a key either immediately or after a delay.

I worked around our lack of this when I reworked Tekton's timeout handling logic by exposing a "snooze" function to the Reconciler that wrapped `EnqueueAfter`, but this feels like a cleaner API for folks to use in general, and is consistent with our `NewPermanentError` and `NewSkipKey` functions in terms of influencing the queuing behaviors in our reconcilers via wrapped errors.

You can see some discussion of this here: https://knative.slack.com/archives/CA4DNJ9A4/p1627524921161100
2021-07-30 08:31:33 -07:00