Commit Graph

84 Commits

Author SHA1 Message Date
Matt Moore bb4aaf09c4
Ignore special errors in codegen for events (#2202) 2021-07-30 10:21:32 -07:00
Ben Moss 7d1b0f19ef
Add ability to filter objects on injection controller promotion (#2180)
Currently we enqueue every object with no way to filter, which causes
problems for eventing's source controller which reconciles duck CRDs.
2021-07-13 10:55:50 -07:00
ying e2947dba20
update the multiple label selector implemention to avoid clobber in filtered factory (#2120) 2021-05-25 00:14:38 -07:00
Ben Moss cfc1eed828
Better support for error wrapping with ReconcilerEvents (#2106)
* 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
2021-04-26 11:00:40 -07:00
Markus Thömmes 78b8140ed1
Use semantic equality for status update retries (#2103) 2021-04-23 09:26:38 -07:00
Markus Thömmes 2e62ba6a9d
Add possibility to implement a deletion handler in a reconciler. (#2089)
* 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
2021-04-19 08:38:00 -07:00
Markus Thömmes b51994e3b3
Fix a few comments in reconciler-gen (#2090) 2021-04-12 10:37:42 -07:00
Evan Anderson 728bc4ad4e
Update OWNERS_ALIASES to match autogen in community (#2078) 2021-04-08 07:42:51 -07:00
Sameer Vohra 9d92ea16c0
Update reconciler_controller.go (#2066)
* Update reconciler_controller.go

nit: fix tiny typo

* Ran ./hack/update-codegen.sh

Signed-off-by: Sameer Vohra <vsameer@vmware.com>
2021-03-28 23:52:22 -07:00
Markus Thömmes bbe0bb3eb1
Implement getter machinery to generically fetch all injected clients (#2054) 2021-03-10 09:35:25 -08:00
Lionel Villard 07b5ddfaea
add demoteFunc controller option (#2033)
* add demoteFunc controller option

* use tab instead of space for indent

* run codegen
2021-02-25 14:10:47 -08:00
Francesco Guardiani ca02ef752a
Genreconciler properly generates reconciler for Resources with Status (#2004)
* 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>
2021-01-29 16:18:31 -08:00
qibobo 1bbf0a6436
add LabelSelector to InformerFactory so that the informers only list and watch resources with the given labels (#1940)
* 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
2021-01-19 08:21:23 -08:00
Dave Protasowski a74906c7fb
Use structured logging to augment our logger vs. naming (#1991)
* Use structured logging to augment our logger vs. naming

* remove unused line
2021-01-15 12:08:21 -08:00
Matt Moore f0ea5e6b9c
Use special error type to designate skips. (#1988)
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.
2021-01-14 14:30:20 -08:00
Markus Thömmes a1d2289bb5
Remove useless logger creation (#1966) 2020-12-15 10:22:58 -08:00
Jon Donovan 9bf616d2f4
Fail louder when bad context given to injection (#1768)
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.
2020-11-25 01:50:35 -08:00
Markus Thömmes a2394e8895
Fix produced events if patching a finalizer fails (#1843) 2020-10-26 09:05:41 -07: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 247841408e
Apply the cleanup to the pkg (#1776)
* Apply the cleanup to the pkg

This is probably the final iteration of my cleanup application.

* codegen

* one more try
2020-10-05 21:41:20 -07:00
Victor Agababov 1e373a9e5d
take 2 (#1755) 2020-09-29 14:10:29 -07:00
Victor Agababov 5d1dfa9ef7
Improve the logging messages in the reconciler generator. (#1750)
And other minor nits.
2020-09-28 13:32:28 -07:00
Markus Thömmes 754da4653a
Enable unparam linter to catch unused parameters (#1731) 2020-09-22 09:13:40 -07:00
Zbynek Roubalik 2d4efecc6b
bump to k8s 1.18 (#1428)
* bump to k8s 1.18.8

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* plumbing ctx through

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* add more ctx plumbing

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* ctx WithCancel()

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-09-11 07:54:00 -07:00
Weston Haught 2eaf40292b
don't pre/post process if skipstatusupdate (#1625) 2020-08-15 08:51:06 -07:00
Matt Moore 3a98b0671c
Have codegen log status diffs at debug level (#1598)
Fixes: https://github.com/knative/pkg/issues/1597
2020-08-08 11:49:29 -07:00
runzexia 47e34f1f4e
use const when gen reconciler (#1568)
* use const when gen reconciler

* move to reconciler common

Signed-off-by: RyderXia <ryder.xia@sap.com>

* update

Signed-off-by: RyderXia <ryder.xia@sap.com>
2020-07-29 14:45:59 -07:00
Matt Moore a3a29ac6e1
[master] Fix spelling errors (#1548)
Produced via:
  `github.com/client9/misspell`
/assign n3wscott vagababov
/cc n3wscott vagababov
2020-07-23 08:22:57 -07:00
Scott Nichols ae9c3f7fa8
Refactor the genreconciler code to pull state out (#1544)
* Refactor the genreconciler code to pull state out

* don't generate the stubs

* fix indent
2020-07-22 23:02:57 -07:00
Scott Nichols f397d1a271
Propagate SkipStatusUpdates to reconciler from NewReconciler (#1466) 2020-07-01 22:59:42 -07:00
Weston Haught cd84a3ec16
Update generated reconciler code with a switch (#1457)
* Update generated reconciler code with a switch

* flip

* update-codegen

* dont want to warn on equal
2020-07-01 21:31:41 -07:00
Markus Thömmes a92c682188
Add an option to skip automated status updates in a reconciler. (#1456)
* Add an option to skip automated status updates in a reconciler.

This option is necessary to be able to create reconcilers like Serving's labeler, that is purely adding labels to resources. If that fails, the new automated observed generation handling changes the status and that gets written to the API currently, which is not desired.

* Flip the bool.
2020-06-30 08:02:29 -07:00
Weston Haught aa30bc3ac0
expect resoruces are krshaped by default (#1430) 2020-06-23 10:21:27 -07:00
Weston Haught 602857dcc5
add self to aliases and add reviewers to OWNERS (#1409)
* add self to aliases and add reviewers to OWNERS

* fix typo
2020-06-22 12:30:27 -07:00
Matt Moore 5e60b6f863
Implement the fourth wave of per-reconciler leaderelection. (#1304)
With this, all downstream `// +genreconciler` reconcilers will become leader-aware and expose a model for the typed reconcilers they wrap to themselves become leader-aware.

Detailed design: https://docs.google.com/document/d/1i_QHjQO2T3SNv49xjZLWlivcc0UvZN1Tbw2NKxThkyM/edit#
Issue: https://github.com/knative/pkg/issues/1181
2020-06-21 18:58:26 -07:00
Weston Haught bfb5907813
Fix gen-reconciler stub - remove TODOs (#1425)
* fix examples

* keep for non krshaped

* fix codegen
2020-06-19 14:43:25 -07:00
Markus Thömmes c365f7d338
Abort reconcilation on finalizer patch errors. (#1423)
* Abort reconcilation on finalizer patch errors.

This aborts reconcilation if finalizers could not be patched correctly with an error and thus it retries.

We shouldn't start a reconcilation if we haven't been able to correctly add the finalizer first. Otherwise we could get into a weird spot where the resources are created before the finalizer and in a very degenerate case the finalizer wouldn't even be executed. Also, the current code has a bug where if the patch fails the resource coming back from the patch (essentially an empty object) is passed into ReconcileKind, causing headaches.

The same imo goes for removing a finalizer. Failing to remove a finalizer blocks the resource forever, thus we should retry if that happens too.

* Add generated code.
2020-06-19 08:26:25 -07:00
Weston Haught d5043a4332
Groom conditions LastTransitionTime in postprocess (#1403)
* Groom conditions time

* unit test

* unit test fix

* make readme accurate
2020-06-18 11:46:25 -07:00
Thomas Shafer 2266252575
Prevent nil access when resource is nil (#1386)
When an error is returned frequently the resource is nil and results in nil.Name being called for the error.
2020-06-06 12:53:18 -07:00
Victor Agababov 1ceb875570
Fix \" escaping and other nits in the pkg (#1339) 2020-05-16 09:36:02 -07:00
Victor Agababov b10849aacf
Some nits in the genreconciler (#1328)
* Some nits in the genreconciler

- make sure we allocate proper amount of slice space
-  `t:=t` is needed only if you're doing goroutines in the loop
- extract constants outside of the loops.
- reformat

* meh, I was wrong
2020-05-12 12:11:30 -07:00
Weston Haught 2a7c3fd8e2
use our tag parser (#1327) 2020-05-12 10:45:58 -07:00
Weston Haught 00ce2bb1b4
krshaped should be part of genereconciler (#1326) 2020-05-12 08:28:03 -07:00
Antoine Cotten 8930ffb535
Fail reconciliation when event is wrapped (#1289) 2020-05-08 10:09:45 -07:00
Weston Haught b559da3646
Generate common logic for krshaped resources (#1311)
* generate krshaped logic

* add logic to the tag

* Update injection/README.md

Co-authored-by: Matt Moore <mattmoor@vmware.com>

* move var to reconciler

Co-authored-by: Matt Moore <mattmoor@vmware.com>
2020-05-08 10:00:45 -07:00
Ian Milligan c0dd593d3f
Ensure that all needed imports are tracked in reconciler generator (#1308) 2020-05-07 07:07:45 -07:00
Matt Moore 3da93ebb24
Properly set hasClass (#1296)
This was changed in #1277
2020-05-05 12:10:44 -07:00
Weston Haught 10ba977860
Create our own comment parser for codegen (#1277)
* Adapt our own comment parser

* Use our new comment parser to extract tags

* Update codegen/cmd/injection-gen/generators/comment_parser.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update codegen/cmd/injection-gen/generators/comment_parser_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update codegen/cmd/injection-gen/generators/comment_parser.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update codegen/cmd/injection-gen/generators/comment_parser.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update codegen/cmd/injection-gen/generators/comment_parser_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update codegen/cmd/injection-gen/generators/packages.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* suggestion didn't compile

* Update codegen/cmd/injection-gen/generators/comment_parser.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* trimspace

* include test for ,,, case

* add empty check

* fix comment

Co-authored-by: Victor Agababov <vagababov@gmail.com>
2020-05-04 09:42:43 -07:00
Shashwathi 93be3f499d
Add ability to override controller agent name (#1240)
* Add the ability to override controller agent name

- controller can set agent name via context. If nothing is set then
controller falls back to default controller agent name

* Check if context name is not nil and can be casted to string before returning.

* Create EventRecorder after we determine the controller agent name

* Address comments

Signed-off-by: Andrew Su <asu@pivotal.io>

* Remove check for if recorder is nil

Co-authored-by: Andrew Su <asu@pivotal.io>
2020-05-02 10:00:43 -07:00
Matt Moore d0328aa36b
Generate unique workqueue names. (#1255)
This changes the names we give workqueues in genreconciler to avoid collisions when multiple reconcilers in a single process use the same generated reconciler base.

There are a few examples of this in serving, both route and configuration have collisions.  Right now I think this mainly affects metrics published by the workqueues, but I noticed this leveraging the same for resource lock naming.
2020-04-28 07:44:52 -07:00