kube-controller-manager: readjust log verbosity

- Increase the global level for broadcaster's logging to 3 so that users can ignore event messages by lowering the logging level. It reduces information noise.
- Making sure the context is properly injected into the broadcaster, this will allow the -v flag value to be used also in that broadcaster, rather than the above global value.
- test: use cancellation from ktesting
- golangci-hints: checked error return value
This commit is contained in:
Mengjiao Liu
2023-12-13 16:11:08 +08:00
parent 1b07df8845
commit b584b87a94
66 changed files with 770 additions and 649 deletions

View File

@@ -86,7 +86,7 @@ func NewController(ctx context.Context, podInformer coreinformers.PodInformer,
client clientset.Interface,
endpointUpdatesBatchPeriod time.Duration,
) *Controller {
broadcaster := record.NewBroadcaster()
broadcaster := record.NewBroadcaster(record.WithContext(ctx))
recorder := broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "endpoint-slice-controller"})
endpointslicemetrics.RegisterMetrics()