@@ -211,8 +211,8 @@ func NewCloudControllerManagerCommand() *cobra.Command {
211211
212212// RunWrapper adapts the ccm boot logic to the leader elector call back function
213213func RunWrapper (s * options.CloudControllerManagerOptions , c * cloudcontrollerconfig.Config , h * controllerhealthz.MutableHealthzHandler ) func (ctx context.Context ) {
214- logger := log .Background ().WithName ("RunWrapper" )
215214 return func (ctx context.Context ) {
215+ logger := log .FromContextOrBackground (ctx ).WithName ("RunWrapper" )
216216 if ! c .DynamicReloadingConfig .EnableDynamicReloading {
217217 logger .V (1 ).Info ("using static initialization from config file" , "cloudConfigFile" , c .ComponentConfig .KubeCloudShared .CloudProvider .CloudConfigFile )
218218 if err := Run (ctx , c .Complete (), h ); err != nil {
@@ -289,8 +289,8 @@ func shouldDisableCloudProvider(configFilePath string) (bool, error) {
289289}
290290
291291func runAsync (s * options.CloudControllerManagerOptions , errCh chan error , h * controllerhealthz.MutableHealthzHandler ) context.CancelFunc {
292- logger := log .Background ().WithName ("runAsync" )
293292 ctx , cancelFunc := context .WithCancel (context .Background ())
293+ logger := log .FromContextOrBackground (ctx ).WithName ("runAsync" )
294294
295295 go func () {
296296 c , err := s .Config (KnownControllers (), ControllersDisabledByDefault .List (), names .CCMControllerAliases ())
@@ -344,7 +344,7 @@ func StartHTTPServer(ctx context.Context, c *cloudcontrollerconfig.CompletedConf
344344
345345// Run runs the ExternalCMServer. This should never exit.
346346func Run (ctx context.Context , c * cloudcontrollerconfig.CompletedConfig , h * controllerhealthz.MutableHealthzHandler ) error {
347- logger := log .Background ( ).WithName ("Run" )
347+ logger := log .FromContextOrBackground ( ctx ).WithName ("Run" )
348348 // To help debugging, immediately log version
349349 logger .Info ("Version" , "version" , version .Get ())
350350
@@ -401,7 +401,7 @@ func Run(ctx context.Context, c *cloudcontrollerconfig.CompletedConfig, h *contr
401401// startControllers starts the cloud specific controller loops.
402402func startControllers (ctx context.Context , controllerContext genericcontrollermanager.ControllerContext , completedConfig * cloudcontrollerconfig.CompletedConfig ,
403403 cloud cloudprovider.Interface , controllers map [string ]initFunc , healthzHandler * controllerhealthz.MutableHealthzHandler ) error {
404- logger := log .Background ( ).WithName ("startControllers" )
404+ logger := log .FromContextOrBackground ( ctx ).WithName ("startControllers" )
405405 // Initialize the cloud provider with a reference to the clientBuilder
406406 cloud .Initialize (completedConfig .ClientBuilder , ctx .Done ())
407407 // Set the informer on the user cloud object
0 commit comments