Skip to content

Commit c8a14e4

Browse files
committed
Aggregates: Stylistic cleanup and fixes
1 parent 201d8f5 commit c8a14e4

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

internal/controller/aggregates_controller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ func (ac *AggregatesController) determineDesiredState(hv *kvmv1.Hypervisor) ([]s
143143
// If onboarding is in progress (Initial or Testing), add test aggregate
144144
onboardingCondition := meta.FindStatusCondition(hv.Status.Conditions, kvmv1.ConditionTypeOnboarding)
145145
if onboardingCondition != nil && onboardingCondition.Status == metav1.ConditionTrue {
146-
if onboardingCondition.Reason == kvmv1.ConditionReasonInitial ||
147-
onboardingCondition.Reason == kvmv1.ConditionReasonTesting {
146+
if onboardingCondition.Reason == kvmv1.ConditionReasonInitial || onboardingCondition.Reason == kvmv1.ConditionReasonTesting {
148147
zone := hv.Labels[corev1.LabelTopologyZone]
149148
return []string{zone, testAggregateName}, metav1.Condition{
150149
Type: kvmv1.ConditionTypeAggregatesUpdated,
@@ -154,7 +153,7 @@ func (ac *AggregatesController) determineDesiredState(hv *kvmv1.Hypervisor) ([]s
154153
}
155154
}
156155

157-
// If removing test aggregate, use Spec.Aggregates (no test aggregate)
156+
// If the onboarding is almost complete, it will wait (among other things) for this controller to switch to Spec.Aggregates
158157
if onboardingCondition.Reason == kvmv1.ConditionReasonHandover {
159158
return hv.Spec.Aggregates, metav1.Condition{
160159
Type: kvmv1.ConditionTypeAggregatesUpdated,

internal/openstack/aggregates.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,19 @@ func ApplyAggregates(ctx context.Context, serviceClient *gophercloud.ServiceClie
119119
}
120120
}
121121

122+
if len(errs) > 0 {
123+
return nil, errors.Join(errs...)
124+
}
125+
122126
// Collect aggregates with names and UUIDs
123127
for _, name := range desiredAggregates {
124-
if agg, exists := aggregateMap[name]; exists {
125-
result = append(result, kvmv1.Aggregate{
126-
Name: agg.Name,
127-
UUID: agg.UUID,
128-
})
129-
}
128+
agg := aggregateMap[name] // exists as per "Verify all desired aggregates exist" check
129+
result = append(result, kvmv1.Aggregate{
130+
Name: agg.Name,
131+
UUID: agg.UUID,
132+
})
130133
}
131134

132-
if len(errs) > 0 {
133-
return nil, errors.Join(errs...)
134-
}
135135
return result, nil
136136
}
137137

0 commit comments

Comments
 (0)