Commit Graph

109 Commits

Author SHA1 Message Date
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
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
Victor Agababov 31657d4f05
Fix the logging to be a sentence (#1236)
Also it seems in the test logs this is manifested as 'returned an event' and nothing else...
but I blame it to the testing log configuration, perhaps.
2020-04-23 10:56:31 -07:00
Markus Thömmes 7fbf4b0edc
Add finalizer option and default to test code too. (#1238) 2020-04-23 10:02:31 -07:00
Markus Thömmes 6103dd9b71
Add a controller option to specify a custom finalizer name. (#1230) 2020-04-22 14:55:40 -07:00
Markus Thömmes 5036c917e5
Drop 'no longer exist' line to DEBUG. (#1234) 2020-04-22 07:34:40 -07:00
Markus Thömmes c09083a601
Fix a few simple linter warnings: unused code, govet warnings etc. (#1191) 2020-04-06 08:21:20 -07:00
Scott Nichols 8a6d25b309
Generate reconcilers for resources out of tree. (#1175)
* genreconciler:nonNamespaced

* Adding a force-kinds flag to the reconciler generator to allow us to generate reconcilers for non-owned types.

* force-kinds --> force-genreconciler-kinds

* some minor nits with the generators for non-knative types needed to be removed.

* remove whitespace

Co-authored-by: Nacho Cano <nachoacano@gmail.com>
2020-03-25 11:34:51 -07:00
Markus Thömmes 5605ade524
Add filtering to class based controller stubs. (#1133) 2020-03-03 12:57:53 -08:00
Scott Nichols 3a272190c3
Found missing forced packages in injection gen. (#1116)
* ctx

* runtime.object

* update codegen
2020-02-21 13:42:07 -08:00
Scott Nichols 5d8a01d12c
Implement strongly typed class reconcilers (#1103)
* Implement strongly typed class reconcilers

* document class filters.

* matt is always right
2020-02-19 08:38:06 -08:00
Scott Nichols 72f3cd2bbc
[Genreconciler] Fix group names when client groups differ than their directory name. (#1097)
* looking at annotations for group overrides.

* checkpoint.

* checkpoint

* I think it is correct.

* ok

* trim down the files.

* simulate tekton

* working test out of checkin

* remove test client

* update docs

* and test.

* lint

* it ok

* update codegen
2020-02-18 17:14:59 -08:00
Scott Nichols 69f70e37d9
adding recorder to context. (#1096) 2020-02-14 14:28:41 -08:00
Scott Nichols 602d92f69b
I screwed up the return for clearFinalizer. (#1089) 2020-02-13 08:35:36 -08:00
Matt Moore 12ca62e262
golang format tools (#1087)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)`
  `goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party)`
/assign n3wscott
/cc n3wscott
2020-02-13 08:27:36 -08:00
Scott Nichols 558f848aa0
[GenRec] Keep resource in sync when setting and removing finalizers. (#1086)
* Update the resource if it is patched for finalizer mods to let status update work the first try.

* matt does not like extra :
2020-02-12 17:08:36 -08:00
Scott Nichols d93ce78496
[Reconciler Generators] Adding support for configStore.ToContext (#1085)
* Support optional config maps.

* document configmap stores

* whitespace.

* optionsFns

* review

* check for nil.

* zero trust imports.
2020-02-12 16:10:35 -08:00
Scott Nichols a5517037d3
set the import for sets (#1075) 2020-02-11 07:52:07 -08:00
Matt Moore dddb2d8753
golang format tools (#1072)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)`
  `goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party)`
/assign n3wscott
/cc n3wscott
2020-02-11 07:13:07 -08:00
Scott Nichols 248c9f0353
fix filtering for reconcilers gen. (#1071) 2020-02-11 05:26:07 -08:00
Scott Nichols 85608a8329
Generate Managed Finalizers for Reconcilers (#1069)
* fix rando issues

* code in the group for finalizer name.

* Use FinalizeKind

* show the Finalizer interface.

* removing isFinalizing

* sync finalizers before calling reconcilekind

* missed the events change.
2020-02-10 19:46:06 -08:00
Matt Moore 8e404c7c40
golang format tools (#1056)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)`
  `goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party)`
/assign n3wscott
/cc n3wscott
2020-02-06 16:57:32 -08:00
Scott Nichols b63641488a
fix event recorder (#1053) 2020-02-05 13:51:31 -08:00
Matt Moore 5660964262
golang format tools (#1051)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)`
  `goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party)`
/assign n3wscott
/cc n3wscott
2020-02-05 07:57:31 -08:00
Scott Nichols b9974987c2
Fix issue with returning errors, and not adding scheme (#1049) 2020-02-04 18:03:30 -08:00
Scott Nichols b317048346
Generate Base Reconciler Code for Injection Based Controllers. (#947)
* adding a reconciler generator to use as the base reconcilers for all of knative.

* mend

* fix tag names.

* use reconciler events

* trying new thing.

* base working reconciler gen

* working cleaned up reconciler generator.

* fix typo

* fix some ordering.

* fix interface path

* fix whitespace

* update deps.

* updates based on feedback.

* Remove core loop.

* reconcilerImpl

* add NewReconciler

* Fix copyright header

* Comment out finalizers

* remove finalizers from generated code.
2020-02-04 10:23:30 -08:00
Matt Moore 43ca049cdb Reduce the boilerplate for setting up duck.InformerFactory's. (#896)
This augments the injection codegen with the capability to produce a duck.InformerFactory
attached to context for each type that we process.

Now a `duck.InformerFactory` for "Addressable" can be produced by "Get"ing it from the context.

This is triggered by placing `// +genduck` on the type that implements `duck.Implementable`.
2019-11-25 09:57:10 -08:00
Markus Thömmes 56c2594e4f Assorted linting fixes. (#840)
* Remove unused code.

* Remove unneeded loops.

* Remove unneeded Printf calls.

* Use time.Since instead of time.Now().Sub.

* Remove unused values.

* Rename error variable according to conventions.

* Return error last.

* Simplify array allocations.

* Remove leaky ticker.

* Remove Yoda conditions.

* Remove deprecated function to talk to GKE.

* Remove dot import.

* Remove empty critical section and replace with a channel operation.

* Add linter directives to explicitly state wanted weirdness.

* Update deps.

* Fix broken line.
2019-11-01 12:49:12 -07:00
Dave Protasowski 528ad1c1dd Generate K8s Injection Code (#640)
* update codegen so the fatal error messages are more informative

String representation of an untyped nil is 'nil' so the Fatal messages weren't useful

* generate k8s injection code

* generate apiextensions injection code

* use Fatal & move output paths

* switch from Fatal to Panic

* injection creates a single factory
2019-09-09 12:52:11 -07:00
Matt Moore 524f6c5bb2 Add the ability to scope informers to a namespace with injection. (#626) 2019-09-03 07:17:00 -07:00
mattmoor-sockpuppet 1864f499dc golang format tools (#497)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
/assign @mattmoor
2019-06-27 07:37:08 -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
mattmoor-sockpuppet 5d105b46d3 golang format tools (#444)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
2019-06-06 09:54:40 -07:00
Matt Moore 4d86f3ad6f Access a logger and Fatalf when Get would return nil. (#439) 2019-06-05 09:06:38 -07:00
Matt Moore 35bb0fc83b Add code-generation for the various injection stubs. (#438)
This is largely based on work by @n3wscott
2019-06-05 08:50:38 -07:00