@@ -53,12 +53,19 @@ func (r *KubeadmControlPlaneReconciler) initializeControlPlane(ctx context.Conte
53
53
return ctrl.Result {}, err
54
54
}
55
55
56
- if err := r .cloneConfigsAndGenerateMachine (ctx , controlPlane .Cluster , controlPlane .KCP , bootstrapSpec , fd ); err != nil {
56
+ newMachine , err := r .cloneConfigsAndGenerateMachine (ctx , controlPlane .Cluster , controlPlane .KCP , bootstrapSpec , fd )
57
+ if err != nil {
57
58
logger .Error (err , "Failed to create initial control plane Machine" )
58
59
r .recorder .Eventf (controlPlane .KCP , corev1 .EventTypeWarning , "FailedInitialization" , "Failed to create initial control plane Machine for cluster %s control plane: %v" , klog .KObj (controlPlane .Cluster ), err )
59
60
return ctrl.Result {}, err
60
61
}
61
62
63
+ logger .WithValues (controlPlane .StatusToLogKeyAndValues (newMachine , nil )... ).
64
+ Info ("Machine created (scale up)" ,
65
+ "Machine" , klog .KObj (newMachine ),
66
+ newMachine .Spec .InfrastructureRef .Kind , klog .KRef (newMachine .Spec .InfrastructureRef .Namespace , newMachine .Spec .InfrastructureRef .Name ),
67
+ newMachine .Spec .Bootstrap .ConfigRef .Kind , klog .KRef (newMachine .Spec .Bootstrap .ConfigRef .Namespace , newMachine .Spec .Bootstrap .ConfigRef .Name ))
68
+
62
69
// Requeue the control plane, in case there are additional operations to perform
63
70
return ctrl.Result {Requeue : true }, nil
64
71
}
@@ -87,12 +94,19 @@ func (r *KubeadmControlPlaneReconciler) scaleUpControlPlane(ctx context.Context,
87
94
return ctrl.Result {}, err
88
95
}
89
96
90
- if err := r .cloneConfigsAndGenerateMachine (ctx , controlPlane .Cluster , controlPlane .KCP , bootstrapSpec , fd ); err != nil {
97
+ newMachine , err := r .cloneConfigsAndGenerateMachine (ctx , controlPlane .Cluster , controlPlane .KCP , bootstrapSpec , fd )
98
+ if err != nil {
91
99
logger .Error (err , "Failed to create additional control plane Machine" )
92
100
r .recorder .Eventf (controlPlane .KCP , corev1 .EventTypeWarning , "FailedScaleUp" , "Failed to create additional control plane Machine for cluster % control plane: %v" , klog .KObj (controlPlane .Cluster ), err )
93
101
return ctrl.Result {}, err
94
102
}
95
103
104
+ logger .WithValues (controlPlane .StatusToLogKeyAndValues (newMachine , nil )... ).
105
+ Info ("Machine created (scale up)" ,
106
+ "Machine" , klog .KObj (newMachine ),
107
+ newMachine .Spec .InfrastructureRef .Kind , klog .KRef (newMachine .Spec .InfrastructureRef .Namespace , newMachine .Spec .InfrastructureRef .Name ),
108
+ newMachine .Spec .Bootstrap .ConfigRef .Kind , klog .KRef (newMachine .Spec .Bootstrap .ConfigRef .Namespace , newMachine .Spec .Bootstrap .ConfigRef .Name ))
109
+
96
110
// Requeue the control plane, in case there are other operations to perform
97
111
return ctrl.Result {Requeue : true }, nil
98
112
}
@@ -138,14 +152,14 @@ func (r *KubeadmControlPlaneReconciler) scaleDownControlPlane(
138
152
// NOTE: etcd member removal will be performed by the kcp-cleanup hook after machine completes drain & all volumes are detached.
139
153
}
140
154
141
- logger = logger .WithValues ("Machine" , klog .KObj (machineToDelete ))
142
- logger .Info ("Deleting Machine (scale down)" )
143
155
if err := r .Client .Delete (ctx , machineToDelete ); err != nil && ! apierrors .IsNotFound (err ) {
144
156
logger .Error (err , "Failed to delete control plane machine" )
145
157
r .recorder .Eventf (controlPlane .KCP , corev1 .EventTypeWarning , "FailedScaleDown" ,
146
158
"Failed to delete control plane Machine %s for cluster %s control plane: %v" , machineToDelete .Name , klog .KObj (controlPlane .Cluster ), err )
147
159
return ctrl.Result {}, err
148
160
}
161
+ logger .WithValues (controlPlane .StatusToLogKeyAndValues (nil , machineToDelete )... ).
162
+ Info ("Deleting Machine (scale down)" , "Machine" , klog .KObj (machineToDelete ))
149
163
150
164
// Requeue the control plane, in case there are additional operations to perform
151
165
return ctrl.Result {Requeue : true }, nil
0 commit comments