Skip to content

Commit 4502600

Browse files
committed
machineset: prepare splitting reconcile functions
1 parent f973add commit 4502600

File tree

7 files changed

+830
-174
lines changed

7 files changed

+830
-174
lines changed

api/v1beta1/machineset_types.go

+75
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,81 @@ type MachineSetSpec struct {
8787
Template MachineTemplateSpec `json:"template,omitempty"`
8888
}
8989

90+
// MachineSet's ScalingUp condition and corresponding reasons that will be used in v1Beta2 API version.
91+
const (
92+
// MachineSetScalingUpV1Beta2Condition is true if actual replicas < desired replicas.
93+
MachineSetScalingUpV1Beta2Condition = ScalingUpV1Beta2Condition
94+
95+
// MachineSetScalingUpV1Beta2Reason surfaces when actual replicas < desired replicas.
96+
MachineSetScalingUpV1Beta2Reason = ScalingUpV1Beta2Reason
97+
98+
// MachineSetNotScalingUpV1Beta2Reason surfaces when actual replicas >= desired replicas.
99+
MachineSetNotScalingUpV1Beta2Reason = NotScalingUpV1Beta2Reason
100+
101+
// MachineSetScalingUpInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines.
102+
MachineSetScalingUpInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
103+
104+
// MachineSetScalingUpWaitingForReplicasSetV1Beta2Reason surfaces when the .spec.replicas
105+
// field of the MachineSet is not set.
106+
MachineSetScalingUpWaitingForReplicasSetV1Beta2Reason = WaitingForReplicasSetV1Beta2Reason
107+
)
108+
109+
// MachineSet's ScalingDown condition and corresponding reasons that will be used in v1Beta2 API version.
110+
const (
111+
// MachineSetScalingDownV1Beta2Condition is true if actual replicas > desired replicas.
112+
MachineSetScalingDownV1Beta2Condition = ScalingDownV1Beta2Condition
113+
114+
// MachineSetScalingDownV1Beta2Reason surfaces when actual replicas > desired replicas.
115+
MachineSetScalingDownV1Beta2Reason = ScalingDownV1Beta2Reason
116+
117+
// MachineSetNotScalingDownV1Beta2Reason surfaces when actual replicas <= desired replicas.
118+
MachineSetNotScalingDownV1Beta2Reason = NotScalingDownV1Beta2Reason
119+
120+
// MachineSetScalingDownInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines.
121+
MachineSetScalingDownInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
122+
123+
// MachineSetScalingDownWaitingForReplicasToBeSetV1Beta2Reason surfaces when the .spec.replicas
124+
// field of the MachineSet is not set.
125+
MachineSetScalingDownWaitingForReplicasSetV1Beta2Reason = WaitingForReplicasSetV1Beta2Reason
126+
)
127+
128+
// MachineSet's MachinesReady condition and corresponding reasons that will be used in v1Beta2 API version.
129+
// Note: Reason's could also be derived from the aggregation of machine's Ready conditions.
130+
const (
131+
// MachineSetMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
132+
MachineSetMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition
133+
134+
// MachineSetMachinesReadyNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineSet.
135+
MachineSetMachinesReadyNoReplicasV1Beta2Reason = "NoReplicas"
136+
137+
// MachineSetMachinesReadyInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
138+
// or aggregating machine's conditions.
139+
MachineSetMachinesReadyInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
140+
)
141+
142+
// MachineSet's MachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
143+
// Note: Reason's could also be derived from the aggregation of machine's MachinesUpToDate conditions.
144+
const (
145+
// MachineSetMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
146+
MachineSetMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition
147+
148+
// MachineSetMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineSet.
149+
MachineSetMachinesUpToDateNoReplicasV1Beta2Reason = "NoReplicas"
150+
151+
// MachineSetMachinesUpToDateInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
152+
// or aggregating status.
153+
MachineSetMachinesUpToDateInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
154+
)
155+
156+
// Conditions that will be used for the MachineSet object in v1Beta2 API version.
157+
const (
158+
// MachineSetRemediatingV1Beta2Condition surfaces details about ongoing remediation of the controlled machines, if any.
159+
MachineSetRemediatingV1Beta2Condition = RemediatingV1Beta2Condition
160+
161+
// MachineSetDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
162+
MachineSetDeletingV1Beta2Condition = DeletingV1Beta2Condition
163+
)
164+
90165
// ANCHOR_END: MachineSetSpec
91166

92167
// ANCHOR: MachineTemplateSpec

api/v1beta1/v1beta2_condition_consts.go

+15-21
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ const (
9090
// AvailableV1Beta2Reason applies to a condition surfacing object availability.
9191
AvailableV1Beta2Reason = "Available"
9292

93+
// ScalingUpV1Beta2Reason surfaces when an object is scaling up.
94+
ScalingUpV1Beta2Reason = "ScalingUp"
95+
96+
// NotScalingUpV1Beta2Reason surfaces when an object is not scaling up.
97+
NotScalingUpV1Beta2Reason = "NotScalingUp"
98+
99+
// ScalingDownV1Beta2Reason surfaces when an object is scaling down.
100+
ScalingDownV1Beta2Reason = "ScalingDown"
101+
102+
// NotScalingDownV1Beta2Reason surfaces when an object is not scaling down.
103+
NotScalingDownV1Beta2Reason = "NotScalingDown"
104+
105+
// WaitingForReplicasSetV1Beta2Reason surfaces when the repicla field of an object is not set.
106+
WaitingForReplicasSetV1Beta2Reason = "WaitingForReplicasToBeSet"
107+
93108
// InvalidConditionReportedV1Beta2Reason applies to a condition, usually read from an external object, that is invalid
94109
// (e.g. its status is missing).
95110
InvalidConditionReportedV1Beta2Reason = "InvalidConditionReported"
@@ -141,27 +156,6 @@ const (
141156
DeletionCompletedV1Beta2Reason = "DeletionCompleted"
142157
)
143158

144-
// Conditions that will be used for the MachineSet object in v1Beta2 API version.
145-
const (
146-
// MachineSetMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
147-
MachineSetMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition
148-
149-
// MachineSetMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
150-
MachineSetMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition
151-
152-
// MachineSetScalingUpV1Beta2Condition is true if available replicas < desired replicas.
153-
MachineSetScalingUpV1Beta2Condition = ScalingUpV1Beta2Condition
154-
155-
// MachineSetScalingDownV1Beta2Condition is true if replicas > desired replicas.
156-
MachineSetScalingDownV1Beta2Condition = ScalingDownV1Beta2Condition
157-
158-
// MachineSetRemediatingV1Beta2Condition surfaces details about ongoing remediation of the controlled machines, if any.
159-
MachineSetRemediatingV1Beta2Condition = RemediatingV1Beta2Condition
160-
161-
// MachineSetDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
162-
MachineSetDeletingV1Beta2Condition = DeletingV1Beta2Condition
163-
)
164-
165159
// Conditions that will be used for the MachineDeployment object in v1Beta2 API version.
166160
const (
167161
// MachineDeploymentAvailableV1Beta2Condition is true if the MachineDeployment is not deleted, and it has minimum

internal/controllers/machine/machine_controller.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,12 @@ func doReconcile(ctx context.Context, phases []machineReconcileFunc, s *scope) (
328328
}
329329
res = util.LowestNonZeroResult(res, phaseResult)
330330
}
331-
return res, kerrors.NewAggregate(errs)
331+
332+
if len(errs) > 0 {
333+
return ctrl.Result{}, kerrors.NewAggregate(errs)
334+
}
335+
336+
return res, nil
332337
}
333338

334339
// scope holds the different objects that are read and used during the reconcile.

0 commit comments

Comments
 (0)