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:
@@ -55,17 +55,17 @@ type TestServer struct {
|
||||
// enough time to remove temporary files.
|
||||
func StartTestServer(ctx context.Context, customFlags []string) (result TestServer, err error) {
|
||||
logger := klog.FromContext(ctx)
|
||||
stopCh := make(chan struct{})
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
var errCh chan error
|
||||
tearDown := func() {
|
||||
close(stopCh)
|
||||
cancel()
|
||||
|
||||
// If the kube-controller-manager was started, let's wait for
|
||||
// it to shutdown clearly.
|
||||
// it to shutdown cleanly.
|
||||
if errCh != nil {
|
||||
err, ok := <-errCh
|
||||
if ok && err != nil {
|
||||
klog.Errorf("Failed to shutdown test server clearly: %v", err)
|
||||
logger.Error(err, "Failed to shutdown test server cleanly")
|
||||
}
|
||||
}
|
||||
if len(result.TmpDir) != 0 {
|
||||
@@ -112,21 +112,23 @@ func StartTestServer(ctx context.Context, customFlags []string) (result TestServ
|
||||
}
|
||||
|
||||
errCh = make(chan error)
|
||||
go func(stopCh <-chan struct{}) {
|
||||
go func(ctx context.Context) {
|
||||
defer close(errCh)
|
||||
|
||||
if err := app.Run(config.Complete(), stopCh); err != nil {
|
||||
if err := app.Run(ctx, config.Complete()); err != nil {
|
||||
errCh <- err
|
||||
}
|
||||
}(stopCh)
|
||||
}(ctx)
|
||||
|
||||
logger.Info("Waiting for /healthz to be ok...")
|
||||
client, err := kubernetes.NewForConfig(config.LoopbackClientConfig)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("failed to create a client: %v", err)
|
||||
}
|
||||
err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
||||
err = wait.PollWithContext(ctx, 100*time.Millisecond, 30*time.Second, func(ctx context.Context) (bool, error) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return false, ctx.Err()
|
||||
case err := <-errCh:
|
||||
return false, err
|
||||
default:
|
||||
|
Reference in New Issue
Block a user