kube-controller-manager: convert to structured logging

Most of the individual controllers were already converted earlier. Some log
calls were missed or added and then not updated during a rebase. Some of those
get updated here to fill those gaps.

Adding of the name to the logger used by each controller gets
consolidated in this commit. By using the name under which the
controller is registered we ensure that the names in the log
are consistent.
This commit is contained in:
Patrick Ohly
2023-03-13 09:45:42 +01:00
parent 1cb334960c
commit 99151c39b7
19 changed files with 136 additions and 130 deletions

View File

@@ -23,8 +23,6 @@ import (
"context"
"fmt"
"k8s.io/klog/v2"
"k8s.io/controller-manager/controller"
"k8s.io/kubernetes/pkg/controller/cronjob"
"k8s.io/kubernetes/pkg/controller/job"
@@ -40,7 +38,6 @@ func startJobController(ctx context.Context, controllerContext ControllerContext
}
func startCronJobController(ctx context.Context, controllerContext ControllerContext) (controller.Interface, bool, error) {
ctx = klog.NewContext(ctx, klog.LoggerWithName(klog.FromContext(ctx), "cronjob-controller"))
cj2c, err := cronjob.NewControllerV2(ctx, controllerContext.InformerFactory.Batch().V1().Jobs(),
controllerContext.InformerFactory.Batch().V1().CronJobs(),
controllerContext.ClientBuilder.ClientOrDie("cronjob-controller"),