* refactor codegen into different packages and use gengo v2
This allows us to run this injection against types that have newer golang features - eg. 'any'
* updated go.mod drops gengo v1
* tweak scripts to support gengov2 framework
* drop verbose output
* Update defaultMinimumVersion
* Fix issues that occurred after running update-k8s-deps
* Adding changes to vendor and other folders
* Add new files after running update-codegen
* Add newLine
* Generator: allow reconcilers to listen to leader promotion events
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
* Run hack/update-codegen.sh
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
---------
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
The state comparison using `kmp.SafeDiff(existing.Status, desired.Status)` in the `reconcilerImpl.updateStatus` method is costly and performed for debug logging purposes.
Issue: https://github.com/knative/pkg/issues/2677
Generally K8s types have a list type where the 'Items' member is an
array of structs.
ie. https://pkg.go.dev/k8s.io/api@v0.25.3/apps/v1#DeploymentList
type DeploymentList struct {
...
// Items is the list of Deployments.
Items []Deployment `json:"items" protobuf:"bytes,2,rep,name=items"`
}
Istio is an exception where the list contains pointers to structs
type GatewayList struct {
...
Items []*Gateway `json:"items" protobuf:"bytes,2,rep,name=items"`
}
To hint that the list types are pointers you can now pass the flag
'--lister-has-pointer-elem'.
Ideally we could infer this info by inspecting the types but
unfortunately the generator doesn't load this information
I noticed that the finalizer manipulation code was performing a second fetch of the resource from the lister cache to determine the differences in finalizers when the finalizers are being modify immediately above each callsite.
This changes both call sites to simply pass through the "desired finalizers" as a new parameter (instead of assigning them), which lets us use the unmodified resource and avoid the redundant lister cache fetch.
* Extend Apply verb to extensions, Bump to K8s 1.22.
This was motivated by the linked issue, and does the work to upgrade PKG to 1.22 libs.
Fixes: https://github.com/knative/pkg/issues/2320
* 0.22.2 -> 0.22.5
* allow multiple values for comment tag keys
this will allow us to support multiple annotation keys
* add OR filter chain
* update codegen to support multiple annotation keys
* Preserve previous code & formatting if the number of annotation keys is 1
- preserve the order of the annotations vs. sorting it
- deprecate and don't remove ClassAnnotationKey to allow migration to happen smoothly
* fix default value for krshape
* include clarifying comment
Unfortunately the lister interfaces didn't plumb through `ctx` so
this is slightly more complex than I'd have liked. Instead of
threading the `resourceVersion` (bounded-staleness) through `ctx`
it is stored on the lister implementation.
It is seeded with `injection.WithResourceVersion` (ideally this
would have been all we needed, w/o state), and this state can be
updated by calling `SetResourceVersion`.
The stored `resourceVersion` is passed via `FooOptions` to `Get`
and `List` calls.
Fixes: a long-standing `TODO(mattmoor)`
* 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
* 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.
* 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.
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.
* Fix codegen to work outside GOPATH
* Fix ReconcilerEvent handling of %w format strings
Using fmt.Errorf(...).Error() means we get %w's translated to %v's for
printing
* Add possibility to implement a deletion handler in a reconciler.
ObserveFinalizeKind is not guaranteed to be called for every resource
that gets deleted, even if they do have a finalizer. The leader can race
the observers in removing the finalizer so the observers would not even
see the deletion.
Using the OnDelete handler on the informer is equally racy in that it
can trigger the deletion handler while a potential "normal" reconcile is
still in-flight.
This adds an ObserveDeletedKind handler that can be implemented by
reconcilers. The events still go via the workQueue, so proper order and
deduplication is guaranteed. Observation is guaranteed as well. In most
if not all cases, this handler should replace the ObserveFinalizeKind
handler.
* Move interface to its own file
* Fix license
* Fix comment
* Fix#2003
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
* Removed useless newline
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
* Removed useless check
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
* Now we don't have any newlines anymore
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
* add filtered InformerFactory and informers which only list and watch resources with the given labels
* rename to RegisterFilteredInformers
* generated files
* typo
* update per comments
* rename file
* rm old files
This change introduces a new `controller.NewSkipKey` method to designate certain reconciliations as "skipped".
The primary motivation for this is to squelch useless logging on non-leader replicas, which currently report success with trivial latency.
I have plumbed this through existing reconcilers and the code-gen so most things downstream should get this for free. In places where a key is observed, I do not mark the reconcile as skipped as the reconciler did some processing for which the awareness of side-effects and reported latency may be interesting.
This uses the presence of the config key to determine whether
this is an injection context, and if it is not, the panic
message includes a notice about injection context behavior.