diff --git a/api/v1alpha5/conversion_test.go b/api/v1alpha5/conversion_test.go index 72b3c62851..b7dbbbac2b 100644 --- a/api/v1alpha5/conversion_test.go +++ b/api/v1alpha5/conversion_test.go @@ -87,7 +87,7 @@ func TestConvertFrom(t *testing.T) { Spec: OpenStackMachineSpec{}, ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - "cluster.x-k8s.io/conversion-data": "{\"spec\":{\"flavor\":\"\",\"image\":{}},\"status\":{\"dependentResources\":{},\"ready\":false,\"referencedResources\":{}}}", + "cluster.x-k8s.io/conversion-data": `{"spec":{"flavor":"","image":{}},"status":{"ready":false,"referencedResources":{},"resources":{}}}`, }, }, }, diff --git a/api/v1alpha5/zz_generated.conversion.go b/api/v1alpha5/zz_generated.conversion.go index 60a6ff055b..c7cac5b353 100644 --- a/api/v1alpha5/zz_generated.conversion.go +++ b/api/v1alpha5/zz_generated.conversion.go @@ -1213,7 +1213,7 @@ func autoConvert_v1beta1_OpenStackMachineStatus_To_v1alpha5_OpenStackMachineStat out.Addresses = *(*[]corev1.NodeAddress)(unsafe.Pointer(&in.Addresses)) out.InstanceState = (*InstanceState)(unsafe.Pointer(in.InstanceState)) // WARNING: in.ReferencedResources requires manual conversion: does not exist in peer-type - // WARNING: in.DependentResources requires manual conversion: does not exist in peer-type + // WARNING: in.Resources requires manual conversion: does not exist in peer-type out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) diff --git a/api/v1alpha6/openstackcluster_conversion.go b/api/v1alpha6/openstackcluster_conversion.go index 2991efe751..8d0a87efea 100644 --- a/api/v1alpha6/openstackcluster_conversion.go +++ b/api/v1alpha6/openstackcluster_conversion.go @@ -370,8 +370,8 @@ func restorev1beta1ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst * if previous.Bastion != nil { dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources } - if previous.Bastion != nil && previous.Bastion.DependentResources.Ports != nil { - dst.Bastion.DependentResources.Ports = previous.Bastion.DependentResources.Ports + if previous.Bastion != nil && previous.Bastion.Resources.Ports != nil { + dst.Bastion.Resources.Ports = previous.Bastion.Resources.Ports } } diff --git a/api/v1alpha6/openstackmachine_conversion.go b/api/v1alpha6/openstackmachine_conversion.go index f7b114ed12..7f92ec0b65 100644 --- a/api/v1alpha6/openstackmachine_conversion.go +++ b/api/v1alpha6/openstackmachine_conversion.go @@ -90,8 +90,8 @@ var v1beta1OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStackM restorev1beta1MachineSpec, ), "depresources": conversion.UnconditionalFieldRestorer( - func(c *infrav1.OpenStackMachine) *infrav1.DependentMachineResources { - return &c.Status.DependentResources + func(c *infrav1.OpenStackMachine) *infrav1.MachineResources { + return &c.Status.Resources }, ), // No equivalent in v1alpha6 diff --git a/api/v1alpha6/zz_generated.conversion.go b/api/v1alpha6/zz_generated.conversion.go index b38e4436e2..e9bdedeb0f 100644 --- a/api/v1alpha6/zz_generated.conversion.go +++ b/api/v1alpha6/zz_generated.conversion.go @@ -1248,7 +1248,7 @@ func autoConvert_v1beta1_OpenStackMachineStatus_To_v1alpha6_OpenStackMachineStat out.Addresses = *(*[]corev1.NodeAddress)(unsafe.Pointer(&in.Addresses)) out.InstanceState = (*InstanceState)(unsafe.Pointer(in.InstanceState)) // WARNING: in.ReferencedResources requires manual conversion: does not exist in peer-type - // WARNING: in.DependentResources requires manual conversion: does not exist in peer-type + // WARNING: in.Resources requires manual conversion: does not exist in peer-type out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) diff --git a/api/v1alpha7/openstackcluster_conversion.go b/api/v1alpha7/openstackcluster_conversion.go index 7384a9fa2c..641148b654 100644 --- a/api/v1alpha7/openstackcluster_conversion.go +++ b/api/v1alpha7/openstackcluster_conversion.go @@ -353,8 +353,8 @@ func restorev1beta1ClusterStatus(previous *infrav1.OpenStackClusterStatus, dst * dst.Bastion.ReferencedResources = previous.Bastion.ReferencedResources } - if previous.Bastion != nil && previous.Bastion.DependentResources.Ports != nil { - dst.Bastion.DependentResources.Ports = previous.Bastion.DependentResources.Ports + if previous.Bastion != nil && previous.Bastion.Resources.Ports != nil { + dst.Bastion.Resources.Ports = previous.Bastion.Resources.Ports } } diff --git a/api/v1alpha7/openstackmachine_conversion.go b/api/v1alpha7/openstackmachine_conversion.go index d18db4e676..9ee3b01c8c 100644 --- a/api/v1alpha7/openstackmachine_conversion.go +++ b/api/v1alpha7/openstackmachine_conversion.go @@ -77,8 +77,8 @@ var v1beta1OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStackM restorev1beta1MachineSpec, ), "depresources": conversion.UnconditionalFieldRestorer( - func(c *infrav1.OpenStackMachine) *infrav1.DependentMachineResources { - return &c.Status.DependentResources + func(c *infrav1.OpenStackMachine) *infrav1.MachineResources { + return &c.Status.Resources }, ), // No equivalent in v1alpha7 diff --git a/api/v1alpha7/zz_generated.conversion.go b/api/v1alpha7/zz_generated.conversion.go index 4d72d623f4..f7b10f6064 100644 --- a/api/v1alpha7/zz_generated.conversion.go +++ b/api/v1alpha7/zz_generated.conversion.go @@ -574,7 +574,7 @@ func autoConvert_v1beta1_BastionStatus_To_v1alpha7_BastionStatus(in *v1beta1.Bas out.IP = in.IP out.FloatingIP = in.FloatingIP // WARNING: in.ReferencedResources requires manual conversion: does not exist in peer-type - // WARNING: in.DependentResources requires manual conversion: does not exist in peer-type + // WARNING: in.Resources requires manual conversion: does not exist in peer-type return nil } @@ -1448,7 +1448,7 @@ func autoConvert_v1beta1_OpenStackMachineStatus_To_v1alpha7_OpenStackMachineStat out.Addresses = *(*[]corev1.NodeAddress)(unsafe.Pointer(&in.Addresses)) out.InstanceState = (*InstanceState)(unsafe.Pointer(in.InstanceState)) // WARNING: in.ReferencedResources requires manual conversion: does not exist in peer-type - // WARNING: in.DependentResources requires manual conversion: does not exist in peer-type + // WARNING: in.Resources requires manual conversion: does not exist in peer-type out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) diff --git a/api/v1beta1/openstackmachine_types.go b/api/v1beta1/openstackmachine_types.go index b4f3babef9..43d4f05574 100644 --- a/api/v1beta1/openstackmachine_types.go +++ b/api/v1beta1/openstackmachine_types.go @@ -129,8 +129,8 @@ type OpenStackMachineStatus struct { // ReferencedResources contains resolved references to resources that the machine depends on. ReferencedResources ReferencedMachineResources `json:"referencedResources,omitempty"` - // DependentResources contains resolved dependent resources that were created by the machine. - DependentResources DependentMachineResources `json:"dependentResources,omitempty"` + // Resources contains references to OpenStack resources created for the machine. + Resources MachineResources `json:"resources,omitempty"` FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"` diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index f5f8fcfa22..01316d955f 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -365,7 +365,7 @@ type BastionStatus struct { IP string `json:"ip,omitempty"` FloatingIP string `json:"floatingIP,omitempty"` ReferencedResources ReferencedMachineResources `json:"referencedResources,omitempty"` - DependentResources DependentMachineResources `json:"dependentResources,omitempty"` + Resources MachineResources `json:"resources,omitempty"` } type RootVolume struct { @@ -673,7 +673,7 @@ type ReferencedMachineResources struct { Ports []ResolvedPortSpec `json:"ports,omitempty"` } -type DependentMachineResources struct { +type MachineResources struct { // Ports is the status of the ports created for the machine. // +optional Ports []PortStatus `json:"ports,omitempty"` diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 98c11cbbf4..d9e22e65c4 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -147,7 +147,7 @@ func (in *Bastion) DeepCopy() *Bastion { func (in *BastionStatus) DeepCopyInto(out *BastionStatus) { *out = *in in.ReferencedResources.DeepCopyInto(&out.ReferencedResources) - in.DependentResources.DeepCopyInto(&out.DependentResources) + in.Resources.DeepCopyInto(&out.Resources) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BastionStatus. @@ -220,26 +220,6 @@ func (in *BlockDeviceVolume) DeepCopy() *BlockDeviceVolume { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DependentMachineResources) DeepCopyInto(out *DependentMachineResources) { - *out = *in - if in.Ports != nil { - in, out := &in.Ports, &out.Ports - *out = make([]PortStatus, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DependentMachineResources. -func (in *DependentMachineResources) DeepCopy() *DependentMachineResources { - if in == nil { - return nil - } - out := new(DependentMachineResources) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ExternalRouterIPParam) DeepCopyInto(out *ExternalRouterIPParam) { *out = *in @@ -371,6 +351,26 @@ func (in *LoadBalancer) DeepCopy() *LoadBalancer { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineResources) DeepCopyInto(out *MachineResources) { + *out = *in + if in.Ports != nil { + in, out := &in.Ports, &out.Ports + *out = make([]PortStatus, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineResources. +func (in *MachineResources) DeepCopy() *MachineResources { + if in == nil { + return nil + } + out := new(MachineResources) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ManagedSecurityGroups) DeepCopyInto(out *ManagedSecurityGroups) { *out = *in @@ -965,7 +965,7 @@ func (in *OpenStackMachineStatus) DeepCopyInto(out *OpenStackMachineStatus) { **out = **in } in.ReferencedResources.DeepCopyInto(&out.ReferencedResources) - in.DependentResources.DeepCopyInto(&out.DependentResources) + in.Resources.DeepCopyInto(&out.Resources) if in.FailureReason != nil { in, out := &in.FailureReason, &out.FailureReason *out = new(errors.MachineStatusError) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml index 3130c26513..fda2df3277 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml @@ -6242,21 +6242,6 @@ spec: description: Bastion contains the information about the deployed bastion host properties: - dependentResources: - properties: - ports: - description: Ports is the status of the ports created for - the machine. - items: - properties: - id: - description: ID is the unique identifier of the port. - type: string - required: - - id - type: object - type: array - type: object floatingIP: type: string id: @@ -6449,6 +6434,21 @@ spec: machine should be added to and is calculated based on ServerGroupFilter. type: string type: object + resources: + properties: + ports: + description: Ports is the status of the ports created for + the machine. + items: + properties: + id: + description: ID is the unique identifier of the port. + type: string + required: + - id + type: object + type: array + type: object sshKeyName: type: string state: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachines.yaml index 74bbae9e0b..8cea0408b3 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachines.yaml @@ -2421,23 +2421,6 @@ spec: - type type: object type: array - dependentResources: - description: DependentResources contains resolved dependent resources - that were created by the machine. - properties: - ports: - description: Ports is the status of the ports created for the - machine. - items: - properties: - id: - description: ID is the unique identifier of the port. - type: string - required: - - id - type: object - type: array - type: object failureMessage: description: |- FailureMessage will be set in the event that there is a terminal problem @@ -2652,6 +2635,23 @@ spec: should be added to and is calculated based on ServerGroupFilter. type: string type: object + resources: + description: Resources contains references to OpenStack resources + created for the machine. + properties: + ports: + description: Ports is the status of the ports created for the + machine. + items: + properties: + id: + description: ID is the unique identifier of the port. + type: string + required: + - id + type: object + type: array + type: object type: object type: object served: true diff --git a/controllers/openstackcluster_controller.go b/controllers/openstackcluster_controller.go index 2f742c5545..dbc2527042 100644 --- a/controllers/openstackcluster_controller.go +++ b/controllers/openstackcluster_controller.go @@ -219,7 +219,7 @@ func contains(arr []string, target string) bool { } func resolveBastionResources(scope *scope.WithLogger, clusterResourceName string, openStackCluster *infrav1.OpenStackCluster) (bool, error) { - // Resolve and store referenced & dependent resources for the bastion + // Resolve and store resources for the bastion if openStackCluster.Spec.Bastion != nil && openStackCluster.Spec.Bastion.Enabled { if openStackCluster.Status.Bastion == nil { openStackCluster.Status.Bastion = &infrav1.BastionStatus{} @@ -239,9 +239,9 @@ func resolveBastionResources(scope *scope.WithLogger, clusterResourceName string return true, nil } - err = compute.AdoptDependentMachineResources(scope, + err = compute.AdoptMachineResources(scope, &openStackCluster.Status.Bastion.ReferencedResources, - &openStackCluster.Status.Bastion.DependentResources) + &openStackCluster.Status.Bastion.Resources) if err != nil { return false, err } @@ -308,18 +308,18 @@ func deleteBastion(scope *scope.WithLogger, cluster *clusterv1.Cluster, openStac } } - if openStackCluster.Status.Bastion != nil && len(openStackCluster.Status.Bastion.DependentResources.Ports) > 0 { + if openStackCluster.Status.Bastion != nil && len(openStackCluster.Status.Bastion.Resources.Ports) > 0 { trunkSupported, err := networkingService.IsTrunkExtSupported() if err != nil { return err } - for _, port := range openStackCluster.Status.Bastion.DependentResources.Ports { + for _, port := range openStackCluster.Status.Bastion.Resources.Ports { if err := networkingService.DeleteInstanceTrunkAndPort(openStackCluster, port, trunkSupported); err != nil { handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to delete port: %w", err)) return fmt.Errorf("failed to delete port: %w", err) } } - openStackCluster.Status.Bastion.DependentResources.Ports = nil + openStackCluster.Status.Bastion.Resources.Ports = nil } scope.Logger().Info("Deleted Bastion") @@ -445,7 +445,7 @@ func reconcileBastion(scope *scope.WithLogger, cluster *clusterv1.Cluster, openS handleUpdateOSCError(openStackCluster, fmt.Errorf("failed to get or create ports for bastion: %w", err)) return nil, fmt.Errorf("failed to get or create ports for bastion: %w", err) } - bastionPortIDs := GetPortIDs(openStackCluster.Status.Bastion.DependentResources.Ports) + bastionPortIDs := GetPortIDs(openStackCluster.Status.Bastion.Resources.Ports) var instanceStatus *compute.InstanceStatus if openStackCluster.Status.Bastion != nil && openStackCluster.Status.Bastion.ID != "" { @@ -579,13 +579,13 @@ func getBastionSecurityGroupID(openStackCluster *infrav1.OpenStackCluster) *stri func getOrCreateBastionPorts(openStackCluster *infrav1.OpenStackCluster, networkingService *networking.Service) error { desiredPorts := openStackCluster.Status.Bastion.ReferencedResources.Ports - dependentResources := &openStackCluster.Status.Bastion.DependentResources + resources := &openStackCluster.Status.Bastion.Resources - if len(desiredPorts) == len(dependentResources.Ports) { + if len(desiredPorts) == len(resources.Ports) { return nil } - err := networkingService.CreatePorts(openStackCluster, desiredPorts, dependentResources) + err := networkingService.CreatePorts(openStackCluster, desiredPorts, resources) if err != nil { return fmt.Errorf("failed to create ports for bastion %s: %w", bastionName(openStackCluster.Name), err) } diff --git a/controllers/openstackcluster_controller_test.go b/controllers/openstackcluster_controller_test.go index 198f55a818..a7aa20892a 100644 --- a/controllers/openstackcluster_controller_test.go +++ b/controllers/openstackcluster_controller_test.go @@ -245,7 +245,7 @@ var _ = Describe("OpenStackCluster controller", func() { }, }, }, - DependentResources: infrav1.DependentMachineResources{ + Resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: "portID1", @@ -294,7 +294,7 @@ var _ = Describe("OpenStackCluster controller", func() { }, }, }, - DependentResources: infrav1.DependentMachineResources{ + Resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: "portID1", @@ -335,7 +335,7 @@ var _ = Describe("OpenStackCluster controller", func() { }, }, }, - DependentResources: infrav1.DependentMachineResources{ + Resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: "portID1", @@ -377,7 +377,7 @@ var _ = Describe("OpenStackCluster controller", func() { }, }, }, - DependentResources: infrav1.DependentMachineResources{ + Resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: "portID1", @@ -417,7 +417,7 @@ var _ = Describe("OpenStackCluster controller", func() { }, }, }, - DependentResources: infrav1.DependentMachineResources{ + Resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: "portID1", @@ -453,7 +453,7 @@ var _ = Describe("OpenStackCluster controller", func() { }, }, }, - DependentResources: infrav1.DependentMachineResources{ + Resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: "portID1", @@ -528,7 +528,7 @@ var _ = Describe("OpenStackCluster controller", func() { } testCluster.Status = infrav1.OpenStackClusterStatus{ Bastion: &infrav1.BastionStatus{ - DependentResources: infrav1.DependentMachineResources{ + Resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: "port-id", @@ -613,7 +613,7 @@ var _ = Describe("OpenStackCluster controller", func() { } testCluster.Status = infrav1.OpenStackClusterStatus{ Bastion: &infrav1.BastionStatus{ - DependentResources: infrav1.DependentMachineResources{ + Resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: "port-id", diff --git a/controllers/openstackmachine_controller.go b/controllers/openstackmachine_controller.go index 230768a73a..a537d389f0 100644 --- a/controllers/openstackmachine_controller.go +++ b/controllers/openstackmachine_controller.go @@ -175,8 +175,8 @@ func resolveMachineResources(scope *scope.WithLogger, clusterResourceName string return true, nil } - // Adopt any existing dependent resources - return false, compute.AdoptDependentMachineResources(scope, &openStackMachine.Status.ReferencedResources, &openStackMachine.Status.DependentResources) + // Adopt any existing resources + return false, compute.AdoptMachineResources(scope, &openStackMachine.Status.ReferencedResources, &openStackMachine.Status.Resources) } func patchMachine(ctx context.Context, patchHelper *patch.Helper, openStackMachine *infrav1.OpenStackMachine, machine *clusterv1.Machine, options ...patch.Option) error { @@ -308,7 +308,7 @@ func (r *OpenStackMachineReconciler) reconcileDelete(scope *scope.WithLogger, cl return ctrl.Result{}, err } - portsStatus := openStackMachine.Status.DependentResources.Ports + portsStatus := openStackMachine.Status.Resources.Ports for _, port := range portsStatus { if err := networkingService.DeleteInstanceTrunkAndPort(openStackMachine, port, trunkSupported); err != nil { return ctrl.Result{}, fmt.Errorf("failed to delete port %q: %w", port.ID, err) @@ -519,7 +519,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope if err != nil { return ctrl.Result{}, err } - portIDs := GetPortIDs(openStackMachine.Status.DependentResources.Ports) + portIDs := GetPortIDs(openStackMachine.Status.Resources.Ports) instanceStatus, err := r.getOrCreateInstance(scope.Logger(), openStackCluster, machine, openStackMachine, computeService, userData, portIDs) if err != nil || instanceStatus == nil { @@ -659,13 +659,13 @@ func (r *OpenStackMachineReconciler) reconcileAPIServerLoadBalancer(scope *scope func getOrCreateMachinePorts(openStackMachine *infrav1.OpenStackMachine, networkingService *networking.Service) error { desiredPorts := openStackMachine.Status.ReferencedResources.Ports - dependentResources := &openStackMachine.Status.DependentResources + resources := &openStackMachine.Status.Resources - if len(desiredPorts) == len(dependentResources.Ports) { + if len(desiredPorts) == len(resources.Ports) { return nil } - if err := networkingService.CreatePorts(openStackMachine, desiredPorts, dependentResources); err != nil { + if err := networkingService.CreatePorts(openStackMachine, desiredPorts, resources); err != nil { return fmt.Errorf("creating ports: %w", err) } diff --git a/docs/book/src/api/v1beta1/api.md b/docs/book/src/api/v1beta1/api.md index e4d1ac338a..8909adc3c7 100644 --- a/docs/book/src/api/v1beta1/api.md +++ b/docs/book/src/api/v1beta1/api.md @@ -1224,10 +1224,10 @@ ReferencedMachineResources
dependentResources
resources
-(Appears on: -BastionStatus, -OpenStackMachineStatus) -
--
-Field | -Description | -
---|---|
-ports - - -[]PortStatus - - - |
-
-(Optional)
- Ports is the status of the ports created for the machine. - |
-
@@ -1750,6 +1717,39 @@ string +
+(Appears on: +BastionStatus, +OpenStackMachineStatus) +
++
+Field | +Description | +
---|---|
+ports + + +[]PortStatus + + + |
+
+(Optional)
+ Ports is the status of the ports created for the machine. + |
+
string
alias)@@ -3299,15 +3299,15 @@ ReferencedMachineResources
dependentResources
resources
DependentResources contains resolved dependent resources that were created by the machine.
+Resources contains references to OpenStack resources created for the machine.
(Appears on: -DependentMachineResources) +MachineResources)
diff --git a/pkg/cloud/services/compute/dependent_resources.go b/pkg/cloud/services/compute/machine_resources.go similarity index 82% rename from pkg/cloud/services/compute/dependent_resources.go rename to pkg/cloud/services/compute/machine_resources.go index 0d45f07fb4..7061fed468 100644 --- a/pkg/cloud/services/compute/dependent_resources.go +++ b/pkg/cloud/services/compute/machine_resources.go @@ -22,11 +22,11 @@ import ( "sigs.k8s.io/cluster-api-provider-openstack/pkg/scope" ) -func AdoptDependentMachineResources(scope *scope.WithLogger, referencedResources *infrav1.ReferencedMachineResources, dependentResources *infrav1.DependentMachineResources) error { +func AdoptMachineResources(scope *scope.WithLogger, referencedResources *infrav1.ReferencedMachineResources, resources *infrav1.MachineResources) error { networkingService, err := networking.NewService(scope) if err != nil { return err } - return networkingService.AdoptPorts(scope, referencedResources.Ports, dependentResources) + return networkingService.AdoptPorts(scope, referencedResources.Ports, resources) } diff --git a/pkg/cloud/services/networking/port.go b/pkg/cloud/services/networking/port.go index df5975981f..f1fbfef6ce 100644 --- a/pkg/cloud/services/networking/port.go +++ b/pkg/cloud/services/networking/port.go @@ -311,10 +311,10 @@ func getPortName(baseName string, portSpec *infrav1.PortOpts, netIndex int) stri return fmt.Sprintf("%s-%d", baseName, netIndex) } -func (s *Service) CreatePorts(eventObject runtime.Object, desiredPorts []infrav1.ResolvedPortSpec, dependentResources *infrav1.DependentMachineResources) error { +func (s *Service) CreatePorts(eventObject runtime.Object, desiredPorts []infrav1.ResolvedPortSpec, resources *infrav1.MachineResources) error { for i := range desiredPorts { // Skip creation of ports which already exist - if i < len(dependentResources.Ports) { + if i < len(resources.Ports) { continue } @@ -325,7 +325,7 @@ func (s *Service) CreatePorts(eventObject runtime.Object, desiredPorts []infrav1 return err } - dependentResources.Ports = append(dependentResources.Ports, infrav1.PortStatus{ + resources.Ports = append(resources.Ports, infrav1.PortStatus{ ID: port.ID, }) } @@ -558,11 +558,11 @@ func (s *Service) IsTrunkExtSupported() (trunknSupported bool, err error) { return true, nil } -// AdoptPorts looks for ports in desiredPorts which were previously created, and adds them to dependentResources.Ports. +// AdoptPorts looks for ports in desiredPorts which were previously created, and adds them to resources.Ports. // A port matches if it has the same name and network ID as the desired port. -func (s *Service) AdoptPorts(scope *scope.WithLogger, desiredPorts []infrav1.ResolvedPortSpec, dependentResources *infrav1.DependentMachineResources) error { +func (s *Service) AdoptPorts(scope *scope.WithLogger, desiredPorts []infrav1.ResolvedPortSpec, resources *infrav1.MachineResources) error { // We can skip adoption if the ports are already in the status - if len(desiredPorts) == len(dependentResources.Ports) { + if len(desiredPorts) == len(resources.Ports) { return nil } @@ -573,7 +573,7 @@ func (s *Service) AdoptPorts(scope *scope.WithLogger, desiredPorts []infrav1.Res // We can therefore stop searching for ports once we find one that doesn't exist. for i := range desiredPorts { // check if the port is in status first and if it is, skip it - if i < len(dependentResources.Ports) { + if i < len(resources.Ports) { scope.Logger().V(5).Info("Port already in status, skipping it", "port index", i) continue } @@ -599,7 +599,7 @@ func (s *Service) AdoptPorts(scope *scope.WithLogger, desiredPorts []infrav1.Res // The desired port was found, so we add it to the status portID := ports[0].ID scope.Logger().Info("Adopted previously created port which was not in status", "port index", i, "portID", portID) - dependentResources.Ports = append(dependentResources.Ports, infrav1.PortStatus{ID: portID}) + resources.Ports = append(resources.Ports, infrav1.PortStatus{ID: portID}) } return nil diff --git a/pkg/cloud/services/networking/port_test.go b/pkg/cloud/services/networking/port_test.go index d0ae57ab6d..466ee35a89 100644 --- a/pkg/cloud/services/networking/port_test.go +++ b/pkg/cloud/services/networking/port_test.go @@ -886,12 +886,12 @@ func Test_AdoptPorts(t *testing.T) { ) tests := []struct { - testName string - desiredPorts []infrav1.ResolvedPortSpec - dependentResources infrav1.DependentMachineResources - expect func(*mock.MockNetworkClientMockRecorder) - want infrav1.DependentMachineResources - wantErr bool + testName string + desiredPorts []infrav1.ResolvedPortSpec + resources infrav1.MachineResources + expect func(*mock.MockNetworkClientMockRecorder) + want infrav1.MachineResources + wantErr bool }{ { testName: "No desired ports", @@ -901,14 +901,14 @@ func Test_AdoptPorts(t *testing.T) { desiredPorts: []infrav1.ResolvedPortSpec{ {NetworkID: networkID1}, }, - dependentResources: infrav1.DependentMachineResources{ + resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: portID1, }, }, }, - want: infrav1.DependentMachineResources{ + want: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: portID1, @@ -925,7 +925,7 @@ func Test_AdoptPorts(t *testing.T) { m.ListPort(ports.ListOpts{Name: "test-machine-0", NetworkID: networkID1}). Return([]ports.Port{{ID: portID1}}, nil) }, - want: infrav1.DependentMachineResources{ + want: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: portID1, @@ -942,7 +942,7 @@ func Test_AdoptPorts(t *testing.T) { m.ListPort(ports.ListOpts{Name: "test-machine-0", NetworkID: networkID1}). Return(nil, nil) }, - want: infrav1.DependentMachineResources{}, + want: infrav1.MachineResources{}, }, { testName: "2 desired ports, first in status, second exists: adopt second", @@ -950,7 +950,7 @@ func Test_AdoptPorts(t *testing.T) { {Name: "test-machine-0", NetworkID: networkID1}, {Name: "test-machine-1", NetworkID: networkID2}, }, - dependentResources: infrav1.DependentMachineResources{ + resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: portID1, @@ -961,7 +961,7 @@ func Test_AdoptPorts(t *testing.T) { m.ListPort(ports.ListOpts{Name: "test-machine-1", NetworkID: networkID2}). Return([]ports.Port{{ID: portID2}}, nil) }, - want: infrav1.DependentMachineResources{ + want: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ {ID: portID1}, {ID: portID2}, @@ -975,7 +975,7 @@ func Test_AdoptPorts(t *testing.T) { {Name: "test-machine-1", NetworkID: networkID2}, {Name: "test-machine-2", NetworkID: networkID3}, }, - dependentResources: infrav1.DependentMachineResources{ + resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: portID1, @@ -986,7 +986,7 @@ func Test_AdoptPorts(t *testing.T) { m.ListPort(ports.ListOpts{Name: "test-machine-1", NetworkID: networkID2}). Return(nil, nil) }, - want: infrav1.DependentMachineResources{ + want: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ {ID: portID1}, }, @@ -999,7 +999,7 @@ func Test_AdoptPorts(t *testing.T) { {Name: "test-machine-bar", NetworkID: networkID2}, {Name: "test-machine-baz", NetworkID: networkID3}, }, - dependentResources: infrav1.DependentMachineResources{ + resources: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ { ID: portID1, @@ -1010,7 +1010,7 @@ func Test_AdoptPorts(t *testing.T) { m.ListPort(ports.ListOpts{Name: "test-machine-bar", NetworkID: networkID2}). Return(nil, nil) }, - want: infrav1.DependentMachineResources{ + want: infrav1.MachineResources{ Ports: []infrav1.PortStatus{ {ID: portID1}, }, @@ -1035,13 +1035,13 @@ func Test_AdoptPorts(t *testing.T) { } err := s.AdoptPorts(scope.NewWithLogger(mockScopeFactory, log), - tt.desiredPorts, &tt.dependentResources) + tt.desiredPorts, &tt.resources) if tt.wantErr { g.Expect(err).Error() return } - g.Expect(tt.dependentResources).To(Equal(tt.want), cmp.Diff(&tt.dependentResources, tt.want)) + g.Expect(tt.resources).To(Equal(tt.want), cmp.Diff(&tt.resources, tt.want)) }) } }