Skip to content

Commit 1077cc5

Browse files
committed
Remediate unhealthy MachinePool machines
1 parent 2ebc80d commit 1077cc5

19 files changed

+583
-50
lines changed

api/core/v1beta1/conversion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,10 @@ func Convert_v1beta1_MachinePoolSpec_To_v1beta2_MachinePoolSpec(in *MachinePoolS
12031203
return autoConvert_v1beta1_MachinePoolSpec_To_v1beta2_MachinePoolSpec(in, out, s)
12041204
}
12051205

1206+
func Convert_v1beta2_MachinePoolSpec_To_v1beta1_MachinePoolSpec(in *clusterv1.MachinePoolSpec, out *MachinePoolSpec, s apimachineryconversion.Scope) error {
1207+
return autoConvert_v1beta2_MachinePoolSpec_To_v1beta1_MachinePoolSpec(in, out, s)
1208+
}
1209+
12061210
func Convert_v1beta1_ClusterClassStatusVariableDefinition_To_v1beta2_ClusterClassStatusVariableDefinition(in *ClusterClassStatusVariableDefinition, out *clusterv1.ClusterClassStatusVariableDefinition, s apimachineryconversion.Scope) error {
12071211
if err := autoConvert_v1beta1_ClusterClassStatusVariableDefinition_To_v1beta2_ClusterClassStatusVariableDefinition(in, out, s); err != nil {
12081212
return err

api/core/v1beta1/conversion_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ func spokeObjectReference(in *corev1.ObjectReference, c randfill.Continue) {
583583

584584
func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
585585
return []interface{}{
586+
hubMachinePoolSpec,
586587
hubMachinePoolStatus,
587588
hubMachineSpec,
588589
spokeMachinePool,
@@ -591,6 +592,13 @@ func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
591592
}
592593
}
593594

595+
func hubMachinePoolSpec(in *clusterv1.MachinePoolSpec, c randfill.Continue) {
596+
c.FillNoCustom(in)
597+
598+
// Readded in v1beta2 with different type than in v1alpha's, no conversion possible
599+
in.Strategy = nil
600+
}
601+
594602
func hubMachinePoolStatus(in *clusterv1.MachinePoolStatus, c randfill.Continue) {
595603
c.FillNoCustom(in)
596604
// Always create struct with at least one mandatory fields.

api/core/v1beta1/machinepool_types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ type MachinePoolSpec struct {
108108

109109
// ANCHOR_END: MachinePoolSpec
110110

111+
// ANCHOR: MachinePoolStrategy
112+
113+
// MachinePoolStrategy describes how to replace existing machines
114+
// with new ones.
115+
type MachinePoolStrategy struct {
116+
// remediation controls the strategy of remediating unhealthy machines
117+
// as marked by a MachineHealthCheck. This only applies to infrastructure
118+
// providers supporting "MachinePool Machines". For other providers,
119+
// no remediation is done.
120+
// +optional
121+
Remediation *RemediationStrategy `json:"remediation,omitempty"`
122+
}
123+
124+
// ANCHOR_END: MachinePoolStrategy
125+
111126
// ANCHOR: MachinePoolStatus
112127

113128
// MachinePoolStatus defines the observed state of MachinePool.

api/core/v1beta1/zz_generated.conversion.go

Lines changed: 33 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/core/v1beta1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/core/v1beta1/zz_generated.openapi.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/core/v1beta2/machinepool_types.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,29 @@ type MachinePoolSpec struct {
9797
// +kubebuilder:validation:items:MinLength=1
9898
// +kubebuilder:validation:items:MaxLength=256
9999
FailureDomains []string `json:"failureDomains,omitempty"`
100+
101+
// strategy defines how to replace existing machines with new ones.
102+
// +optional
103+
Strategy *MachinePoolStrategy `json:"strategy,omitempty"`
100104
}
101105

102106
// ANCHOR_END: MachinePoolSpec
103107

108+
// ANCHOR: MachinePoolStrategy
109+
110+
// MachinePoolStrategy describes how to replace existing machines
111+
// with new ones.
112+
type MachinePoolStrategy struct {
113+
// remediation controls the strategy of remediating unhealthy machines
114+
// as marked by a MachineHealthCheck. This only applies to infrastructure
115+
// providers supporting "MachinePool Machines". For other providers,
116+
// no remediation is done.
117+
// +optional
118+
Remediation *RemediationStrategy `json:"remediation,omitempty"`
119+
}
120+
121+
// ANCHOR_END: MachinePoolStrategy
122+
104123
// ANCHOR: MachinePoolStatus
105124

106125
// MachinePoolStatus defines the observed state of MachinePool.

api/core/v1beta2/zz_generated.deepcopy.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/core/v1beta2/zz_generated.openapi.go

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machinepools.yaml

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)