Commit Graph

30 Commits

Author SHA1 Message Date
Chris Henzie
25ce433e5c Propagate existing ctx instead of context.TODO()
Kubernetes-commit: 3f1c41d53ebfcda5b5d39230426a095c135463af
2024-09-23 14:40:07 -07:00
Mike Spreitzer
cd970a4c9d Finish switching to utilruntime.HandleErrorWithContext
Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>

Kubernetes-commit: fdbf0bbb2d85c3095fdc9625620648fb861fce6a
2024-07-03 10:36:51 -04:00
Mike Spreitzer
6e60f3495c Brush up the sample controller
Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>

Kubernetes-commit: 7848612de8d0f6e4ac67c180184ee4bed1ac7691
2024-02-02 14:30:25 -05:00
Alvaro Aleman
f356e5a163 Sample Controller: Use one variable for key throughout
After changing it to use a typed workqueue, the differentiation between
the key we get from the workqueue and they key we use down the line is
no longer useful as they are the same, so use one variable for it
throughout.

Kubernetes-commit: 6e2e7f7c26d0c4908180180a85a53d2ca408f3b0
2024-05-27 21:29:48 -04:00
Alvaro Aleman
3272c300d3 Use the generic/typed workqueue throughout
This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.

Kubernetes-commit: 6d0ac8c561a7ac66c21e4ee7bd1976c2ecedbf32
2024-04-28 18:26:18 +02:00
Patrick Ohly
2c4684fa27 sample controller: enhance context support
27a68aee3a4834 introduced context support for events. Creating an event
broadcaster with context makes tests more resilient against leaking goroutines
when that context gets canceled at the end of a test and enables per-test
output via ktesting.

The New method already had a context, therefore no API changes are needed.

Kubernetes-commit: 591855966c1d136c8fca299db2c6ba949bef4493
2023-12-01 09:00:59 +01:00
Davanum Srinivas
362a7851c1 Drop usage of deprecated method NewNamedRateLimitingQueue
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: c8b65422e582e4d6703b03cfea0aff0ac5e48ce2
2023-10-17 14:46:13 -04:00
Prasad Chandrasekaran
ab7425d650 Migrate sample-controller to contextual logging
Kubernetes-commit: e346475822604fc41bd38e24a331fc7a8314876a
2022-11-14 09:16:04 +05:30
Wojciech Tyczyński
735d680475 Couple remaining SelfLink references cleanup
Kubernetes-commit: b62774f2f7907e0d519026e8fc3cfaf50eaa5d31
2022-01-19 21:19:25 +01:00
Frank Yang
0edb970c17 feat(sample-controller): use update status
Signed-off-by: Frank Yang <yangpoan@gmail.com>

Kubernetes-commit: 01e9c80d90c5a6da8278d0785ef583e01f901c1e
2021-11-18 22:00:54 +08:00
Jille Timmermans
2760f8658e Fix double formatting on error message
fmt.Errorf() was called with a message rather than a format string

Kubernetes-commit: 4c038d387c081c2a1a222adb76cbc2b0750fa520
2021-09-25 09:51:48 +02:00
astraw99
0bf5b5ab8f unify worker num to workers
Kubernetes-commit: e6df935fd30c56a8ece0da6152c60fc725d942b7
2021-08-09 10:48:53 +08:00
Steven Pitts
85830b19e9 Fix grammar
Original:

> This handler will lookup the owner of the given Deployment, and if it is owned by a Foo resource will enqueue that Foo resource for processing.

Fixed:

> This handler will lookup the owner of the given Deployment, and if it is owned by a Foo resource then the handler will enqueue that Foo resource for processing.

Kubernetes-commit: c21f9cb59d2bd23804959cf41dc0b2c349b66b9d
2021-06-28 19:18:22 -04:00
Kobayashi Daisuke
36de02d179 Replace StartLogging(klog.Infof) with StartStructuredLogging(0)
Kubernetes-commit: 4ae11dac2e2cc8594c528a679db5861c0926b514
2020-06-09 12:01:45 +09:00
Davanum Srinivas
b3876539af switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Mike Danese
ef20aa3dd1 generated: run refactor
Kubernetes-commit: 25651408aeadf38c3df7ea8c760e7519fd37d625
2020-02-08 12:30:21 -05:00
Mike Danese
297436d318 generated: run refactor
Kubernetes-commit: 3aa59f7f3077642592dc8a864fcef8ba98699894
2020-02-07 18:16:47 -08:00
Zhou Peng
9dfda3fc9a [k8s.io/sample-controller/controller.go]: fixup minor typo
Signed-off-by: Zhou Peng <p@ctriple.cn>

Kubernetes-commit: 5616ce97622e25a90f89f56e5556e73e065ee012
2019-10-25 10:30:25 +08:00
AdheipSingh
1205a13b28 Update comment for syncHandler
```
// If the Deployment is not controlled by this Foo resource, we should log
// a warning to the event recorder and return error msg
```
For a clearer understanding of the comment.

Kubernetes-commit: db303bc2af859d48958e0b9c084a3b2983c1220f
2019-09-07 19:09:56 +05:30
Shintaro Murakami
e3d37f6957 Create GroupVersionKind with simpler way
Kubernetes-commit: e9906dc36246889478db999b5b44c2df48176100
2019-04-22 15:01:05 +09:00
Bruce Ma
7047ee6cec replace AddRateLimited with Add in enqueue func
Kubernetes-commit: 0335867b564f4791ccca56f20b8d06226f991d15
2019-03-22 11:40:23 +08:00
Dr. Stefan Schimanski
84833d0138 sample-controller: adapt to package moves
Kubernetes-commit: b671a06e46ced532c76136474afa8e88a136e99f
2019-02-15 13:08:42 +01:00
stewart-yu
4a9e8aba65 remove duplicated import
Kubernetes-commit: 217dbeafaf3293d193d6bdf3a8a220329d55dfe9
2018-11-13 20:08:39 +08:00
Davanum Srinivas
a508a6c07c Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
nrfox
94e9a85e76 Requeue work item on syncHandler error
Kubernetes-commit: 8f86654b8e23bbf960a286712df35c003f7389f8
2018-10-19 13:54:31 -04:00
Mikhail Mazurskiy
f3ae960ce1 Handle errors
Kubernetes-commit: 5cab7f9a57dbbd6e2a181018aae523235843f77d
2018-07-17 20:29:55 +10:00
Gregory Man
92fe46a498 Added unit tests to sample-controller
Added unit tests.

Changed NewController function to accept informers and not informers
factory. This make code more testable and align it with other
controllers.

Kubernetes-commit: a29a1cbb955e993300c9388a218a4f323f3fdf8f
2017-10-19 18:31:46 +03:00
Nikhita Raghunath
ad67096f17 sample-controller: add status subresource support
- Add an example to show how to use status subresources
with custom resources.
- Update the comment in the controller to mention that
`UpdateStatus` can now be used.
- Generate `UpdateStatus` for Foo.
- Update the README to remove feature gate information for
CRD validation since the current example requires a v1.9
cluster and it is enabled by default.
- Update the README to add feature gate information for
CustomResourceSubResources.

Kubernetes-commit: 7c06d6fb17ee46f587c1facff93b9bb185522855
2018-02-18 18:45:38 +05:30
hzxuzhonghu
994cb3621c upgrade to apps/v1 deployment
Kubernetes-commit: 386e001446b8e9c96daf15d71d3176a73d638b50
2018-01-18 17:47:00 +08:00
James Munnelly
00e875e461 Add sample CustomResourceDefinition controller
sample-controller: add API types

sample-controller: regenerate files

sample-controller: add implementation

sample-controller: update bazel

sample-controller: update make-rules and cache_go_dirs

sample-controller: Set noStatus tag. Remove openapi-gen tag.

sample-controller: add deletion tombstone handling logic

sample-controller: update README, remove use of reflect in UpdateFuncs

sample-controller: add OWNERS file

sample-controller: add LICENSE

Kubernetes-commit: 740afa0e65bf44a95752fb863017a7cf14b476ad
2017-10-09 19:19:34 +01:00