@@ -102,7 +102,7 @@ type Scope struct {
102102// SetupWithManager sets up the reconciler with the Manager.
103103func (r * KubeadmConfigReconciler ) SetupWithManager (ctx context.Context , mgr ctrl.Manager , options controller.Options ) error {
104104 if r .KubeadmInitLock == nil {
105- r .KubeadmInitLock = locking .NewControlPlaneInitMutex (ctrl . LoggerFrom ( ctx ). WithName ( "init-locker" ), mgr .GetClient ())
105+ r .KubeadmInitLock = locking .NewControlPlaneInitMutex (mgr .GetClient ())
106106 }
107107 if r .remoteClientGetter == nil {
108108 r .remoteClientGetter = remote .NewClusterClient
@@ -173,7 +173,7 @@ func (r *KubeadmConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
173173 if configOwner == nil {
174174 return ctrl.Result {}, nil
175175 }
176- log = log .WithValues (configOwner .GetKind (), klog .KRef (configOwner .GetNamespace (), configOwner .GetName ()), "resourceVersion" , configOwner .GetResourceVersion ())
176+ log = log .WithValues (configOwner .LowerCamelCaseKind (), klog .KRef (configOwner .GetNamespace (), configOwner .GetName ()), "resourceVersion" , configOwner .GetResourceVersion ())
177177
178178 // Lookup the cluster the config owner is associated with
179179 cluster , err := util .GetClusterByName (ctx , r .Client , configOwner .GetNamespace (), configOwner .ClusterName ())
@@ -324,14 +324,14 @@ func (r *KubeadmConfigReconciler) rotateMachinePoolBootstrapToken(ctx context.Co
324324 return ctrl.Result {}, err
325325 }
326326 if shouldRotate {
327- log .V ( 2 ). Info ("Creating new bootstrap token" )
327+ log .Info ("Creating new bootstrap token, the existing one should be rotated " )
328328 token , err := createToken (ctx , remoteClient , r .TokenTTL )
329329 if err != nil {
330330 return ctrl.Result {}, errors .Wrapf (err , "failed to create new bootstrap token" )
331331 }
332332
333333 config .Spec .JoinConfiguration .Discovery .BootstrapToken .Token = token
334- log .Info ("Altering JoinConfiguration.Discovery.BootstrapToken" , " Token", token )
334+ log .V ( 3 ). Info ("Altering JoinConfiguration.Discovery.BootstrapToken. Token" )
335335
336336 // update the bootstrap data
337337 return r .joinWorker (ctx , scope )
@@ -381,7 +381,7 @@ func (r *KubeadmConfigReconciler) handleClusterNotInitialized(ctx context.Contex
381381 }
382382 }()
383383
384- scope .Info ("Creating BootstrapData for the init control plane" )
384+ scope .Info ("Creating BootstrapData for the first control plane" )
385385
386386 // Nb. in this case JoinConfiguration should not be defined by users, but in case of misconfigurations, CABPK simply ignore it
387387
@@ -498,6 +498,8 @@ func (r *KubeadmConfigReconciler) handleClusterNotInitialized(ctx context.Contex
498498}
499499
500500func (r * KubeadmConfigReconciler ) joinWorker (ctx context.Context , scope * Scope ) (ctrl.Result , error ) {
501+ scope .Info ("Creating BootstrapData for the worker node" )
502+
501503 certificates := secret .NewCertificatesForWorker (scope .Config .Spec .JoinConfiguration .CACertPath )
502504 err := certificates .Lookup (
503505 ctx ,
@@ -537,8 +539,6 @@ func (r *KubeadmConfigReconciler) joinWorker(ctx context.Context, scope *Scope)
537539 return ctrl.Result {}, errors .New ("Machine is a Worker, but JoinConfiguration.ControlPlane is set in the KubeadmConfig object" )
538540 }
539541
540- scope .Info ("Creating BootstrapData for the worker node" )
541-
542542 verbosityFlag := ""
543543 if scope .Config .Spec .Verbosity != nil {
544544 verbosityFlag = fmt .Sprintf ("--v %s" , strconv .Itoa (int (* scope .Config .Spec .Verbosity )))
@@ -595,6 +595,8 @@ func (r *KubeadmConfigReconciler) joinWorker(ctx context.Context, scope *Scope)
595595}
596596
597597func (r * KubeadmConfigReconciler ) joinControlplane (ctx context.Context , scope * Scope ) (ctrl.Result , error ) {
598+ scope .Info ("Creating BootstrapData for the joining control plane" )
599+
598600 if ! scope .ConfigOwner .IsControlPlaneMachine () {
599601 return ctrl.Result {}, fmt .Errorf ("%s is not a valid control plane kind, only Machine is supported" , scope .ConfigOwner .GetKind ())
600602 }
@@ -638,8 +640,6 @@ func (r *KubeadmConfigReconciler) joinControlplane(ctx context.Context, scope *S
638640 return ctrl.Result {}, err
639641 }
640642
641- scope .Info ("Creating BootstrapData for the join control plane" )
642-
643643 verbosityFlag := ""
644644 if scope .Config .Spec .Verbosity != nil {
645645 verbosityFlag = fmt .Sprintf ("--v %s" , strconv .Itoa (int (* scope .Config .Spec .Verbosity )))
@@ -892,7 +892,7 @@ func (r *KubeadmConfigReconciler) reconcileDiscovery(ctx context.Context, cluste
892892
893893 apiServerEndpoint = cluster .Spec .ControlPlaneEndpoint .String ()
894894 config .Spec .JoinConfiguration .Discovery .BootstrapToken .APIServerEndpoint = apiServerEndpoint
895- log .Info ("Altering JoinConfiguration.Discovery.BootstrapToken" , "APIServerEndpoint" , apiServerEndpoint )
895+ log .V ( 3 ). Info ("Altering JoinConfiguration.Discovery.BootstrapToken.APIServerEndpoint " , "APIServerEndpoint" , apiServerEndpoint )
896896 }
897897
898898 // if BootstrapToken already contains a token, respect it; otherwise create a new bootstrap token for the node to join
@@ -908,7 +908,7 @@ func (r *KubeadmConfigReconciler) reconcileDiscovery(ctx context.Context, cluste
908908 }
909909
910910 config .Spec .JoinConfiguration .Discovery .BootstrapToken .Token = token
911- log .Info ("Altering JoinConfiguration.Discovery.BootstrapToken" )
911+ log .V ( 3 ). Info ("Altering JoinConfiguration.Discovery.BootstrapToken.Token " )
912912 }
913913
914914 // If the BootstrapToken does not contain any CACertHashes then force skip CA Verification
@@ -930,39 +930,39 @@ func (r *KubeadmConfigReconciler) reconcileTopLevelObjectSettings(ctx context.Co
930930 // then use Cluster's ControlPlaneEndpoint as a control plane endpoint for the Kubernetes cluster.
931931 if config .Spec .ClusterConfiguration .ControlPlaneEndpoint == "" && cluster .Spec .ControlPlaneEndpoint .IsValid () {
932932 config .Spec .ClusterConfiguration .ControlPlaneEndpoint = cluster .Spec .ControlPlaneEndpoint .String ()
933- log .Info ("Altering ClusterConfiguration" , "ControlPlaneEndpoint" , config .Spec .ClusterConfiguration .ControlPlaneEndpoint )
933+ log .V ( 3 ). Info ("Altering ClusterConfiguration.ControlPlaneEndpoint " , "ControlPlaneEndpoint" , config .Spec .ClusterConfiguration .ControlPlaneEndpoint )
934934 }
935935
936936 // If there are no ClusterName defined in ClusterConfiguration, use Cluster.Name
937937 if config .Spec .ClusterConfiguration .ClusterName == "" {
938938 config .Spec .ClusterConfiguration .ClusterName = cluster .Name
939- log .Info ("Altering ClusterConfiguration" , "ClusterName" , config .Spec .ClusterConfiguration .ClusterName )
939+ log .V ( 3 ). Info ("Altering ClusterConfiguration.ClusterName " , "ClusterName" , config .Spec .ClusterConfiguration .ClusterName )
940940 }
941941
942942 // If there are no Network settings defined in ClusterConfiguration, use ClusterNetwork settings, if defined
943943 if cluster .Spec .ClusterNetwork != nil {
944944 if config .Spec .ClusterConfiguration .Networking .DNSDomain == "" && cluster .Spec .ClusterNetwork .ServiceDomain != "" {
945945 config .Spec .ClusterConfiguration .Networking .DNSDomain = cluster .Spec .ClusterNetwork .ServiceDomain
946- log .Info ("Altering ClusterConfiguration" , "DNSDomain" , config .Spec .ClusterConfiguration .Networking .DNSDomain )
946+ log .V ( 3 ). Info ("Altering ClusterConfiguration.Networking.DNSDomain " , "DNSDomain" , config .Spec .ClusterConfiguration .Networking .DNSDomain )
947947 }
948948 if config .Spec .ClusterConfiguration .Networking .ServiceSubnet == "" &&
949949 cluster .Spec .ClusterNetwork .Services != nil &&
950950 len (cluster .Spec .ClusterNetwork .Services .CIDRBlocks ) > 0 {
951951 config .Spec .ClusterConfiguration .Networking .ServiceSubnet = cluster .Spec .ClusterNetwork .Services .String ()
952- log .Info ("Altering ClusterConfiguration" , "ServiceSubnet" , config .Spec .ClusterConfiguration .Networking .ServiceSubnet )
952+ log .V ( 3 ). Info ("Altering ClusterConfiguration.Networking.ServiceSubnet " , "ServiceSubnet" , config .Spec .ClusterConfiguration .Networking .ServiceSubnet )
953953 }
954954 if config .Spec .ClusterConfiguration .Networking .PodSubnet == "" &&
955955 cluster .Spec .ClusterNetwork .Pods != nil &&
956956 len (cluster .Spec .ClusterNetwork .Pods .CIDRBlocks ) > 0 {
957957 config .Spec .ClusterConfiguration .Networking .PodSubnet = cluster .Spec .ClusterNetwork .Pods .String ()
958- log .Info ("Altering ClusterConfiguration" , "PodSubnet" , config .Spec .ClusterConfiguration .Networking .PodSubnet )
958+ log .V ( 3 ). Info ("Altering ClusterConfiguration.Networking.PodSubnet " , "PodSubnet" , config .Spec .ClusterConfiguration .Networking .PodSubnet )
959959 }
960960 }
961961
962962 // If there are no KubernetesVersion settings defined in ClusterConfiguration, use Version from machine, if defined
963963 if config .Spec .ClusterConfiguration .KubernetesVersion == "" && machine .Spec .Version != nil {
964964 config .Spec .ClusterConfiguration .KubernetesVersion = * machine .Spec .Version
965- log .Info ("Altering ClusterConfiguration" , "KubernetesVersion" , config .Spec .ClusterConfiguration .KubernetesVersion )
965+ log .V ( 3 ). Info ("Altering ClusterConfiguration.KubernetesVersion " , "KubernetesVersion" , config .Spec .ClusterConfiguration .KubernetesVersion )
966966 }
967967}
968968
@@ -1001,7 +1001,7 @@ func (r *KubeadmConfigReconciler) storeBootstrapData(ctx context.Context, scope
10011001 if ! apierrors .IsAlreadyExists (err ) {
10021002 return errors .Wrapf (err , "failed to create bootstrap data secret for KubeadmConfig %s/%s" , scope .Config .Namespace , scope .Config .Name )
10031003 }
1004- log .Info ("bootstrap data secret for KubeadmConfig already exists, updating" , "secret" , secret . Name , "KubeadmConfig" , scope . Config . Name )
1004+ log .Info ("bootstrap data secret for KubeadmConfig already exists, updating" , "secret" , klog . KObj ( secret ) )
10051005 if err := r .Client .Update (ctx , secret ); err != nil {
10061006 return errors .Wrapf (err , "failed to update bootstrap data secret for KubeadmConfig %s/%s" , scope .Config .Namespace , scope .Config .Name )
10071007 }
0 commit comments