Skip to content

Commit 023c191

Browse files
committed
remove from old apis, ensure unhealthyMachineConditions is used/tested everywhere
1 parent 56608f2 commit 023c191

23 files changed

+461
-462
lines changed

api/core/v1beta1/conversion_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func TestFuzzyConversion(t *testing.T) {
7575

7676
func ClusterFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
7777
return []interface{}{
78+
hubClusterSpec,
7879
hubClusterStatus,
7980
spokeClusterTopology,
8081
spokeClusterStatus,
@@ -99,6 +100,21 @@ func hubClusterStatus(in *clusterv1.ClusterStatus, c fuzz.Continue) {
99100
}
100101
}
101102

103+
func hubClusterSpec(in *clusterv1.ClusterSpec, c fuzz.Continue) {
104+
c.FuzzNoCustom(in)
105+
106+
// remove MachineHealthCheck.UnhealthyMachineConditions as it does not exist in v1beta1.
107+
if in.Topology != nil && in.Topology.ControlPlane.MachineHealthCheck != nil {
108+
in.Topology.ControlPlane.MachineHealthCheck.UnhealthyMachineConditions = nil
109+
}
110+
111+
if in.Topology != nil && in.Topology.Workers != nil && len(in.Topology.Workers.MachineDeployments) > 0 {
112+
for i := range in.Topology.Workers.MachineDeployments {
113+
in.Topology.Workers.MachineDeployments[i].MachineHealthCheck = nil
114+
}
115+
}
116+
}
117+
102118
func spokeClusterTopology(in *Topology, c fuzz.Continue) {
103119
c.FuzzNoCustom(in)
104120

@@ -129,6 +145,22 @@ func ClusterClassFuncs(_ runtimeserializer.CodecFactory) []interface{} {
129145
hubJSONSchemaProps,
130146
spokeClusterClassStatus,
131147
spokeJSONSchemaProps,
148+
hubClusterClassSpec,
149+
}
150+
}
151+
152+
func hubClusterClassSpec(in *clusterv1.ClusterClassSpec, c fuzz.Continue) {
153+
c.FuzzNoCustom(in)
154+
155+
// remove MachineHealthCheck.UnhealthyMachineConditions as it does not exist in v1beta1.
156+
if in.ControlPlane.MachineHealthCheck != nil && in.ControlPlane.MachineHealthCheck.UnhealthyMachineConditions != nil {
157+
in.ControlPlane.MachineHealthCheck.UnhealthyMachineConditions = nil
158+
}
159+
160+
if len(in.Workers.MachineDeployments) > 0 {
161+
for i := range in.Workers.MachineDeployments {
162+
in.Workers.MachineDeployments[i].MachineHealthCheck = nil
163+
}
132164
}
133165
}
134166

@@ -348,11 +380,21 @@ func spokeMachineDeploymentStatus(in *MachineDeploymentStatus, c fuzz.Continue)
348380

349381
func MachineHealthCheckFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
350382
return []interface{}{
383+
hubMachineHealthCheckSpec,
351384
hubMachineHealthCheckStatus,
352385
spokeMachineHealthCheckStatus,
353386
}
354387
}
355388

389+
func hubMachineHealthCheckSpec(in *clusterv1.MachineHealthCheckSpec, c fuzz.Continue) {
390+
c.FuzzNoCustom(in)
391+
392+
// Drop UnhealthyMachineConditions as it does not exist in v1beta1.
393+
if in.UnhealthyMachineConditions != nil {
394+
in.UnhealthyMachineConditions = nil
395+
}
396+
}
397+
356398
func hubMachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, c fuzz.Continue) {
357399
c.FuzzNoCustom(in)
358400
// Drop empty structs with only omit empty fields.

api/core/v1beta1/machinehealthcheck_types.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ type MachineHealthCheckSpec struct {
6969
// +kubebuilder:validation:MaxItems=100
7070
UnhealthyConditions []UnhealthyCondition `json:"unhealthyConditions,omitempty"`
7171

72-
// unhealthyMachineConditions contains a list of the machine conditions that determine
73-
// whether a node is considered unhealthy. The conditions are combined in a
74-
// logical OR, i.e. if any of the conditions is met, the node is unhealthy.
75-
//
76-
// +optional
77-
// +kubebuilder:validation:MaxItems=100
78-
UnhealthyMachineConditions []UnhealthyMachineCondition `json:"unhealthyMachineConditions,omitempty"`
79-
8072
// maxUnhealthy specifies the maximum number of unhealthy machines allowed.
8173
// Any further remediation is only allowed if at most "maxUnhealthy" machines selected by
8274
// "selector" are not healthy.
@@ -156,34 +148,6 @@ type UnhealthyCondition struct {
156148

157149
// ANCHOR_END: UnhealthyCondition
158150

159-
// ANCHOR: UnhealthyMachineCondition
160-
161-
// UnhealthyMachineCondition represents a Node condition type and value with a timeout
162-
// specified as a duration. When the named condition has been in the given
163-
// status for at least the timeout value, a node is considered unhealthy.
164-
type UnhealthyMachineCondition struct {
165-
// type of Node condition
166-
// +kubebuilder:validation:Type=string
167-
// +kubebuilder:validation:MinLength=1
168-
// +required
169-
Type string `json:"type"`
170-
171-
// status of the condition, one of True, False, Unknown.
172-
// +kubebuilder:validation:Type=string
173-
// +kubebuilder:validation:MinLength=1
174-
// +required
175-
Status metav1.ConditionStatus `json:"status"`
176-
177-
// timeout is the duration that a node must be in a given status for,
178-
// after which the node is considered unhealthy.
179-
// For example, with a value of "1h", the node must match the status
180-
// for at least 1 hour before being considered unhealthy.
181-
// +required
182-
Timeout metav1.Duration `json:"timeout"`
183-
}
184-
185-
// ANCHOR_END: UnhealthyMachineCondition
186-
187151
// ANCHOR: MachineHealthCheckStatus
188152

189153
// MachineHealthCheckStatus defines the observed state of MachineHealthCheck.

api/core/v1beta1/zz_generated.conversion.go

Lines changed: 1 addition & 36 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: 0 additions & 21 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: 1 addition & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/core/v1beta2/clusterclass_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,14 @@ type MachineHealthCheckClass struct {
385385
// +kubebuilder:validation:MaxItems=100
386386
UnhealthyNodeConditions []UnhealthyNodeCondition `json:"unhealthyNodeConditions,omitempty"`
387387

388+
// unhealthyMachineConditions contains a list of the machine conditions that determine
389+
// whether a node is considered unhealthy. The conditions are combined in a
390+
// logical OR, i.e. if any of the conditions is met, the node is unhealthy.
391+
//
392+
// +optional
393+
// +kubebuilder:validation:MaxItems=100
394+
UnhealthyMachineConditions []UnhealthyMachineCondition `json:"unhealthyMachineConditions,omitempty"`
395+
388396
// maxUnhealthy specifies the maximum number of unhealthy machines allowed.
389397
// Any further remediation is only allowed if at most "maxUnhealthy" machines selected by
390398
// "selector" are not healthy.

0 commit comments

Comments
 (0)