Skip to content

Commit 654d714

Browse files
authored
Merge pull request #1938 from shiftstack/openstackcluster_apicleanup
🌱 Rename Ports fields in status
2 parents 2074438 + 4afdb80 commit 654d714

15 files changed

+77
-77
lines changed

api/v1alpha6/openstackcluster_conversion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ func restorev1beta1ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst *
370370
if previous.Bastion != nil {
371371
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
372372
}
373-
if previous.Bastion != nil && previous.Bastion.DependentResources.PortsStatus != nil {
374-
dst.Bastion.DependentResources.PortsStatus = previous.Bastion.DependentResources.PortsStatus
373+
if previous.Bastion != nil && previous.Bastion.DependentResources.Ports != nil {
374+
dst.Bastion.DependentResources.Ports = previous.Bastion.DependentResources.Ports
375375
}
376376
}
377377

api/v1alpha7/openstackcluster_conversion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ func restorev1beta1ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst *
355355
dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources
356356
}
357357

358-
if previous.Bastion != nil && previous.Bastion.DependentResources.PortsStatus != nil {
359-
dst.Bastion.DependentResources.PortsStatus = previous.Bastion.DependentResources.PortsStatus
358+
if previous.Bastion != nil && previous.Bastion.DependentResources.Ports != nil {
359+
dst.Bastion.DependentResources.Ports = previous.Bastion.DependentResources.Ports
360360
}
361361
}
362362

api/v1beta1/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,15 +654,15 @@ type ReferencedMachineResources struct {
654654
// +optional
655655
ImageID string `json:"imageID,omitempty"`
656656

657-
// portsOpts is the list of ports options to create for the machine.
657+
// Ports is the fully resolved list of ports to create for the machine.
658658
// +optional
659-
PortsOpts []PortOpts `json:"portsOpts,omitempty"`
659+
Ports []PortOpts `json:"ports,omitempty"`
660660
}
661661

662662
type DependentMachineResources struct {
663-
// PortsStatus is the status of the ports created for the machine.
663+
// Ports is the status of the ports created for the machine.
664664
// +optional
665-
PortsStatus []PortStatus `json:"portsStatus,omitempty"`
665+
Ports []PortStatus `json:"ports,omitempty"`
666666
}
667667

668668
// ValueSpec represents a single value_spec key-value pair.

api/v1beta1/zz_generated.deepcopy.go

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

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6201,9 +6201,9 @@ spec:
62016201
properties:
62026202
dependentResources:
62036203
properties:
6204-
portsStatus:
6205-
description: PortsStatus is the status of the ports created
6206-
for the machine.
6204+
ports:
6205+
description: Ports is the status of the ports created for
6206+
the machine.
62076207
items:
62086208
properties:
62096209
id:
@@ -6230,9 +6230,9 @@ spec:
62306230
description: ImageID is the ID of the image to use for the
62316231
machine and is calculated based on ImageFilter.
62326232
type: string
6233-
portsOpts:
6234-
description: portsOpts is the list of ports options to create
6235-
for the machine.
6233+
ports:
6234+
description: Ports is the fully resolved list of ports to
6235+
create for the machine.
62366236
items:
62376237
properties:
62386238
adminStateUp:

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachines.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,9 +2396,9 @@ spec:
23962396
description: DependentResources contains resolved dependent resources
23972397
that were created by the machine.
23982398
properties:
2399-
portsStatus:
2400-
description: PortsStatus is the status of the ports created for
2401-
the machine.
2399+
ports:
2400+
description: Ports is the status of the ports created for the
2401+
machine.
24022402
items:
24032403
properties:
24042404
id:
@@ -2449,8 +2449,8 @@ spec:
24492449
description: ImageID is the ID of the image to use for the machine
24502450
and is calculated based on ImageFilter.
24512451
type: string
2452-
portsOpts:
2453-
description: portsOpts is the list of ports options to create
2452+
ports:
2453+
description: Ports is the fully resolved list of ports to create
24542454
for the machine.
24552455
items:
24562456
properties:

controllers/openstackcluster_controller.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,18 @@ func deleteBastion(scope *scope.WithLogger, cluster *clusterv1.Cluster, openStac
293293
}
294294
}
295295

296-
if openStackCluster.Status.Bastion != nil && len(openStackCluster.Status.Bastion.DependentResources.PortsStatus) > 0 {
296+
if openStackCluster.Status.Bastion != nil && len(openStackCluster.Status.Bastion.DependentResources.Ports) > 0 {
297297
trunkSupported, err := networkingService.IsTrunkExtSupported()
298298
if err != nil {
299299
return err
300300
}
301-
for _, port := range openStackCluster.Status.Bastion.DependentResources.PortsStatus {
301+
for _, port := range openStackCluster.Status.Bastion.DependentResources.Ports {
302302
if err := networkingService.DeleteInstanceTrunkAndPort(openStackCluster, port, trunkSupported); err != nil {
303303
handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to delete port: %w", err))
304304
return fmt.Errorf("failed to delete port: %w", err)
305305
}
306306
}
307-
openStackCluster.Status.Bastion.DependentResources.PortsStatus = nil
307+
openStackCluster.Status.Bastion.DependentResources.Ports = nil
308308
}
309309

310310
scope.Logger().Info("Deleted Bastion for cluster %s", cluster.Name)
@@ -375,7 +375,7 @@ func reconcileBastion(scope *scope.WithLogger, cluster *clusterv1.Cluster, openS
375375

376376
// If ports options aren't in the status, we'll re-trigger the reconcile to get them
377377
// via adopting the referenced resources.
378-
if len(openStackCluster.Status.Bastion.ReferencedResources.PortsOpts) == 0 {
378+
if len(openStackCluster.Status.Bastion.ReferencedResources.Ports) == 0 {
379379
return reconcile.Result{}, nil
380380
}
381381

@@ -409,7 +409,7 @@ func reconcileBastion(scope *scope.WithLogger, cluster *clusterv1.Cluster, openS
409409
handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to get or create ports for bastion: %w", err))
410410
return ctrl.Result{}, fmt.Errorf("failed to get or create ports for bastion: %w", err)
411411
}
412-
bastionPortIDs := GetPortIDs(openStackCluster.Status.Bastion.DependentResources.PortsStatus)
412+
bastionPortIDs := GetPortIDs(openStackCluster.Status.Bastion.DependentResources.Ports)
413413

414414
var instanceStatus *compute.InstanceStatus
415415
if openStackCluster.Status.Bastion != nil && openStackCluster.Status.Bastion.ID != "" {
@@ -555,12 +555,12 @@ func getOrCreateBastionPorts(scope *scope.WithLogger, cluster *clusterv1.Cluster
555555
openStackCluster.Status.Bastion = &infrav1.BastionStatus{}
556556
}
557557

558-
desiredPorts := openStackCluster.Status.Bastion.ReferencedResources.PortsOpts
559-
portsToCreate := networking.MissingPorts(openStackCluster.Status.Bastion.DependentResources.PortsStatus, desiredPorts)
558+
desiredPorts := openStackCluster.Status.Bastion.ReferencedResources.Ports
559+
portsToCreate := networking.MissingPorts(openStackCluster.Status.Bastion.DependentResources.Ports, desiredPorts)
560560

561561
// Sanity check that the number of desired ports is equal to the addition of ports to create and ports that already exist.
562-
if len(desiredPorts) != len(portsToCreate)+len(openStackCluster.Status.Bastion.DependentResources.PortsStatus) {
563-
return fmt.Errorf("length of desired ports (%d) is not equal to the length of ports to create (%d) + the length of ports that already exist (%d)", len(desiredPorts), len(portsToCreate), len(openStackCluster.Status.Bastion.DependentResources.PortsStatus))
562+
if len(desiredPorts) != len(portsToCreate)+len(openStackCluster.Status.Bastion.DependentResources.Ports) {
563+
return fmt.Errorf("length of desired ports (%d) is not equal to the length of ports to create (%d) + the length of ports that already exist (%d)", len(desiredPorts), len(portsToCreate), len(openStackCluster.Status.Bastion.DependentResources.Ports))
564564
}
565565

566566
if len(portsToCreate) > 0 {
@@ -570,12 +570,12 @@ func getOrCreateBastionPorts(scope *scope.WithLogger, cluster *clusterv1.Cluster
570570
return fmt.Errorf("failed to create ports for bastion %s: %w", bastionName(openStackCluster.Name), err)
571571
}
572572

573-
openStackCluster.Status.Bastion.DependentResources.PortsStatus = append(openStackCluster.Status.Bastion.DependentResources.PortsStatus, bastionPortsStatus...)
573+
openStackCluster.Status.Bastion.DependentResources.Ports = append(openStackCluster.Status.Bastion.DependentResources.Ports, bastionPortsStatus...)
574574
}
575575

576576
// Sanity check that the number of ports that have been put into PortsStatus is equal to the number of desired ports now that we have created them all.
577-
if len(openStackCluster.Status.Bastion.DependentResources.PortsStatus) != len(desiredPorts) {
578-
return fmt.Errorf("length of ports that already exist (%d) is not equal to the length of desired ports (%d)", len(openStackCluster.Status.Bastion.DependentResources.PortsStatus), len(desiredPorts))
577+
if len(openStackCluster.Status.Bastion.DependentResources.Ports) != len(desiredPorts) {
578+
return fmt.Errorf("length of ports that already exist (%d) is not equal to the length of desired ports (%d)", len(openStackCluster.Status.Bastion.DependentResources.Ports), len(desiredPorts))
579579
}
580580

581581
return nil

controllers/openstackcluster_controller_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ var _ = Describe("OpenStackCluster controller", func() {
234234
Bastion: &infrav1.BastionStatus{
235235
ReferencedResources: infrav1.ReferencedMachineResources{
236236
ImageID: "imageID",
237-
PortsOpts: []infrav1.PortOpts{
237+
Ports: []infrav1.PortOpts{
238238
{
239239
Network: &infrav1.NetworkFilter{
240240
ID: "network-id",
@@ -243,7 +243,7 @@ var _ = Describe("OpenStackCluster controller", func() {
243243
},
244244
},
245245
DependentResources: infrav1.DependentMachineResources{
246-
PortsStatus: []infrav1.PortStatus{
246+
Ports: []infrav1.PortStatus{
247247
{
248248
ID: "portID1",
249249
},
@@ -285,7 +285,7 @@ var _ = Describe("OpenStackCluster controller", func() {
285285
State: "ACTIVE",
286286
ReferencedResources: infrav1.ReferencedMachineResources{
287287
ImageID: "imageID",
288-
PortsOpts: []infrav1.PortOpts{
288+
Ports: []infrav1.PortOpts{
289289
{
290290
Network: &infrav1.NetworkFilter{
291291
ID: "network-id",
@@ -294,7 +294,7 @@ var _ = Describe("OpenStackCluster controller", func() {
294294
},
295295
},
296296
DependentResources: infrav1.DependentMachineResources{
297-
PortsStatus: []infrav1.PortStatus{
297+
Ports: []infrav1.PortStatus{
298298
{
299299
ID: "portID1",
300300
},
@@ -326,7 +326,7 @@ var _ = Describe("OpenStackCluster controller", func() {
326326
ID: "adopted-fip-bastion-uuid",
327327
ReferencedResources: infrav1.ReferencedMachineResources{
328328
ImageID: "imageID",
329-
PortsOpts: []infrav1.PortOpts{
329+
Ports: []infrav1.PortOpts{
330330
{
331331
Network: &infrav1.NetworkFilter{
332332
ID: "network-id",
@@ -335,7 +335,7 @@ var _ = Describe("OpenStackCluster controller", func() {
335335
},
336336
},
337337
DependentResources: infrav1.DependentMachineResources{
338-
PortsStatus: []infrav1.PortStatus{
338+
Ports: []infrav1.PortStatus{
339339
{
340340
ID: "portID1",
341341
},
@@ -370,7 +370,7 @@ var _ = Describe("OpenStackCluster controller", func() {
370370
State: "ACTIVE",
371371
ReferencedResources: infrav1.ReferencedMachineResources{
372372
ImageID: "imageID",
373-
PortsOpts: []infrav1.PortOpts{
373+
Ports: []infrav1.PortOpts{
374374
{
375375
Network: &infrav1.NetworkFilter{
376376
ID: "network-id",
@@ -379,7 +379,7 @@ var _ = Describe("OpenStackCluster controller", func() {
379379
},
380380
},
381381
DependentResources: infrav1.DependentMachineResources{
382-
PortsStatus: []infrav1.PortStatus{
382+
Ports: []infrav1.PortStatus{
383383
{
384384
ID: "portID1",
385385
},
@@ -411,7 +411,7 @@ var _ = Describe("OpenStackCluster controller", func() {
411411
ID: "requeue-bastion-uuid",
412412
ReferencedResources: infrav1.ReferencedMachineResources{
413413
ImageID: "imageID",
414-
PortsOpts: []infrav1.PortOpts{
414+
Ports: []infrav1.PortOpts{
415415
{
416416
Network: &infrav1.NetworkFilter{
417417
ID: "network-id",
@@ -420,7 +420,7 @@ var _ = Describe("OpenStackCluster controller", func() {
420420
},
421421
},
422422
DependentResources: infrav1.DependentMachineResources{
423-
PortsStatus: []infrav1.PortStatus{
423+
Ports: []infrav1.PortStatus{
424424
{
425425
ID: "portID1",
426426
},
@@ -449,7 +449,7 @@ var _ = Describe("OpenStackCluster controller", func() {
449449
State: "BUILD",
450450
ReferencedResources: infrav1.ReferencedMachineResources{
451451
ImageID: "imageID",
452-
PortsOpts: []infrav1.PortOpts{
452+
Ports: []infrav1.PortOpts{
453453
{
454454
Network: &infrav1.NetworkFilter{
455455
ID: "network-id",
@@ -458,7 +458,7 @@ var _ = Describe("OpenStackCluster controller", func() {
458458
},
459459
},
460460
DependentResources: infrav1.DependentMachineResources{
461-
PortsStatus: []infrav1.PortStatus{
461+
Ports: []infrav1.PortStatus{
462462
{
463463
ID: "portID1",
464464
},
@@ -532,7 +532,7 @@ var _ = Describe("OpenStackCluster controller", func() {
532532
testCluster.Status = infrav1.OpenStackClusterStatus{
533533
Bastion: &infrav1.BastionStatus{
534534
DependentResources: infrav1.DependentMachineResources{
535-
PortsStatus: []infrav1.PortStatus{
535+
Ports: []infrav1.PortStatus{
536536
{
537537
ID: "port-id",
538538
},
@@ -616,7 +616,7 @@ var _ = Describe("OpenStackCluster controller", func() {
616616
testCluster.Status = infrav1.OpenStackClusterStatus{
617617
Bastion: &infrav1.BastionStatus{
618618
DependentResources: infrav1.DependentMachineResources{
619-
PortsStatus: []infrav1.PortStatus{
619+
Ports: []infrav1.PortStatus{
620620
{
621621
ID: "port-id",
622622
},

controllers/openstackmachine_controller.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (r *OpenStackMachineReconciler) reconcileDelete(scope *scope.WithLogger, cl
313313
return ctrl.Result{}, err
314314
}
315315

316-
portsStatus := openStackMachine.Status.DependentResources.PortsStatus
316+
portsStatus := openStackMachine.Status.DependentResources.Ports
317317
for _, port := range portsStatus {
318318
if err := networkingService.DeleteInstanceTrunkAndPort(openStackMachine, port, trunkSupported); err != nil {
319319
return ctrl.Result{}, fmt.Errorf("failed to delete port %q: %w", port.ID, err)
@@ -383,7 +383,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
383383
if err != nil {
384384
return ctrl.Result{}, err
385385
}
386-
portIDs := GetPortIDs(openStackMachine.Status.DependentResources.PortsStatus)
386+
portIDs := GetPortIDs(openStackMachine.Status.DependentResources.Ports)
387387

388388
instanceStatus, err := r.getOrCreateInstance(scope.Logger(), openStackCluster, machine, openStackMachine, computeService, userData, portIDs)
389389
if err != nil || instanceStatus == nil {
@@ -498,12 +498,12 @@ func getOrCreateMachinePorts(scope *scope.WithLogger, openStackCluster *infrav1.
498498
var machinePortsStatus []infrav1.PortStatus
499499
var err error
500500

501-
desiredPorts := openStackMachine.Status.ReferencedResources.PortsOpts
502-
portsToCreate := networking.MissingPorts(openStackMachine.Status.DependentResources.PortsStatus, desiredPorts)
501+
desiredPorts := openStackMachine.Status.ReferencedResources.Ports
502+
portsToCreate := networking.MissingPorts(openStackMachine.Status.DependentResources.Ports, desiredPorts)
503503

504504
// Sanity check that the number of desired ports is equal to the addition of ports to create and ports that already exist.
505-
if len(desiredPorts) != len(portsToCreate)+len(openStackMachine.Status.DependentResources.PortsStatus) {
506-
return fmt.Errorf("length of desired ports (%d) is not equal to the length of ports to create (%d) + the length of ports that already exist (%d)", len(desiredPorts), len(portsToCreate), len(openStackMachine.Status.DependentResources.PortsStatus))
505+
if len(desiredPorts) != len(portsToCreate)+len(openStackMachine.Status.DependentResources.Ports) {
506+
return fmt.Errorf("length of desired ports (%d) is not equal to the length of ports to create (%d) + the length of ports that already exist (%d)", len(desiredPorts), len(portsToCreate), len(openStackMachine.Status.DependentResources.Ports))
507507
}
508508

509509
if len(portsToCreate) > 0 {
@@ -513,12 +513,12 @@ func getOrCreateMachinePorts(scope *scope.WithLogger, openStackCluster *infrav1.
513513
if err != nil {
514514
return fmt.Errorf("create ports: %w", err)
515515
}
516-
openStackMachine.Status.DependentResources.PortsStatus = append(openStackMachine.Status.DependentResources.PortsStatus, machinePortsStatus...)
516+
openStackMachine.Status.DependentResources.Ports = append(openStackMachine.Status.DependentResources.Ports, machinePortsStatus...)
517517
}
518518

519519
// Sanity check that the number of ports that have been put into PortsStatus is equal to the number of desired ports now that we have created them all.
520-
if len(openStackMachine.Status.DependentResources.PortsStatus) != len(desiredPorts) {
521-
return fmt.Errorf("length of ports that already exist (%d) is not equal to the length of desired ports (%d)", len(openStackMachine.Status.DependentResources.PortsStatus), len(desiredPorts))
520+
if len(openStackMachine.Status.DependentResources.Ports) != len(desiredPorts) {
521+
return fmt.Errorf("length of ports that already exist (%d) is not equal to the length of desired ports (%d)", len(openStackMachine.Status.DependentResources.Ports), len(desiredPorts))
522522
}
523523

524524
return nil

docs/book/src/api/v1beta1/api.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ further information.</p>
13961396
<tbody>
13971397
<tr>
13981398
<td>
1399-
<code>portsStatus</code><br/>
1399+
<code>ports</code><br/>
14001400
<em>
14011401
<a href="#infrastructure.cluster.x-k8s.io/v1beta1.PortStatus">
14021402
[]PortStatus
@@ -1405,7 +1405,7 @@ further information.</p>
14051405
</td>
14061406
<td>
14071407
<em>(Optional)</em>
1408-
<p>PortsStatus is the status of the ports created for the machine.</p>
1408+
<p>Ports is the status of the ports created for the machine.</p>
14091409
</td>
14101410
</tr>
14111411
</tbody>
@@ -3895,7 +3895,7 @@ string
38953895
</tr>
38963896
<tr>
38973897
<td>
3898-
<code>portsOpts</code><br/>
3898+
<code>ports</code><br/>
38993899
<em>
39003900
<a href="#infrastructure.cluster.x-k8s.io/v1beta1.PortOpts">
39013901
[]PortOpts
@@ -3904,7 +3904,7 @@ string
39043904
</td>
39053905
<td>
39063906
<em>(Optional)</em>
3907-
<p>portsOpts is the list of ports options to create for the machine.</p>
3907+
<p>Ports is the fully resolved list of ports to create for the machine.</p>
39083908
</td>
39093909
</tr>
39103910
</tbody>

0 commit comments

Comments
 (0)