`debuggingRoundTripper` is a useful throbleshooting tool to debug of Kubernetes API requests and their timing.
Unfortunately, as of today, it can only be used via the `DebugWrappers` function, which automatically adjust the amount of debug information exposed by the roundTripper based on the configured `klog` verbosity.
While `DebugWrappers` definitely fits the purpose for clients using `klog`, this is currently hard to be used for controllers using `controller-runtime`, which uses `github.com/go-logr/logr` for logging.
In this PR we change the visibility of `newDebuggingRoundTripper` and `debugLevel` in order to be directly accessible from users of the `k8s.io/client-go/transport` package.
In particular, the changes proposed in this PR allow users of `controller-runtime` to use the `debuggingRoundTripper` to intercept Kubernetes API requests as follows
```go
import (
ctrl "sigs.k8s.io/controller-runtime"
)
func init() {
ctrl.SetLogger(zap.New())
}
func main() {
// wrap the http transport used by the Kubernetes client
restConfig, err := ctrl.GetConfig()
checkError(setupLog, err, "unable to get kubernetes client config")
restConfig.Wrap(func(rt http.RoundTripper) http.RoundTripper {
return transport.NewDebuggingRoundTripper(rt, transport.DebugJustURL)
})
...
}
```
Kubernetes-commit: 8de53ce96cb58d56fd00e91d8bcf7761ab498b83
Fixed a bug where initialPopulationCount should be based on the key length not list size in DeltaFIFO#Replace()
Kubernetes-commit: 7d8587c4cc3529dc9065c1536071ea382e6c725c
Note that the fake client isn't designed to work with informer. It
doesn't support resource version. It's encouraged to use a real client
in an integration/E2E test if you need to test complex behavior with
informer/controllers.
Kubernetes-commit: 942bc9b32e39bb9c6ca045c02b48cc84dfa86633
This changes the event recorder to use the equivalent of a select
statement instead of a goroutine to record events.
Previously, we used a goroutine to make event recording non-blocking.
Unfortunately, this writes to a channel, and during shutdown we then
race to write to a closed channel, panicing (caught by the error
handler, but still) and making the race detector unhappy.
Instead, we now use the select statement to make event emitting
non-blocking, and if we'd block, we just drop the event. We already
drop events if a particular sink is overloaded, so this just moves the
incoming event queue to match that behavior (and makes the incoming
event queue much longer).
This means that, if the user uses `Eventf` and friends correctly (i.e.
ensure they've returned by the time we call `Shutdown`), it's
now safe to call Shutdown. This matches the conventional go guidance on
channels: the writer should call close.
Kubernetes-commit: e90e67bd002e70a525d3ee9045b213a5d826074d
github.com/hashicorp/golang-lru is MPL 2 licensed, which means that
anyone who distributes code or binaries that incorporates it needs to
include its source code, even if they haven't made any modifications.
Since lrucacheexpire is picked up as a dependency of using the shared
informers in client-go, that's potentially a lot of distributors.
Most other deps of client-go are Apache 2.0, MIT, or BSD-like
licensed, which only requires including the license.
Rather than reverting to groupcache/lru, I just reimplemented the
functionality we need, which isn't much.
Kubernetes-commit: ecc53182475a00a4a1dc8ca1e056b0deb6bd430c
Adds unit tests covering the problematic scenarios identified
around conflicting data in child owner references
Before After
package level 51% 68%
garbagecollector.go 60% 75%
graph_builder.go 50% 81%
graph.go 50% 68%
Added/improved coverage of key functions that had lacking unit test coverage:
* attemptToDeleteWorker
* attemptToDeleteItem
* processGraphChanges (added coverage of all added code)
Kubernetes-commit: e491c3bc7056530d82590d95f0af0e8c4d8dded5