Skip to content

Commit 2042fca

Browse files
committed
Store Aggregate UUIDs in the hypervisor status
For Cortex, we want the uuids in addition to the names, so keep track of them in the status.
1 parent 53fdc7a commit 2042fca

File tree

7 files changed

+46
-3
lines changed

7 files changed

+46
-3
lines changed

api/v1/hypervisor_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ type HypervisorStatus struct {
341341
// Aggregates are the applied aggregates of the hypervisor.
342342
Aggregates []string `json:"aggregates,omitempty"`
343343

344+
// +kubebuilder:default:={}
345+
// The UUIDs of the aggregates are used to apply aggregates to the hypervisor.
346+
AggregateUUIDs []string `json:"aggregateUUIDs,omitempty"`
347+
344348
// InternalIP is the internal IP address of the hypervisor.
345349
InternalIP string `json:"internalIp,omitempty"`
346350

api/v1/zz_generated.deepcopy.go

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

applyconfigurations/api/v1/hypervisorstatus.go

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

charts/openstack-hypervisor-operator/crds/hypervisor-crd.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ spec:
188188
status:
189189
description: HypervisorStatus defines the observed state of Hypervisor
190190
properties:
191+
aggregateUUIDs:
192+
default: []
193+
description: The UUIDs of the aggregates are used to apply aggregates
194+
to the hypervisor.
195+
items:
196+
type: string
197+
type: array
191198
aggregates:
192199
description: Aggregates are the applied aggregates of the hypervisor.
193200
items:

config/crd/bases/kvm.cloud.sap_hypervisors.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ spec:
189189
status:
190190
description: HypervisorStatus defines the observed state of Hypervisor
191191
properties:
192+
aggregateUUIDs:
193+
default: []
194+
description: The UUIDs of the aggregates are used to apply aggregates
195+
to the hypervisor.
196+
items:
197+
type: string
198+
type: array
192199
aggregates:
193200
description: Aggregates are the applied aggregates of the hypervisor.
194201
items:

internal/controller/aggregates_controller_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ var _ = Describe("AggregatesController", func() {
5050
"availability_zone": "",
5151
"deleted": false,
5252
"id": 100001,
53+
"uuid": "uuid-100001",
5354
"hosts": ["hv-test"]
5455
},
5556
{
5657
"name": "test-aggregate3",
5758
"availability_zone": "",
5859
"deleted": false,
5960
"id": 99,
61+
"uuid": "uuid-99",
6062
"hosts": ["hv-test"]
6163
}
6264
]
@@ -69,7 +71,8 @@ var _ = Describe("AggregatesController", func() {
6971
"name": "test-aggregate3",
7072
"availability_zone": "",
7173
"deleted": false,
72-
"id": 99
74+
"id": 99,
75+
"uuid": "uuid-99"
7376
}
7477
}`
7578

@@ -82,7 +85,8 @@ var _ = Describe("AggregatesController", func() {
8285
"hosts": [
8386
"hv-test"
8487
],
85-
"id": 42
88+
"id": 42,
89+
"uuid": "uuid-42"
8690
}
8791
}`
8892
)
@@ -159,6 +163,7 @@ var _ = Describe("AggregatesController", func() {
159163
"availability_zone": "",
160164
"deleted": false,
161165
"id": 42,
166+
"uuid": "uuid-42",
162167
"hosts": []
163168
}
164169
]
@@ -190,6 +195,7 @@ var _ = Describe("AggregatesController", func() {
190195
updated := &kvmv1.Hypervisor{}
191196
Expect(aggregatesController.Client.Get(ctx, hypervisorName, updated)).To(Succeed())
192197
Expect(updated.Status.Aggregates).To(ContainElements("test-aggregate1"))
198+
Expect(updated.Status.AggregateUUIDs).To(ContainElements("uuid-42"))
193199
Expect(meta.IsStatusConditionTrue(updated.Status.Conditions, kvmv1.ConditionTypeAggregatesUpdated)).To(BeTrue())
194200
})
195201
})
@@ -232,6 +238,7 @@ var _ = Describe("AggregatesController", func() {
232238
updated := &kvmv1.Hypervisor{}
233239
Expect(aggregatesController.Client.Get(ctx, hypervisorName, updated)).To(Succeed())
234240
Expect(updated.Status.Aggregates).To(BeEmpty())
241+
Expect(updated.Status.AggregateUUIDs).To(BeEmpty())
235242
Expect(meta.IsStatusConditionTrue(updated.Status.Conditions, kvmv1.ConditionTypeAggregatesUpdated)).To(BeTrue())
236243
})
237244
})

internal/controller/utils.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,13 @@ func ApplyAggregatesAndUpdateStatus(
166166
// Remove condition before OpenStack call to reflect unknown state on failure
167167
meta.RemoveStatusCondition(&hv.Status.Conditions, kvmv1.ConditionTypeAggregatesUpdated)
168168

169-
if _, err := openstack.ApplyAggregates(ctx, computeClient, hv.Name, desiredAggregates); err != nil {
169+
uuids, err := openstack.ApplyAggregates(ctx, computeClient, hv.Name, desiredAggregates)
170+
if err != nil {
170171
return fmt.Errorf("failed to apply aggregates: %w", err)
171172
}
172173

173174
hv.Status.Aggregates = desiredAggregates
175+
hv.Status.AggregateUUIDs = uuids
174176

175177
return nil
176178
}

0 commit comments

Comments
 (0)