Skip to content

Commit 7278f4a

Browse files
More comments
1 parent 82ee71d commit 7278f4a

File tree

6 files changed

+27
-19
lines changed

6 files changed

+27
-19
lines changed

api/v1beta1/machine_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const (
143143
MachineBootstrapConfigInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason
144144

145145
// MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason applies to a BootstrapConfig Ready condition (read from a bootstrap config object) that reports no reason.
146-
MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason = NoV1Beta2ReasonReported
146+
MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason = NoReasonReportedV1Beta2Reason
147147

148148
// MachineBootstrapConfigInternalErrorV1Beta2Reason surfaces unexpected failures when reading a BootstrapConfig object.
149149
MachineBootstrapConfigInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
@@ -169,7 +169,7 @@ const (
169169
MachineInfrastructureInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason
170170

171171
// MachineInfrastructureReadyNoReasonReportedV1Beta2Reason applies to a infrastructure Ready condition (read from an infra machine object) that reports no reason.
172-
MachineInfrastructureReadyNoReasonReportedV1Beta2Reason = NoV1Beta2ReasonReported
172+
MachineInfrastructureReadyNoReasonReportedV1Beta2Reason = NoReasonReportedV1Beta2Reason
173173

174174
// MachineInfrastructureInternalErrorV1Beta2Reason surfaces unexpected failures when reading a infra machine object.
175175
MachineInfrastructureInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason

api/v1beta1/v1beta2_condition_consts.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ const (
9191
// (e.g. its status is missing).
9292
InvalidConditionReportedV1Beta2Reason = "InvalidConditionReported"
9393

94-
// NoV1Beta2ReasonReported applies to a condition, usually read from an external object, that reports no reason.
94+
// NoReasonReportedV1Beta2Reason applies to a condition, usually read from an external object, that reports no reason.
9595
// Note: this could happen e.g. when an external object still uses Cluster API v1beta1 Conditions.
96-
NoV1Beta2ReasonReported = "NoReasonReported"
96+
NoReasonReportedV1Beta2Reason = "NoReasonReported"
9797

9898
// InternalErrorV1Beta2Reason surfaces unexpected errors reporting by controllers.
9999
// In most cases, it will be required to look at controllers logs to properly triage those issues.

internal/controllers/machine/machine_controller_status.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func setNodeHealthyAndReadyConditions(ctx context.Context, machine *clusterv1.Ma
234234
}
235235
reason := condition.Reason
236236
if reason == "" {
237-
reason = clusterv1.NoV1Beta2ReasonReported
237+
reason = clusterv1.NoReasonReportedV1Beta2Reason
238238
}
239239
nodeReady = &metav1.Condition{
240240
Type: clusterv1.MachineNodeReadyV1Beta2Condition,
@@ -461,7 +461,7 @@ func (c machineConditionCustomMergeStrategy) Merge(conditions []v1beta2condition
461461
}
462462
// Note: MachineNodeReadyV1Beta2Condition is not relevant for the summary.
463463
}
464-
return v1beta2conditions.GetDefaultMergePriority(nil)(condition)
464+
return v1beta2conditions.GetDefaultMergePriorityFunc(nil)(condition)
465465
}).Merge(conditions, conditionTypes)
466466
}
467467

internal/controllers/machine/machine_controller_status_test.go

+16-8
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ func TestSetBootstrapReadyCondition(t *testing.T) {
132132
},
133133
},
134134
{
135-
name: "Use status.BoostrapReady flag as a fallback Ready condition from bootstrap config is missing (ready true)",
136-
machine: defaultMachine.DeepCopy(),
135+
name: "Use status.BoostrapReady flag as a fallback Ready condition from bootstrap config is missing (ready true)",
136+
machine: func() *clusterv1.Machine {
137+
m := defaultMachine.DeepCopy()
138+
m.Status.BootstrapReady = true
139+
return m
140+
}(),
137141
bootstrapConfig: &unstructured.Unstructured{Object: map[string]interface{}{
138142
"kind": "GenericBootstrapConfig",
139143
"apiVersion": "bootstrap.cluster.x-k8s.io/v1beta1",
@@ -148,9 +152,9 @@ func TestSetBootstrapReadyCondition(t *testing.T) {
148152
bootstrapConfigIsNotFound: false,
149153
expectCondition: metav1.Condition{
150154
Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition,
151-
Status: metav1.ConditionFalse,
155+
Status: metav1.ConditionTrue,
152156
Reason: clusterv1.MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason,
153-
Message: "GenericBootstrapConfig status.ready is false",
157+
Message: "GenericBootstrapConfig status.ready is true",
154158
},
155159
},
156160
{
@@ -322,8 +326,12 @@ func TestSetInfrastructureReadyCondition(t *testing.T) {
322326
},
323327
},
324328
{
325-
name: "Use status.InfrastructureReady flag as a fallback Ready condition from infra machine is missing (ready true)",
326-
machine: defaultMachine.DeepCopy(),
329+
name: "Use status.InfrastructureReady flag as a fallback Ready condition from infra machine is missing (ready true)",
330+
machine: func() *clusterv1.Machine {
331+
m := defaultMachine.DeepCopy()
332+
m.Status.InfrastructureReady = true
333+
return m
334+
}(),
327335
infraMachine: &unstructured.Unstructured{Object: map[string]interface{}{
328336
"kind": "GenericInfrastructureMachine",
329337
"apiVersion": "infrastructure.cluster.x-k8s.io/v1beta1",
@@ -338,9 +346,9 @@ func TestSetInfrastructureReadyCondition(t *testing.T) {
338346
infraMachineIsNotFound: false,
339347
expectCondition: metav1.Condition{
340348
Type: clusterv1.MachineInfrastructureReadyV1Beta2Condition,
341-
Status: metav1.ConditionFalse,
349+
Status: metav1.ConditionTrue,
342350
Reason: clusterv1.MachineInfrastructureReadyNoReasonReportedV1Beta2Reason,
343-
Message: "GenericInfrastructureMachine status.ready is false",
351+
Message: "GenericInfrastructureMachine status.ready is true",
344352
},
345353
},
346354
{

util/conditions/v1beta2/merge_strategies.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ func DefaultMergeStrategyWithCustomPriority(getPriorityFunc func(condition metav
8282

8383
func newDefaultMergeStrategy(negativePolarityConditionTypes sets.Set[string]) MergeStrategy {
8484
return &defaultMergeStrategy{
85-
getPriorityFunc: GetDefaultMergePriority(negativePolarityConditionTypes),
85+
getPriorityFunc: GetDefaultMergePriorityFunc(negativePolarityConditionTypes),
8686
}
8787
}
8888

89-
// GetDefaultMergePriority returns the merge priority for each condition.
89+
// GetDefaultMergePriorityFunc returns the merge priority for each condition.
9090
// It assigns following priority values to conditions:
9191
// - issues: conditions with positive polarity (normal True) and status False or conditions with negative polarity (normal False) and status True.
9292
// - unknown: conditions with status unknown.
9393
// - info: conditions with positive polarity (normal True) and status True or conditions with negative polarity (normal False) and status False.
94-
func GetDefaultMergePriority(negativePolarityConditionTypes sets.Set[string]) func(condition metav1.Condition) MergePriority {
94+
func GetDefaultMergePriorityFunc(negativePolarityConditionTypes sets.Set[string]) func(condition metav1.Condition) MergePriority {
9595
return func(condition metav1.Condition) MergePriority {
9696
switch condition.Status {
9797
case metav1.ConditionTrue:

util/conditions/v1beta2/merge_strategies_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestSplitConditionsByPriority(t *testing.T) {
108108
{OwnerResource: ConditionOwnerInfo{Name: "baz"}, Condition: metav1.Condition{Type: "!C", Status: metav1.ConditionFalse}}, // info
109109
}
110110

111-
issueConditions, unknownConditions, infoConditions := splitConditionsByPriority(conditions, GetDefaultMergePriority(sets.New[string]("!C")))
111+
issueConditions, unknownConditions, infoConditions := splitConditionsByPriority(conditions, GetDefaultMergePriorityFunc(sets.New[string]("!C")))
112112

113113
// Check condition are grouped as expected and order is preserved.
114114

@@ -196,7 +196,7 @@ func TestDefaultMergePriority(t *testing.T) {
196196
if tt.negativePolarity {
197197
negativePolarityConditionTypes.Insert(tt.condition.Type)
198198
}
199-
gotPriority := GetDefaultMergePriority(negativePolarityConditionTypes)(tt.condition)
199+
gotPriority := GetDefaultMergePriorityFunc(negativePolarityConditionTypes)(tt.condition)
200200

201201
g.Expect(gotPriority).To(Equal(tt.wantPriority))
202202
})

0 commit comments

Comments
 (0)