From b80e3c716ba33dc4aa35f92a173ad484ab1f6156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulko?= Date: Fri, 8 Apr 2022 15:40:19 +0200 Subject: [PATCH 1/2] Add Profile and Trunks to Ports and Networks Seems like these options got added in late CAPO and we haven't copied them to MAPO. So this commit adds them again. --- pkg/apis/openstackproviderconfig/v1alpha1/types.go | 13 +++++++++++-- pkg/machine/convert.go | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/apis/openstackproviderconfig/v1alpha1/types.go b/pkg/apis/openstackproviderconfig/v1alpha1/types.go index 29b70f1ab..a30137a30 100644 --- a/pkg/apis/openstackproviderconfig/v1alpha1/types.go +++ b/pkg/apis/openstackproviderconfig/v1alpha1/types.go @@ -135,8 +135,9 @@ type NetworkParam struct { // NoAllowedAddressPairs disables creation of allowed address pairs for the network ports NoAllowedAddressPairs bool `json:"noAllowedAddressPairs,omitempty"` // PortTags allows users to specify a list of tags to add to ports created in a given network - PortTags []string `json:"portTags,omitempty"` - VNICType string `json:"vnicType,omitempty"` + PortTags []string `json:"portTags,omitempty"` + VNICType string `json:"vnicType,omitempty"` + Profile map[string]string `json:"profile,omitempty"` // PortSecurity optionally enables or disables security on ports managed by OpenStack PortSecurity *bool `json:"portSecurity,omitempty"` } @@ -218,9 +219,17 @@ type PortOpts struct { // neutron port. VNICType string `json:"vnicType,omitempty"` + // A dictionary that enables the application running on the specified + // host to pass and receive virtual network interface (VIF) port-specific + // information to the plug-in. + Profile map[string]string `json:"profile,omitempty"` + // enable or disable security on a given port // incompatible with securityGroups and allowedAddressPairs PortSecurity *bool `json:"portSecurity,omitempty"` + + // Enables and disables trunk at port level. If not provided, openStackMachine.Spec.Trunk is inherited. + Trunk *bool `json:"trunk,omitempty"` } type AddressPair struct { diff --git a/pkg/machine/convert.go b/pkg/machine/convert.go index 6fcc98a79..e3c82a3d9 100644 --- a/pkg/machine/convert.go +++ b/pkg/machine/convert.go @@ -159,6 +159,7 @@ func networkParamToCapov1PortOpt(net *openstackconfigv1.NetworkParam, apiVIP, in VNICType: net.VNICType, FixedIPs: fixedIP, Tags: portTags, + Profile: net.Profile, } // Fetch the UUID of the network subnet is attached to or the conversion will fail @@ -307,6 +308,8 @@ func MachineToInstanceSpec(machine *machinev1.Machine, apiVIP, ingressVIP, userD AllowedAddressPairs: make([]capov1.AddressPair, len(port.AllowedAddressPairs)), HostID: port.HostID, VNICType: port.VNICType, + Profile: port.Profile, + Trunk: port.Trunk, } for fixedIPindex, fixedIP := range port.FixedIPs { From 85b4102a7cfe23fc3125ac85a2284d2cae50a436 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Mon, 11 Apr 2022 14:11:57 -0400 Subject: [PATCH 2/2] machine/convert: reverse machineSpec.Ports order When building the `machineSpec.Ports` parameter, we need to take in account the networks first, and then the additional ports. The reason is that when using the legacy cloud provider, the main interface (from a Nova standpoint) will be used to bind the kubelet process and this changes when using the new cloud provider with CCM. --- pkg/machine/convert.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/machine/convert.go b/pkg/machine/convert.go index e3c82a3d9..4961ca34a 100644 --- a/pkg/machine/convert.go +++ b/pkg/machine/convert.go @@ -294,6 +294,16 @@ func MachineToInstanceSpec(machine *machinev1.Machine, apiVIP, ingressVIP, userD } } + // The order of the networks is important, first network is the one that will be used for kubelet when + // the legacy cloud provider is used. Once we switch to using CCM by default, the order won't matter. + for _, network := range ps.Networks { + ports, err := networkParamToCapov1PortOpt(&network, apiVIP, ingressVIP, &ps.Trunk, networkService) + if err != nil { + return nil, err + } + instanceSpec.Ports = append(instanceSpec.Ports, ports...) + } + for _, port := range ps.Ports { capoPort := capov1.PortOpts{ Network: &capov1.NetworkFilter{ID: port.NetworkID}, @@ -325,13 +335,5 @@ func MachineToInstanceSpec(machine *machinev1.Machine, apiVIP, ingressVIP, userD instanceSpec.Ports = append(instanceSpec.Ports, capoPort) } - for _, network := range ps.Networks { - ports, err := networkParamToCapov1PortOpt(&network, apiVIP, ingressVIP, &ps.Trunk, networkService) - if err != nil { - return nil, err - } - instanceSpec.Ports = append(instanceSpec.Ports, ports...) - } - return &instanceSpec, nil }