Skip to content

Commit 82ee71d

Browse files
More comments
1 parent d2760b4 commit 82ee71d

File tree

8 files changed

+293
-178
lines changed

8 files changed

+293
-178
lines changed

api/v1beta1/machine_types.go

+13-19
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const (
104104

105105
// MachineAvailableV1Beta2Reason surfaces when a machine is ready for at least MinReadySeconds.
106106
// Note: MinReadySeconds is assumed 0 until it will be implemented in v1beta2 API.
107-
MachineAvailableV1Beta2Reason = "MachineAvailable"
107+
MachineAvailableV1Beta2Reason = AvailableV1Beta2Condition
108108
)
109109

110110
// Machine's Ready condition and corresponding reasons that will be used in v1Beta2 API version.
@@ -124,7 +124,7 @@ const (
124124
// Note: UpToDate condition is set by the controller owning the machine.
125125
const (
126126
// MachineUpToDateV1Beta2Condition is true if the Machine spec matches the spec of the Machine's owner resource, e.g. KubeadmControlPlane or MachineDeployment.
127-
// The Machine's owner (e.g MachineDeployment) is authoritative to set their owned Machine's UpToDate conditions based on its current spec.
127+
// The Machine's owner (e.g. MachineDeployment) is authoritative to set their owned Machine's UpToDate conditions based on its current spec.
128128
MachineUpToDateV1Beta2Condition = "UpToDate"
129129
)
130130

@@ -139,11 +139,11 @@ const (
139139
MachineBootstrapDataSecretProvidedV1Beta2Reason = "DataSecretProvided"
140140

141141
// MachineBootstrapConfigInvalidConditionReportedV1Beta2Reason surfaces a BootstrapConfig Ready condition (read from a bootstrap config object) which is invalid.
142-
// (e.g. it is status is missing).
143-
MachineBootstrapConfigInvalidConditionReportedV1Beta2Reason = InvalidConditionReported
142+
// (e.g. its status is missing).
143+
MachineBootstrapConfigInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason
144144

145-
// MachineBootstrapConfigReadyNoV1Beta2ReasonReported applies to a BootstrapConfig Ready condition (read from a bootstrap config object) that reports no reason.
146-
MachineBootstrapConfigReadyNoV1Beta2ReasonReported = NoV1Beta2ReasonReported
145+
// MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason applies to a BootstrapConfig Ready condition (read from a bootstrap config object) that reports no reason.
146+
MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason = NoV1Beta2ReasonReported
147147

148148
// MachineBootstrapConfigInternalErrorV1Beta2Reason surfaces unexpected failures when reading a BootstrapConfig object.
149149
MachineBootstrapConfigInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
@@ -165,11 +165,11 @@ const (
165165
MachineInfrastructureReadyV1Beta2Condition = InfrastructureReadyV1Beta2Condition
166166

167167
// MachineInfrastructureInvalidConditionReportedV1Beta2Reason surfaces a infrastructure Ready condition (read from an infra machine object) which is invalid.
168-
// (e.g. it is status is missing).
169-
MachineInfrastructureInvalidConditionReportedV1Beta2Reason = InvalidConditionReported
168+
// (e.g. its status is missing).
169+
MachineInfrastructureInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason
170170

171-
// MachineInfrastructureReadyNoV1Beta2ReasonReported applies to a infrastructure Ready condition (read from an infra machine object) that reports no reason.
172-
MachineInfrastructureReadyNoV1Beta2ReasonReported = NoV1Beta2ReasonReported
171+
// MachineInfrastructureReadyNoReasonReportedV1Beta2Reason applies to a infrastructure Ready condition (read from an infra machine object) that reports no reason.
172+
MachineInfrastructureReadyNoReasonReportedV1Beta2Reason = NoV1Beta2ReasonReported
173173

174174
// MachineInfrastructureInternalErrorV1Beta2Reason surfaces unexpected failures when reading a infra machine object.
175175
MachineInfrastructureInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
@@ -196,14 +196,14 @@ const (
196196
// MachineNodeConditionNotYetReportedV1Beta2Reason surfaces when a Machine's Node doesn't have a condition reported yet.
197197
MachineNodeConditionNotYetReportedV1Beta2Reason = "NodeConditionNotYetReported"
198198

199-
// MachineNodeNotFoundV1Beta2Reason surfaces when the node hosted on the machine cannot be found.
199+
// MachineNodeDoesNotExistV1Beta2Reason surfaces when the node hosted on the machine does not exist.
200200
// Note: this could happen when creating the machine. However, this state should be treated as an error if it lasts indefinitely.
201-
MachineNodeNotFoundV1Beta2Reason = "NodeNotFound"
201+
MachineNodeDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason
202202

203203
// MachineNodeDeletedV1Beta2Reason surfaces when the node hosted on the machine has been deleted.
204204
// Note: controllers can't identify if the Node was deleted by the controller itself, e.g.
205205
// during the deletion workflow, or by a users.
206-
MachineNodeDeletedV1Beta2Reason = "NodeDeleted"
206+
MachineNodeDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
207207
)
208208

209209
// Machine's HealthCheckSucceeded and OwnerRemediated conditions and corresponding reasons that will be used in v1Beta2 API version.
@@ -228,12 +228,6 @@ const (
228228
const (
229229
// MachinePausedV1Beta2Condition is true if the Machine or the Cluster it belongs to are paused.
230230
MachinePausedV1Beta2Condition = PausedV1Beta2Condition
231-
232-
// MachineNotPausedV1Beta2Reason surfaces when a Machine is not paused.
233-
MachineNotPausedV1Beta2Reason = NotPausedV1Beta2Reason
234-
235-
// MachineObjectPausedV1Beta2Reason surfaces when a Machine is paused.
236-
MachineObjectPausedV1Beta2Reason = ObjectPausedV1Beta2Reason
237231
)
238232

239233
// ANCHOR: MachineSpec

api/v1beta1/v1beta2_condition_consts.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ const (
8787

8888
// Reasons that are used across different objects.
8989
const (
90-
// InvalidConditionReported applies to a condition, usually read from an external object, that is invalid
91-
// (e.g. it is status is missing).
92-
InvalidConditionReported = "InvalidConditionReported"
90+
// InvalidConditionReportedV1Beta2Reason applies to a condition, usually read from an external object, that is invalid
91+
// (e.g. its status is missing).
92+
InvalidConditionReportedV1Beta2Reason = "InvalidConditionReported"
9393

9494
// NoV1Beta2ReasonReported applies to a condition, usually read from an external object, that reports no reason.
9595
// Note: this could happen e.g. when an external object still uses Cluster API v1beta1 Conditions.
9696
NoV1Beta2ReasonReported = "NoReasonReported"
9797

9898
// InternalErrorV1Beta2Reason surfaces unexpected errors reporting by controllers.
99-
// In most cases, it will be required to look at controllers logs to proper triage those issues.
99+
// In most cases, it will be required to look at controllers logs to properly triage those issues.
100100
InternalErrorV1Beta2Reason = "InternalError"
101101

102102
// ObjectDoesNotExistV1Beta2Reason surfaces when a referenced object does not exist.
@@ -110,11 +110,8 @@ const (
110110
// NotPausedV1Beta2Reason surfaces when an object is not paused.
111111
NotPausedV1Beta2Reason = "NotPaused"
112112

113-
// ClusterPausedV1Beta2Reason surfaces when an Cluster is paused.
114-
ClusterPausedV1Beta2Reason = "ClusterPaused"
115-
116-
// ObjectPausedV1Beta2Reason surfaces when an object is paused.
117-
ObjectPausedV1Beta2Reason = "ObjectPaused"
113+
// PausedV1Beta2Reason surfaces when an object is paused.
114+
PausedV1Beta2Reason = "Paused"
118115
)
119116

120117
// Conditions that will be used for the MachineSet object in v1Beta2 API version.

internal/controllers/machine/machine_controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ func (r *Reconciler) reconcileDeleteBootstrap(ctx context.Context, s *scope) (bo
878878
return true, nil
879879
}
880880

881-
if s.bootstrapConfig != nil {
881+
if s.bootstrapConfig != nil && s.bootstrapConfig.GetDeletionTimestamp().IsZero() {
882882
if err := r.Client.Delete(ctx, s.bootstrapConfig); err != nil && !apierrors.IsNotFound(err) {
883883
return false, errors.Wrapf(err,
884884
"failed to delete %v %q for Machine %q in namespace %q",
@@ -895,7 +895,7 @@ func (r *Reconciler) reconcileDeleteInfrastructure(ctx context.Context, s *scope
895895
return true, nil
896896
}
897897

898-
if s.infraMachine != nil {
898+
if s.infraMachine != nil && s.infraMachine.GetDeletionTimestamp().IsZero() {
899899
if err := r.Client.Delete(ctx, s.infraMachine); err != nil && !apierrors.IsNotFound(err) {
900900
return false, errors.Wrapf(err,
901901
"failed to delete %v %q for Machine %q in namespace %q",

internal/controllers/machine/machine_controller_phases.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var externalReadyWait = 30 * time.Second
4949
func (r *Reconciler) reconcileExternal(ctx context.Context, cluster *clusterv1.Cluster, m *clusterv1.Machine, ref *corev1.ObjectReference) (*unstructured.Unstructured, error) {
5050
if err := utilconversion.UpdateReferenceAPIContract(ctx, r.Client, ref); err != nil {
5151
if apierrors.IsNotFound(err) {
52-
// We want to surface IsNotFound only for the referenced object, so we use a generic error in case CRD is not found.
52+
// We want to surface the NotFound error only for the referenced object, so we use a generic error in case CRD is not found.
5353
return nil, errors.New(err.Error())
5454
}
5555
return nil, err
@@ -180,6 +180,10 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, s *scope) (ctrl.Res
180180
fallBack,
181181
)
182182

183+
if !s.bootstrapConfig.GetDeletionTimestamp().IsZero() {
184+
return ctrl.Result{}, nil
185+
}
186+
183187
// If the bootstrap provider is not ready, return.
184188
if !ready {
185189
log.Info("Waiting for bootstrap provider to generate data secret and report status.ready", s.bootstrapConfig.GetKind(), klog.KObj(s.bootstrapConfig))
@@ -233,10 +237,6 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, s *scope) (ctr
233237
}
234238
s.infraMachine = obj
235239

236-
if !s.infraMachine.GetDeletionTimestamp().IsZero() {
237-
return ctrl.Result{}, nil
238-
}
239-
240240
// Determine if the infrastructure provider is ready.
241241
ready, err := external.IsReady(s.infraMachine)
242242
if err != nil {
@@ -256,6 +256,10 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, s *scope) (ctr
256256
fallBack,
257257
)
258258

259+
if !s.infraMachine.GetDeletionTimestamp().IsZero() {
260+
return ctrl.Result{}, nil
261+
}
262+
259263
// If the infrastructure provider is not ready (and it wasn't ready before), return early.
260264
if !ready && !m.Status.InfrastructureReady {
261265
log.Info("Waiting for infrastructure provider to create machine infrastructure and report status.ready", s.infraMachine.GetKind(), klog.KObj(s.infraMachine))

0 commit comments

Comments
 (0)