Skip to content

Commit

Permalink
✨ Update machineset with v1beta2 status test (#11278)
Browse files Browse the repository at this point in the history
* machineset: prepare splitting reconcile functions

* improve and first unit tests

* fixes

* review fixes

* review fixes

* fix
  • Loading branch information
chrischdi authored Oct 22, 2024
1 parent fa7d6e0 commit 5d54746
Show file tree
Hide file tree
Showing 8 changed files with 1,597 additions and 177 deletions.
75 changes: 75 additions & 0 deletions api/v1beta1/machineset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,81 @@ type MachineSetSpec struct {
Template MachineTemplateSpec `json:"template,omitempty"`
}

// MachineSet's ScalingUp condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// MachineSetScalingUpV1Beta2Condition is true if actual replicas < desired replicas.
MachineSetScalingUpV1Beta2Condition = ScalingUpV1Beta2Condition

// MachineSetScalingUpV1Beta2Reason surfaces when actual replicas < desired replicas.
MachineSetScalingUpV1Beta2Reason = ScalingUpV1Beta2Reason

// MachineSetNotScalingUpV1Beta2Reason surfaces when actual replicas >= desired replicas.
MachineSetNotScalingUpV1Beta2Reason = NotScalingUpV1Beta2Reason

// MachineSetScalingUpInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines.
MachineSetScalingUpInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason

// MachineSetScalingUpWaitingForReplicasSetV1Beta2Reason surfaces when the .spec.replicas
// field of the MachineSet is not set.
MachineSetScalingUpWaitingForReplicasSetV1Beta2Reason = WaitingForReplicasSetV1Beta2Reason
)

// MachineSet's ScalingDown condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// MachineSetScalingDownV1Beta2Condition is true if actual replicas > desired replicas.
MachineSetScalingDownV1Beta2Condition = ScalingDownV1Beta2Condition

// MachineSetScalingDownV1Beta2Reason surfaces when actual replicas > desired replicas.
MachineSetScalingDownV1Beta2Reason = ScalingDownV1Beta2Reason

// MachineSetNotScalingDownV1Beta2Reason surfaces when actual replicas <= desired replicas.
MachineSetNotScalingDownV1Beta2Reason = NotScalingDownV1Beta2Reason

// MachineSetScalingDownInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines.
MachineSetScalingDownInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason

// MachineSetScalingDownWaitingForReplicasSetV1Beta2Reason surfaces when the .spec.replicas
// field of the MachineSet is not set.
MachineSetScalingDownWaitingForReplicasSetV1Beta2Reason = WaitingForReplicasSetV1Beta2Reason
)

// MachineSet's MachinesReady condition and corresponding reasons that will be used in v1Beta2 API version.
// Note: Reason's could also be derived from the aggregation of machine's Ready conditions.
const (
// MachineSetMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
MachineSetMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition

// MachineSetMachinesReadyNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineSet.
MachineSetMachinesReadyNoReplicasV1Beta2Reason = "NoReplicas"

// MachineSetMachinesReadyInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
// or aggregating machine's conditions.
MachineSetMachinesReadyInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)

// MachineSet's MachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
// Note: Reason's could also be derived from the aggregation of machine's MachinesUpToDate conditions.
const (
// MachineSetMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
MachineSetMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition

// MachineSetMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineSet.
MachineSetMachinesUpToDateNoReplicasV1Beta2Reason = "NoReplicas"

// MachineSetMachinesUpToDateInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
// or aggregating status.
MachineSetMachinesUpToDateInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)

// Conditions that will be used for the MachineSet object in v1Beta2 API version.
const (
// MachineSetRemediatingV1Beta2Condition surfaces details about ongoing remediation of the controlled machines, if any.
MachineSetRemediatingV1Beta2Condition = RemediatingV1Beta2Condition

// MachineSetDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
MachineSetDeletingV1Beta2Condition = DeletingV1Beta2Condition
)

// ANCHOR_END: MachineSetSpec

// ANCHOR: MachineTemplateSpec
Expand Down
36 changes: 15 additions & 21 deletions api/v1beta1/v1beta2_condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ const (
// AvailableV1Beta2Reason applies to a condition surfacing object availability.
AvailableV1Beta2Reason = "Available"

// ScalingUpV1Beta2Reason surfaces when an object is scaling up.
ScalingUpV1Beta2Reason = "ScalingUp"

// NotScalingUpV1Beta2Reason surfaces when an object is not scaling up.
NotScalingUpV1Beta2Reason = "NotScalingUp"

// ScalingDownV1Beta2Reason surfaces when an object is scaling down.
ScalingDownV1Beta2Reason = "ScalingDown"

// NotScalingDownV1Beta2Reason surfaces when an object is not scaling down.
NotScalingDownV1Beta2Reason = "NotScalingDown"

// WaitingForReplicasSetV1Beta2Reason surfaces when the replica field of an object is not set.
WaitingForReplicasSetV1Beta2Reason = "WaitingForReplicasSet"

// InvalidConditionReportedV1Beta2Reason applies to a condition, usually read from an external object, that is invalid
// (e.g. its status is missing).
InvalidConditionReportedV1Beta2Reason = "InvalidConditionReported"
Expand Down Expand Up @@ -144,27 +159,6 @@ const (
InspectionFailedV1Beta2Reason = "InspectionFailed"
)

// Conditions that will be used for the MachineSet object in v1Beta2 API version.
const (
// MachineSetMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
MachineSetMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition

// MachineSetMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
MachineSetMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition

// MachineSetScalingUpV1Beta2Condition is true if available replicas < desired replicas.
MachineSetScalingUpV1Beta2Condition = ScalingUpV1Beta2Condition

// MachineSetScalingDownV1Beta2Condition is true if replicas > desired replicas.
MachineSetScalingDownV1Beta2Condition = ScalingDownV1Beta2Condition

// MachineSetRemediatingV1Beta2Condition surfaces details about ongoing remediation of the controlled machines, if any.
MachineSetRemediatingV1Beta2Condition = RemediatingV1Beta2Condition

// MachineSetDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
MachineSetDeletingV1Beta2Condition = DeletingV1Beta2Condition
)

// Conditions that will be used for the MachineDeployment object in v1Beta2 API version.
const (
// MachineDeploymentAvailableV1Beta2Condition is true if the MachineDeployment is not deleted, and it has minimum
Expand Down
7 changes: 6 additions & 1 deletion internal/controllers/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,12 @@ func doReconcile(ctx context.Context, phases []machineReconcileFunc, s *scope) (
}
res = util.LowestNonZeroResult(res, phaseResult)
}
return res, kerrors.NewAggregate(errs)

if len(errs) > 0 {
return ctrl.Result{}, kerrors.NewAggregate(errs)
}

return res, nil
}

// scope holds the different objects that are read and used during the reconcile.
Expand Down
Loading

0 comments on commit 5d54746

Please sign in to comment.