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

@@ -29,10 +29,10 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/informers"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/klog/v2/ktesting"
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
"k8s.io/kubernetes/pkg/controller/endpointslice"
"k8s.io/kubernetes/test/integration/framework"
"k8s.io/kubernetes/test/utils/ktesting"
utilpointer "k8s.io/utils/pointer"
)
@@ -116,9 +116,9 @@ func TestEndpointSliceTerminating(t *testing.T) {
resyncPeriod := 12 * time.Hour
informers := informers.NewSharedInformerFactory(client, resyncPeriod)
_, ctx := ktesting.NewTestContext(t)
tCtx := ktesting.Init(t)
epsController := endpointslice.NewController(
ctx,
tCtx,
informers.Core().V1().Pods(),
informers.Core().V1().Services(),
informers.Core().V1().Nodes(),
@@ -128,10 +128,8 @@ func TestEndpointSliceTerminating(t *testing.T) {
1*time.Second)
// Start informer and controllers
ctx, cancel := context.WithCancel(ctx)
defer cancel()
informers.Start(ctx.Done())
go epsController.Run(ctx, 1)
informers.Start(tCtx.Done())
go epsController.Run(tCtx, 1)
// Create namespace
ns := framework.CreateNamespaceOrDie(client, "test-endpoints-terminating", t)