Hello!
I'm happy to announce some enhancements that are coming to client-go in 1.37.
There's a new type-safe API for informer event handlers and filters [1].
They come with better documentation, in particular around deletion
events. The type-safe API automatically handles the casting to the correct
type, which removes significant amount of code and also makes it harder
to miss corner cases of deletion events (stale or missing object).
Friends don't let friends use the traditional API... ;-)
[1]
https://github.com/kubernetes/kubernetes/pull/139821
[2]
https://github.com/kubernetes/kubernetes/pull/140776
We now have a mechanism to provide a CHANGELOG.md [3]. The goal is to
document all breaking Go API changes together with instructions on how
to handle them. At the moment, this is voluntary (see [4]). Please pay
attention to pull-kubernetes-apidiff-client-go, that job will fail when
it detects a breaking change and will have further instructions on how
to document it.
We don't want to document Go API changes caused by Kubernetes API
changes because some of the generated interfaces inevitably have
breaking changes. There are some regular expressions which filter out
such changes [5], but they need some more work.
pull-kubernetes-apidiff-client-go is not merge-blocking, so feel free to
ignore it when it highlights something which doesn't need to be
documented or (better) extend the filters.
If this works out okay, we might enforce adding the CHANGELOG.md entry
for breaking changes. Other noteworthy changes can also be documented
there. This is and will remain entirely voluntary.
[3]
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/CHANGELOG.md
[4]
https://github.com/kubernetes/kubernetes/pull/138351
[5]
https://github.com/kubernetes/kubernetes/blob/master/hack/apidiff-changelog/api-changes-allowlist
With the final PR [6] in a much longer series of PRs merged, support for
context handling, including contextual logging, should be complete. One
known exception are some authentication plugin log calls which are
reached through APIs that don't support passing a context. Often new,
alternative APIs have to be used, otherwise client-go has to fall back
to the global klog logger. Look for "contextual logging" comments or
"logcheck:context" logcheck linter [7] annotations.
[6]
https://github.com/kubernetes/kubernetes/pull/129125
[7]
https://github.com/kubernetes-sigs/logtools/blob/main/logcheck/README.md
--
Best Regards
Patrick Ohly
Cloud Software Architect