From 4b633336bff00b5429892ff2a5eae58de6bed185 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Wed, 17 May 2023 16:23:06 +0100 Subject: [PATCH 1/2] Replace SubnetParam with SubnetFilter --- api/v1alpha5/conversion.go | 15 ++++ api/v1alpha5/zz_generated.conversion.go | 74 +++++++++---------- api/v1alpha6/conversion.go | 33 +++++++++ api/v1alpha6/zz_generated.conversion.go | 74 +++++++++---------- api/v1alpha7/types.go | 12 +-- api/v1alpha7/zz_generated.deepcopy.go | 16 ---- ...re.cluster.x-k8s.io_openstackclusters.yaml | 60 +++++++-------- ...er.x-k8s.io_openstackclustertemplates.yaml | 60 +++++++-------- pkg/cloud/services/networking/router.go | 4 +- 9 files changed, 169 insertions(+), 179 deletions(-) diff --git a/api/v1alpha5/conversion.go b/api/v1alpha5/conversion.go index 2761c422fe..0c9c4504ed 100644 --- a/api/v1alpha5/conversion.go +++ b/api/v1alpha5/conversion.go @@ -296,3 +296,18 @@ func Convert_v1alpha7_SecurityGroupFilter_To_v1alpha5_SecurityGroupParam(in *inf } return nil } + +func Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetFilter(in *SubnetParam, out *infrav1.SubnetFilter, _ conversion.Scope) error { + *out = infrav1.SubnetFilter(in.Filter) + if in.UUID != "" { + out.ID = in.UUID + } + return nil +} + +func Convert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetParam(in *infrav1.SubnetFilter, out *SubnetParam, _ conversion.Scope) error { + out.Filter = SubnetFilter(*in) + out.UUID = in.ID + + return nil +} diff --git a/api/v1alpha5/zz_generated.conversion.go b/api/v1alpha5/zz_generated.conversion.go index 8020227bd8..73b1707982 100644 --- a/api/v1alpha5/zz_generated.conversion.go +++ b/api/v1alpha5/zz_generated.conversion.go @@ -334,16 +334,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*SubnetParam)(nil), (*v1alpha7.SubnetParam)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetParam(a.(*SubnetParam), b.(*v1alpha7.SubnetParam), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1alpha7.SubnetParam)(nil), (*SubnetParam)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha7_SubnetParam_To_v1alpha5_SubnetParam(a.(*v1alpha7.SubnetParam), b.(*SubnetParam), scope) - }); err != nil { - return err - } if err := s.AddConversionFunc((*[]Network)(nil), (*[]v1alpha7.Network)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_Slice_v1alpha5_Network_To_Slice_v1alpha7_Network(a.(*[]Network), b.(*[]v1alpha7.Network), scope) }); err != nil { @@ -384,6 +374,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*SubnetParam)(nil), (*v1alpha7.SubnetFilter)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetFilter(a.(*SubnetParam), b.(*v1alpha7.SubnetFilter), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1alpha7.APIServerLoadBalancer)(nil), (*APIServerLoadBalancer)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha7_APIServerLoadBalancer_To_v1alpha5_APIServerLoadBalancer(a.(*v1alpha7.APIServerLoadBalancer), b.(*APIServerLoadBalancer), scope) }); err != nil { @@ -419,6 +414,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1alpha7.SubnetFilter)(nil), (*SubnetParam)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetParam(a.(*v1alpha7.SubnetFilter), b.(*SubnetParam), scope) + }); err != nil { + return err + } return nil } @@ -494,7 +494,7 @@ func Convert_v1alpha7_Bastion_To_v1alpha5_Bastion(in *v1alpha7.Bastion, out *Bas func autoConvert_v1alpha5_ExternalRouterIPParam_To_v1alpha7_ExternalRouterIPParam(in *ExternalRouterIPParam, out *v1alpha7.ExternalRouterIPParam, s conversion.Scope) error { out.FixedIP = in.FixedIP - if err := Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetParam(&in.Subnet, &out.Subnet, s); err != nil { + if err := Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetFilter(&in.Subnet, &out.Subnet, s); err != nil { return err } return nil @@ -507,7 +507,7 @@ func Convert_v1alpha5_ExternalRouterIPParam_To_v1alpha7_ExternalRouterIPParam(in func autoConvert_v1alpha7_ExternalRouterIPParam_To_v1alpha5_ExternalRouterIPParam(in *v1alpha7.ExternalRouterIPParam, out *ExternalRouterIPParam, s conversion.Scope) error { out.FixedIP = in.FixedIP - if err := Convert_v1alpha7_SubnetParam_To_v1alpha5_SubnetParam(&in.Subnet, &out.Subnet, s); err != nil { + if err := Convert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetParam(&in.Subnet, &out.Subnet, s); err != nil { return err } return nil @@ -724,7 +724,17 @@ func autoConvert_v1alpha5_OpenStackClusterSpec_To_v1alpha7_OpenStackClusterSpec( return err } out.DNSNameservers = *(*[]string)(unsafe.Pointer(&in.DNSNameservers)) - out.ExternalRouterIPs = *(*[]v1alpha7.ExternalRouterIPParam)(unsafe.Pointer(&in.ExternalRouterIPs)) + if in.ExternalRouterIPs != nil { + in, out := &in.ExternalRouterIPs, &out.ExternalRouterIPs + *out = make([]v1alpha7.ExternalRouterIPParam, len(*in)) + for i := range *in { + if err := Convert_v1alpha5_ExternalRouterIPParam_To_v1alpha7_ExternalRouterIPParam(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.ExternalRouterIPs = nil + } out.ExternalNetworkID = in.ExternalNetworkID if err := Convert_v1alpha5_APIServerLoadBalancer_To_v1alpha7_APIServerLoadBalancer(&in.APIServerLoadBalancer, &out.APIServerLoadBalancer, s); err != nil { return err @@ -768,7 +778,17 @@ func autoConvert_v1alpha7_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec( return err } out.DNSNameservers = *(*[]string)(unsafe.Pointer(&in.DNSNameservers)) - out.ExternalRouterIPs = *(*[]ExternalRouterIPParam)(unsafe.Pointer(&in.ExternalRouterIPs)) + if in.ExternalRouterIPs != nil { + in, out := &in.ExternalRouterIPs, &out.ExternalRouterIPs + *out = make([]ExternalRouterIPParam, len(*in)) + for i := range *in { + if err := Convert_v1alpha7_ExternalRouterIPParam_To_v1alpha5_ExternalRouterIPParam(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.ExternalRouterIPs = nil + } out.ExternalNetworkID = in.ExternalNetworkID if err := Convert_v1alpha7_APIServerLoadBalancer_To_v1alpha5_APIServerLoadBalancer(&in.APIServerLoadBalancer, &out.APIServerLoadBalancer, s); err != nil { return err @@ -1618,29 +1638,3 @@ func autoConvert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetFilter(in *v1alpha7.Sub func Convert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetFilter(in *v1alpha7.SubnetFilter, out *SubnetFilter, s conversion.Scope) error { return autoConvert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetFilter(in, out, s) } - -func autoConvert_v1alpha5_SubnetParam_To_v1alpha7_SubnetParam(in *SubnetParam, out *v1alpha7.SubnetParam, s conversion.Scope) error { - out.UUID = in.UUID - if err := Convert_v1alpha5_SubnetFilter_To_v1alpha7_SubnetFilter(&in.Filter, &out.Filter, s); err != nil { - return err - } - return nil -} - -// Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetParam is an autogenerated conversion function. -func Convert_v1alpha5_SubnetParam_To_v1alpha7_SubnetParam(in *SubnetParam, out *v1alpha7.SubnetParam, s conversion.Scope) error { - return autoConvert_v1alpha5_SubnetParam_To_v1alpha7_SubnetParam(in, out, s) -} - -func autoConvert_v1alpha7_SubnetParam_To_v1alpha5_SubnetParam(in *v1alpha7.SubnetParam, out *SubnetParam, s conversion.Scope) error { - out.UUID = in.UUID - if err := Convert_v1alpha7_SubnetFilter_To_v1alpha5_SubnetFilter(&in.Filter, &out.Filter, s); err != nil { - return err - } - return nil -} - -// Convert_v1alpha7_SubnetParam_To_v1alpha5_SubnetParam is an autogenerated conversion function. -func Convert_v1alpha7_SubnetParam_To_v1alpha5_SubnetParam(in *v1alpha7.SubnetParam, out *SubnetParam, s conversion.Scope) error { - return autoConvert_v1alpha7_SubnetParam_To_v1alpha5_SubnetParam(in, out, s) -} diff --git a/api/v1alpha6/conversion.go b/api/v1alpha6/conversion.go index 927c3a1a24..489b099801 100644 --- a/api/v1alpha6/conversion.go +++ b/api/v1alpha6/conversion.go @@ -126,6 +126,22 @@ func restorev1alpha7ClusterSpec(previous *infrav1.OpenStackClusterSpec, dst *inf } } +func restorev1alpha6ClusterSpec(previous *OpenStackClusterSpec, dst *OpenStackClusterSpec) { + for i := range previous.ExternalRouterIPs { + dstIP := &dst.ExternalRouterIPs[i] + previousIP := &previous.ExternalRouterIPs[i] + + // Subnet.Filter.ID was overwritten in up-conversion by Subnet.UUID + dstIP.Subnet.Filter.ID = previousIP.Subnet.Filter.ID + + // If Subnet.UUID was previously unset, we overwrote it with the value of Subnet.Filter.ID + // Don't unset it again if it doesn't have the previous value of Subnet.Filter.ID, because that means it was genuinely changed + if previousIP.Subnet.UUID == "" && dstIP.Subnet.UUID == previousIP.Subnet.Filter.ID { + dstIP.Subnet.UUID = "" + } + } +} + var _ ctrlconversion.Convertible = &OpenStackCluster{} func (r *OpenStackCluster) ConvertTo(dstRaw ctrlconversion.Hub) error { @@ -156,6 +172,7 @@ func (r *OpenStackCluster) ConvertFrom(srcRaw ctrlconversion.Hub) error { if prevBastion != nil { restorev1alpha6MachineSpec(&prevBastion.Instance, &r.Spec.Bastion.Instance) } + restorev1alpha6ClusterSpec(&previous.Spec, &r.Spec) restorev1alpha6ClusterStatus(&previous.Status, &r.Status) } @@ -206,6 +223,7 @@ func (r *OpenStackClusterTemplate) ConvertFrom(srcRaw ctrlconversion.Hub) error if prevBastion != nil { restorev1alpha6MachineSpec(&prevBastion.Instance, &r.Spec.Template.Spec.Bastion.Instance) } + restorev1alpha6ClusterSpec(&previous.Spec.Template.Spec, &r.Spec.Template.Spec) } return nil @@ -477,3 +495,18 @@ func Convert_v1alpha7_SecurityGroupFilter_To_v1alpha6_SecurityGroupParam(in *inf } return nil } + +func Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetFilter(in *SubnetParam, out *infrav1.SubnetFilter, _ conversion.Scope) error { + *out = infrav1.SubnetFilter(in.Filter) + if in.UUID != "" { + out.ID = in.UUID + } + return nil +} + +func Convert_v1alpha7_SubnetFilter_To_v1alpha6_SubnetParam(in *infrav1.SubnetFilter, out *SubnetParam, _ conversion.Scope) error { + out.Filter = SubnetFilter(*in) + out.UUID = in.ID + + return nil +} diff --git a/api/v1alpha6/zz_generated.conversion.go b/api/v1alpha6/zz_generated.conversion.go index 1334e2a38a..39fc3b11d4 100644 --- a/api/v1alpha6/zz_generated.conversion.go +++ b/api/v1alpha6/zz_generated.conversion.go @@ -344,16 +344,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*SubnetParam)(nil), (*v1alpha7.SubnetParam)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetParam(a.(*SubnetParam), b.(*v1alpha7.SubnetParam), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1alpha7.SubnetParam)(nil), (*SubnetParam)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha7_SubnetParam_To_v1alpha6_SubnetParam(a.(*v1alpha7.SubnetParam), b.(*SubnetParam), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*ValueSpec)(nil), (*v1alpha7.ValueSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha6_ValueSpec_To_v1alpha7_ValueSpec(a.(*ValueSpec), b.(*v1alpha7.ValueSpec), scope) }); err != nil { @@ -404,6 +394,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*SubnetParam)(nil), (*v1alpha7.SubnetFilter)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetFilter(a.(*SubnetParam), b.(*v1alpha7.SubnetFilter), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1alpha7.BastionStatus)(nil), (*Instance)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha7_BastionStatus_To_v1alpha6_Instance(a.(*v1alpha7.BastionStatus), b.(*Instance), scope) }); err != nil { @@ -429,6 +424,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1alpha7.SubnetFilter)(nil), (*SubnetParam)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha7_SubnetFilter_To_v1alpha6_SubnetParam(a.(*v1alpha7.SubnetFilter), b.(*SubnetParam), scope) + }); err != nil { + return err + } return nil } @@ -510,7 +510,7 @@ func Convert_v1alpha7_Bastion_To_v1alpha6_Bastion(in *v1alpha7.Bastion, out *Bas func autoConvert_v1alpha6_ExternalRouterIPParam_To_v1alpha7_ExternalRouterIPParam(in *ExternalRouterIPParam, out *v1alpha7.ExternalRouterIPParam, s conversion.Scope) error { out.FixedIP = in.FixedIP - if err := Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetParam(&in.Subnet, &out.Subnet, s); err != nil { + if err := Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetFilter(&in.Subnet, &out.Subnet, s); err != nil { return err } return nil @@ -523,7 +523,7 @@ func Convert_v1alpha6_ExternalRouterIPParam_To_v1alpha7_ExternalRouterIPParam(in func autoConvert_v1alpha7_ExternalRouterIPParam_To_v1alpha6_ExternalRouterIPParam(in *v1alpha7.ExternalRouterIPParam, out *ExternalRouterIPParam, s conversion.Scope) error { out.FixedIP = in.FixedIP - if err := Convert_v1alpha7_SubnetParam_To_v1alpha6_SubnetParam(&in.Subnet, &out.Subnet, s); err != nil { + if err := Convert_v1alpha7_SubnetFilter_To_v1alpha6_SubnetParam(&in.Subnet, &out.Subnet, s); err != nil { return err } return nil @@ -730,7 +730,17 @@ func autoConvert_v1alpha6_OpenStackClusterSpec_To_v1alpha7_OpenStackClusterSpec( return err } out.DNSNameservers = *(*[]string)(unsafe.Pointer(&in.DNSNameservers)) - out.ExternalRouterIPs = *(*[]v1alpha7.ExternalRouterIPParam)(unsafe.Pointer(&in.ExternalRouterIPs)) + if in.ExternalRouterIPs != nil { + in, out := &in.ExternalRouterIPs, &out.ExternalRouterIPs + *out = make([]v1alpha7.ExternalRouterIPParam, len(*in)) + for i := range *in { + if err := Convert_v1alpha6_ExternalRouterIPParam_To_v1alpha7_ExternalRouterIPParam(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.ExternalRouterIPs = nil + } out.ExternalNetworkID = in.ExternalNetworkID if err := Convert_v1alpha6_APIServerLoadBalancer_To_v1alpha7_APIServerLoadBalancer(&in.APIServerLoadBalancer, &out.APIServerLoadBalancer, s); err != nil { return err @@ -775,7 +785,17 @@ func autoConvert_v1alpha7_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec( return err } out.DNSNameservers = *(*[]string)(unsafe.Pointer(&in.DNSNameservers)) - out.ExternalRouterIPs = *(*[]ExternalRouterIPParam)(unsafe.Pointer(&in.ExternalRouterIPs)) + if in.ExternalRouterIPs != nil { + in, out := &in.ExternalRouterIPs, &out.ExternalRouterIPs + *out = make([]ExternalRouterIPParam, len(*in)) + for i := range *in { + if err := Convert_v1alpha7_ExternalRouterIPParam_To_v1alpha6_ExternalRouterIPParam(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.ExternalRouterIPs = nil + } out.ExternalNetworkID = in.ExternalNetworkID if err := Convert_v1alpha7_APIServerLoadBalancer_To_v1alpha6_APIServerLoadBalancer(&in.APIServerLoadBalancer, &out.APIServerLoadBalancer, s); err != nil { return err @@ -1627,32 +1647,6 @@ func Convert_v1alpha7_SubnetFilter_To_v1alpha6_SubnetFilter(in *v1alpha7.SubnetF return autoConvert_v1alpha7_SubnetFilter_To_v1alpha6_SubnetFilter(in, out, s) } -func autoConvert_v1alpha6_SubnetParam_To_v1alpha7_SubnetParam(in *SubnetParam, out *v1alpha7.SubnetParam, s conversion.Scope) error { - out.UUID = in.UUID - if err := Convert_v1alpha6_SubnetFilter_To_v1alpha7_SubnetFilter(&in.Filter, &out.Filter, s); err != nil { - return err - } - return nil -} - -// Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetParam is an autogenerated conversion function. -func Convert_v1alpha6_SubnetParam_To_v1alpha7_SubnetParam(in *SubnetParam, out *v1alpha7.SubnetParam, s conversion.Scope) error { - return autoConvert_v1alpha6_SubnetParam_To_v1alpha7_SubnetParam(in, out, s) -} - -func autoConvert_v1alpha7_SubnetParam_To_v1alpha6_SubnetParam(in *v1alpha7.SubnetParam, out *SubnetParam, s conversion.Scope) error { - out.UUID = in.UUID - if err := Convert_v1alpha7_SubnetFilter_To_v1alpha6_SubnetFilter(&in.Filter, &out.Filter, s); err != nil { - return err - } - return nil -} - -// Convert_v1alpha7_SubnetParam_To_v1alpha6_SubnetParam is an autogenerated conversion function. -func Convert_v1alpha7_SubnetParam_To_v1alpha6_SubnetParam(in *v1alpha7.SubnetParam, out *SubnetParam, s conversion.Scope) error { - return autoConvert_v1alpha7_SubnetParam_To_v1alpha6_SubnetParam(in, out, s) -} - func autoConvert_v1alpha6_ValueSpec_To_v1alpha7_ValueSpec(in *ValueSpec, out *v1alpha7.ValueSpec, s conversion.Scope) error { out.Name = in.Name out.Key = in.Key diff --git a/api/v1alpha7/types.go b/api/v1alpha7/types.go index cc388d74f2..9c12e5219f 100644 --- a/api/v1alpha7/types.go +++ b/api/v1alpha7/types.go @@ -26,7 +26,7 @@ type ExternalRouterIPParam struct { // The FixedIP in the corresponding subnet FixedIP string `json:"fixedIP,omitempty"` // The subnet in which the FixedIP is used for the Gateway of this router - Subnet SubnetParam `json:"subnet"` + Subnet SubnetFilter `json:"subnet"` } type SecurityGroupFilter struct { @@ -56,16 +56,6 @@ type NetworkFilter struct { NotTagsAny string `json:"notTagsAny,omitempty"` } -type SubnetParam struct { - // Optional UUID of the subnet. - // If specified this will not be validated prior to server creation. - // If specified, the enclosing `NetworkParam` must also be specified by UUID. - UUID string `json:"uuid,omitempty"` - - // Filters for optional subnet query - Filter SubnetFilter `json:"filter,omitempty"` -} - type SubnetFilter struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` diff --git a/api/v1alpha7/zz_generated.deepcopy.go b/api/v1alpha7/zz_generated.deepcopy.go index 4db7aa31be..a6a74fcc1f 100644 --- a/api/v1alpha7/zz_generated.deepcopy.go +++ b/api/v1alpha7/zz_generated.deepcopy.go @@ -979,22 +979,6 @@ func (in *SubnetFilter) DeepCopy() *SubnetFilter { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SubnetParam) DeepCopyInto(out *SubnetParam) { - *out = *in - out.Filter = in.Filter -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubnetParam. -func (in *SubnetParam) DeepCopy() *SubnetParam { - if in == nil { - return nil - } - out := new(SubnetParam) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ValueSpec) DeepCopyInto(out *ValueSpec) { *out = *in 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 337852f58c..ee2fac6d3c 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml @@ -4169,41 +4169,31 @@ spec: description: The subnet in which the FixedIP is used for the Gateway of this router properties: - filter: - description: Filters for optional subnet query - properties: - cidr: - type: string - description: - type: string - gateway_ip: - type: string - id: - type: string - ipVersion: - type: integer - ipv6AddressMode: - type: string - ipv6RaMode: - type: string - name: - type: string - notTags: - type: string - notTagsAny: - type: string - projectId: - type: string - tags: - type: string - tagsAny: - type: string - type: object - uuid: - description: Optional UUID of the subnet. If specified this - will not be validated prior to server creation. If specified, - the enclosing `NetworkParam` must also be specified by - UUID. + cidr: + type: string + description: + type: string + gateway_ip: + type: string + id: + type: string + ipVersion: + type: integer + ipv6AddressMode: + type: string + ipv6RaMode: + type: string + name: + type: string + notTags: + type: string + notTagsAny: + type: string + projectId: + type: string + tags: + type: string + tagsAny: type: string type: object required: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml index 1d32d4133f..48e0a45b3c 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml @@ -2022,41 +2022,31 @@ spec: description: The subnet in which the FixedIP is used for the Gateway of this router properties: - filter: - description: Filters for optional subnet query - properties: - cidr: - type: string - description: - type: string - gateway_ip: - type: string - id: - type: string - ipVersion: - type: integer - ipv6AddressMode: - type: string - ipv6RaMode: - type: string - name: - type: string - notTags: - type: string - notTagsAny: - type: string - projectId: - type: string - tags: - type: string - tagsAny: - type: string - type: object - uuid: - description: Optional UUID of the subnet. If specified - this will not be validated prior to server creation. - If specified, the enclosing `NetworkParam` must - also be specified by UUID. + cidr: + type: string + description: + type: string + gateway_ip: + type: string + id: + type: string + ipVersion: + type: integer + ipv6AddressMode: + type: string + ipv6RaMode: + type: string + name: + type: string + notTags: + type: string + notTagsAny: + type: string + projectId: + type: string + tags: + type: string + tagsAny: type: string type: object required: diff --git a/pkg/cloud/services/networking/router.go b/pkg/cloud/services/networking/router.go index 2dd218e501..29930cec11 100644 --- a/pkg/cloud/services/networking/router.go +++ b/pkg/cloud/services/networking/router.go @@ -164,9 +164,9 @@ func (s *Service) setRouterExternalIPs(openStackCluster *infrav1.OpenStackCluste } for _, externalRouterIP := range openStackCluster.Spec.ExternalRouterIPs { - subnetID := externalRouterIP.Subnet.UUID + subnetID := externalRouterIP.Subnet.ID if subnetID == "" { - subnet, err := s.GetSubnetByFilter(&externalRouterIP.Subnet.Filter) + subnet, err := s.GetSubnetByFilter(&externalRouterIP.Subnet) if err != nil { return fmt.Errorf("failed to get subnet for external router: %w", err) } From a1de5163aebaf6a5232f7b396f22be27e4dd1bb4 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Thu, 18 May 2023 14:46:58 +0100 Subject: [PATCH 2/2] Document removal of SubnetParam --- .../crd-changes/v1alpha6-to-v1alpha7.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/book/src/topics/crd-changes/v1alpha6-to-v1alpha7.md b/docs/book/src/topics/crd-changes/v1alpha6-to-v1alpha7.md index bdb98377c9..a1e75ed65c 100644 --- a/docs/book/src/topics/crd-changes/v1alpha6-to-v1alpha7.md +++ b/docs/book/src/topics/crd-changes/v1alpha6-to-v1alpha7.md @@ -11,6 +11,8 @@ - [Change to securityGroups](#change-to-securitygroups) - [Change to ports.securityGroupFilters](#change-to-portssecuritygroupfilters) - [Removal of Port SecurityGroups](#removal-of-port-securitygroups) + - [`OpenStackCluster`](#openstackcluster) + - [Change to externalRouterIPs.subnet](#change-to-externalrouteripssubnet) @@ -172,3 +174,26 @@ securityGroupFilters: - id: 0ddd14d9-5c33-4734-b7d0-ac4fdf35c2d9 - id: 4a131d3e-9939-4a6b-adea-788a2e89fcd8 ``` + +### `OpenStackCluster` + +#### Change to externalRouterIPs.subnet + +The `uuid` field is renamed to `id`, and all fields from `filter` are moved directly into the `subnet`. + +```yaml +externalRouterIPs: +- subnet: + uuid: f23bf9c1-8c66-4383-b474-ada1d1960149 +- subnet: + filter: + name: my-subnet +``` +becomes: +```yaml +externalRouterIPs: +- subnet: + id: f23bf9c1-8c66-4383-b474-ada1d1960149 +- subnet: + name: my-subnet +```