Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ generate-e2e-templates-v1.11: $(KUSTOMIZE)
generate-e2e-templates-main: $(KUSTOMIZE)
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-md-remediation --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-md-remediation.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-mp-remediation --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-mp-remediation.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-kcp-remediation --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-kcp-remediation.yaml
$(KUSTOMIZE) build $(DOCKER_TEMPLATES)/main/cluster-template-kcp-adoption/step1 --load-restrictor LoadRestrictionsNone > $(DOCKER_TEMPLATES)/main/cluster-template-kcp-adoption.yaml
echo "---" >> $(DOCKER_TEMPLATES)/main/cluster-template-kcp-adoption.yaml
Expand Down
4 changes: 4 additions & 0 deletions api/core/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,10 @@ func Convert_v1beta1_MachinePoolSpec_To_v1beta2_MachinePoolSpec(in *MachinePoolS
return autoConvert_v1beta1_MachinePoolSpec_To_v1beta2_MachinePoolSpec(in, out, s)
}

func Convert_v1beta2_MachinePoolSpec_To_v1beta1_MachinePoolSpec(in *clusterv1.MachinePoolSpec, out *MachinePoolSpec, s apimachineryconversion.Scope) error {
return autoConvert_v1beta2_MachinePoolSpec_To_v1beta1_MachinePoolSpec(in, out, s)
}

func Convert_v1beta1_ClusterClassStatusVariableDefinition_To_v1beta2_ClusterClassStatusVariableDefinition(in *ClusterClassStatusVariableDefinition, out *clusterv1.ClusterClassStatusVariableDefinition, s apimachineryconversion.Scope) error {
if err := autoConvert_v1beta1_ClusterClassStatusVariableDefinition_To_v1beta2_ClusterClassStatusVariableDefinition(in, out, s); err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions api/core/v1beta1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ func spokeObjectReference(in *corev1.ObjectReference, c randfill.Continue) {

func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
return []interface{}{
hubMachinePoolSpec,
hubMachinePoolStatus,
hubMachineSpec,
spokeMachinePool,
Expand All @@ -789,6 +790,13 @@ func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
}
}

func hubMachinePoolSpec(in *clusterv1.MachinePoolSpec, c randfill.Continue) {
c.FillNoCustom(in)

// Readded in v1beta2 with different type than in v1alpha's, no conversion possible
in.Remediation = clusterv1.MachinePoolRemediationSpec{}
}

func hubMachinePoolStatus(in *clusterv1.MachinePoolStatus, c randfill.Continue) {
c.FillNoCustom(in)
// Always create struct with at least one mandatory fields.
Expand Down
11 changes: 11 additions & 0 deletions api/core/v1beta1/machinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ type MachinePoolSpec struct {
FailureDomains []string `json:"failureDomains,omitempty"`
}

// MachinePoolStrategy describes how to replace existing machines
// with new ones.
type MachinePoolStrategy struct {
// remediation controls the strategy of remediating unhealthy machines
// as marked by a MachineHealthCheck. This only applies to infrastructure
// providers supporting "MachinePool Machines". For other providers,
// no remediation is done.
// +optional
Remediation *RemediationStrategy `json:"remediation,omitempty"`
}

// MachinePoolStatus defines the observed state of MachinePool.
type MachinePoolStatus struct {
// nodeRefs will point to the corresponding Nodes if it they exist.
Expand Down
16 changes: 6 additions & 10 deletions api/core/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions api/core/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions api/core/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions api/core/v1beta2/machinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

capierrors "sigs.k8s.io/cluster-api/errors"
)
Expand Down Expand Up @@ -97,6 +98,29 @@ type MachinePoolSpec struct {
// +kubebuilder:validation:items:MinLength=1
// +kubebuilder:validation:items:MaxLength=256
FailureDomains []string `json:"failureDomains,omitempty"`

// remediation controls how unhealthy Machines are remediated (through a MachineHealthCheck).
// This only applies to infrastructure providers supporting and enabling the
// "MachinePool Machines" feature. For other setups, no remediation is done.
// +optional
Remediation MachinePoolRemediationSpec `json:"remediation,omitempty,omitzero"`
}

// MachinePoolRemediationSpec controls how unhealthy Machines are remediated (through a MachineHealthCheck).
// This only applies to infrastructure providers supporting and enabling the
// "MachinePool Machines" feature. For other setups, no remediation is done.
// +kubebuilder:validation:MinProperties=1
type MachinePoolRemediationSpec struct {
// maxInFlight determines how many in flight remediations should happen at the same time.
//
// MaxInFlight can be set to a fixed number or a percentage.
// Example: when this is set to 20%, the MachinePool controller deletes at most 20% of
// the desired replicas.
//
// If not set, remediation is limited to all machines under the active MachinePool's management.
//
// +optional
MaxInFlight *intstr.IntOrString `json:"maxInFlight,omitempty"`
}

// MachinePoolStatus defines the observed state of MachinePool.
Expand Down
21 changes: 21 additions & 0 deletions api/core/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 30 additions & 1 deletion api/core/v1beta2/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions config/crd/bases/cluster.x-k8s.io_machinepools.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
go.etcd.io/etcd/client/pkg/v3 v3.6.5
go.etcd.io/etcd/client/v3 v3.6.5
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/oauth2 v0.32.0
golang.org/x/text v0.30.0
gomodules.xyz/jsonpatch/v2 v2.5.0
Expand Down
15 changes: 14 additions & 1 deletion internal/api/core/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,16 @@ func (dst *MachinePool) ConvertFrom(srcRaw conversion.Hub) error {
return utilconversion.MarshalData(src, dst)
}

func Convert_v1alpha3_MachineDeploymentStrategy_To_v1beta2_MachinePoolStrategy(in *MachineDeploymentStrategy, out *clusterv1.MachinePoolRemediationSpec, _ apimachineryconversion.Scope) error {
// Subfields differ in v1beta2, no conversion possible
out.MaxInFlight = nil
return nil
}

func Convert_v1beta2_MachinePoolStrategy_To_v1alpha3_MachineDeploymentStrategy(in *clusterv1.MachinePoolRemediationSpec, out *MachineDeploymentStrategy, _ apimachineryconversion.Scope) error {
return nil
}

func Convert_v1beta2_MachineSetStatus_To_v1alpha3_MachineSetStatus(in *clusterv1.MachineSetStatus, out *MachineSetStatus, _ apimachineryconversion.Scope) error {
// Status.Conditions was introduced in v1alpha4, thus requiring a custom conversion function; the values is going to be preserved in an annotation thus allowing roundtrip without loosing informations
// V1Beta2 was added in v1beta1.
Expand Down Expand Up @@ -973,7 +983,10 @@ func Convert_v1alpha3_MachineSetSpec_To_v1beta2_MachineSetSpec(in *MachineSetSpe
return nil
}

// Convert_v1alpha3_MachinePoolSpec_To_v1beta2_MachinePoolSpec is an autogenerated conversion function.
func Convert_v1beta2_MachinePoolSpec_To_v1alpha3_MachinePoolSpec(in *clusterv1.MachinePoolSpec, out *MachinePoolSpec, s apimachineryconversion.Scope) error {
return autoConvert_v1beta2_MachinePoolSpec_To_v1alpha3_MachinePoolSpec(in, out, s)
}

func Convert_v1alpha3_MachinePoolSpec_To_v1beta2_MachinePoolSpec(in *MachinePoolSpec, out *clusterv1.MachinePoolSpec, s apimachineryconversion.Scope) error {
return autoConvert_v1alpha3_MachinePoolSpec_To_v1beta2_MachinePoolSpec(in, out, s)
}
Expand Down
Loading