@@ -29,6 +29,7 @@ import (
29
29
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
30
30
"k8s.io/utils/pointer"
31
31
"sigs.k8s.io/cluster-api/util/annotations"
32
+ "sigs.k8s.io/cluster-api/util/conditions"
32
33
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
33
34
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
34
35
"sigs.k8s.io/controller-runtime/pkg/handler"
@@ -158,6 +159,14 @@ func (r *MachineReconciler) reconcileExternal(ctx context.Context, cluster *clus
158
159
159
160
// reconcileBootstrap reconciles the Spec.Bootstrap.ConfigRef object on a Machine.
160
161
func (r * MachineReconciler ) reconcileBootstrap (ctx context.Context , cluster * clusterv1.Cluster , m * clusterv1.Machine ) error {
162
+ // If the bootstrap data is populated, set ready and return.
163
+ if m .Spec .Bootstrap .DataSecretName != nil {
164
+ m .Status .BootstrapReady = true
165
+ conditions .MarkTrue (m , clusterv1 .BootstrapReadyCondition )
166
+ return nil
167
+ }
168
+
169
+ // If the Boostrap ref is nil (and so the machine should use user generated data secret), return.
161
170
if m .Spec .Bootstrap .ConfigRef == nil {
162
171
return nil
163
172
}
@@ -172,12 +181,6 @@ func (r *MachineReconciler) reconcileBootstrap(ctx context.Context, cluster *clu
172
181
}
173
182
bootstrapConfig := externalResult .Result
174
183
175
- // If the bootstrap data is populated, set ready and return.
176
- if m .Spec .Bootstrap .DataSecretName != nil {
177
- m .Status .BootstrapReady = true
178
- return nil
179
- }
180
-
181
184
// If the bootstrap config is being deleted, return early.
182
185
if ! bootstrapConfig .GetDeletionTimestamp ().IsZero () {
183
186
return nil
@@ -187,7 +190,16 @@ func (r *MachineReconciler) reconcileBootstrap(ctx context.Context, cluster *clu
187
190
ready , err := external .IsReady (bootstrapConfig )
188
191
if err != nil {
189
192
return err
190
- } else if ! ready {
193
+ }
194
+
195
+ // Report a summary of current status of the bootstrap object defined for this machine.
196
+ conditions .SetMirror (m , clusterv1 .BootstrapReadyCondition ,
197
+ conditions .UnstructuredGetter (bootstrapConfig ),
198
+ conditions .WithFallbackValue (ready , clusterv1 .WaitingForDataSecretFallbackReason , clusterv1 .ConditionSeverityInfo , "" ),
199
+ )
200
+
201
+ // If the bootstrap provider is not ready, requeue.
202
+ if ! ready {
191
203
return errors .Wrapf (& capierrors.RequeueAfterError {RequeueAfter : externalReadyWait },
192
204
"Bootstrap provider for Machine %q in namespace %q is not ready, requeuing" , m .Name , m .Namespace )
193
205
}
@@ -236,6 +248,14 @@ func (r *MachineReconciler) reconcileInfrastructure(ctx context.Context, cluster
236
248
return err
237
249
}
238
250
m .Status .InfrastructureReady = ready
251
+
252
+ // Report a summary of current status of the infrastructure object defined for this machine.
253
+ conditions .SetMirror (m , clusterv1 .InfrastructureReadyCondition ,
254
+ conditions .UnstructuredGetter (infraConfig ),
255
+ conditions .WithFallbackValue (ready , clusterv1 .WaitingForInfrastructureFallbackReason , clusterv1 .ConditionSeverityInfo , "" ),
256
+ )
257
+
258
+ // If the infrastructure provider is not ready, return early.
239
259
if ! ready {
240
260
return errors .Wrapf (& capierrors.RequeueAfterError {RequeueAfter : externalReadyWait },
241
261
"Infrastructure provider for Machine %q in namespace %q is not ready, requeuing" , m .Name , m .Namespace ,
0 commit comments