Skip to content

Commit 24da9f5

Browse files
Merge pull request openshift#7239 from shiftstack/osp_fd
OSASINFRA-3182: openstack: remove portTargets
2 parents c941665 + 97e3019 commit 24da9f5

28 files changed

+600
-1024
lines changed

data/data/install.openshift.io_installconfigs.yaml

Lines changed: 0 additions & 485 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ replace sigs.k8s.io/controller-tools => sigs.k8s.io/controller-tools v0.3.1-0.20
253253

254254
// Override the OpenShift API version in hive
255255

256-
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20230531161518-2346bf94f19e
256+
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20230607130528-611114dca681
257257

258258
replace github.com/terraform-providers/terraform-provider-nutanix => github.com/nutanix/terraform-provider-nutanix v1.5.0
259259

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,8 @@ github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.m
10541054
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
10551055
github.com/opencontainers/selinux v1.5.2/go.mod h1:yTcKuYAh6R95iDpefGLQaPaRwJFwyzAJufJyiTt7s0g=
10561056
github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8=
1057-
github.com/openshift/api v0.0.0-20230531161518-2346bf94f19e h1:ELcgpoysjPXc3Gf4TrlP/OAJMgZeDUaQAFpfcnNdw2o=
1058-
github.com/openshift/api v0.0.0-20230531161518-2346bf94f19e/go.mod h1:4VWG+W22wrB4HfBL88P40DxLEpSOaiBVxUnfalfJo9k=
1057+
github.com/openshift/api v0.0.0-20230607130528-611114dca681 h1:kSvo4fjZyYRu7z7PVkZlqcYhoS4mZHVFYVUkG3WkvIE=
1058+
github.com/openshift/api v0.0.0-20230607130528-611114dca681/go.mod h1:4VWG+W22wrB4HfBL88P40DxLEpSOaiBVxUnfalfJo9k=
10591059
github.com/openshift/assisted-image-service v0.0.0-20220506122314-2f689a1084b8 h1:oZ3VAWiM8tPRBM+vYI4GBmlrqyoqizcgZ7pBy5EX2K8=
10601060
github.com/openshift/assisted-image-service v0.0.0-20220506122314-2f689a1084b8/go.mod h1:bH4+AsmPy8mQQvtgedBm2Crs93TDWeXEMlIPrlEMpjA=
10611061
github.com/openshift/assisted-service v0.0.0-20220928142635-a40422bdea61 h1:HtUYJBAdRgfVYide0bq3GsT/4n5uPWteA1rIZVXEL7k=

pkg/asset/machines/openstack/machines.go

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1212
"k8s.io/apimachinery/pkg/runtime"
1313

14+
machinev1 "github.com/openshift/api/machine/v1"
1415
machinev1alpha1 "github.com/openshift/api/machine/v1alpha1"
1516
machineapi "github.com/openshift/api/machine/v1beta1"
1617
"github.com/openshift/installer/pkg/types"
@@ -57,14 +58,11 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
5758
}
5859
machines := make([]machineapi.Machine, 0, total)
5960
for idx := int64(0); idx < total; idx++ {
60-
var failureDomain openstack.FailureDomain
61-
62-
if len(mpool.FailureDomains) > 0 {
63-
failureDomain = mpool.FailureDomains[uint(idx)%uint(len(mpool.FailureDomains))]
64-
} else {
65-
// Zones have length at least one
66-
failureDomain.ComputeAvailabilityZone = mpool.Zones[uint(idx)%uint(len(mpool.Zones))]
67-
failureDomain.StorageAvailabilityZone = volumeAZs[uint(idx)%uint(len(volumeAZs))]
61+
failureDomain := machinev1.OpenStackFailureDomain{
62+
AvailabilityZone: mpool.Zones[uint(idx)%uint(len(mpool.Zones))],
63+
RootVolume: &machinev1.RootVolume{
64+
AvailabilityZone: volumeAZs[uint(idx)%uint(len(volumeAZs))],
65+
},
6866
}
6967

7068
var provider *machinev1alpha1.OpenstackProviderSpec
@@ -110,9 +108,9 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
110108
return machines, nil
111109
}
112110

113-
func generateProvider(clusterID string, platform *openstack.Platform, mpool *openstack.MachinePool, osImage string, role, userDataSecret string, trunkSupport bool, failureDomain openstack.FailureDomain) (*machinev1alpha1.OpenstackProviderSpec, error) {
111+
func generateProvider(clusterID string, platform *openstack.Platform, mpool *openstack.MachinePool, osImage string, role, userDataSecret string, trunkSupport bool, failureDomain machinev1.OpenStackFailureDomain) (*machinev1alpha1.OpenstackProviderSpec, error) {
114112
var controlPlaneNetwork machinev1alpha1.NetworkParam
115-
additionalNetworks := make([]machinev1alpha1.NetworkParam, 0, len(failureDomain.PortTargets)+len(mpool.AdditionalNetworkIDs))
113+
additionalNetworks := make([]machinev1alpha1.NetworkParam, 0, len(mpool.AdditionalNetworkIDs))
116114
primarySubnet := platform.MachinesSubnet
117115

118116
if platform.MachinesSubnet != "" {
@@ -134,27 +132,6 @@ func generateProvider(clusterID string, platform *openstack.Platform, mpool *ope
134132
}
135133
}
136134

137-
for _, portTarget := range failureDomain.PortTargets {
138-
networkParam := machinev1alpha1.NetworkParam{
139-
UUID: portTarget.Network.ID,
140-
Filter: machinev1alpha1.Filter{
141-
Name: portTarget.Network.Name,
142-
},
143-
}
144-
for i := range portTarget.FixedIPs {
145-
networkParam.Subnets = append(networkParam.Subnets, machinev1alpha1.SubnetParam{Filter: portTarget.FixedIPs[i].Subnet})
146-
}
147-
if portTarget.ID == "control-plane" {
148-
controlPlaneNetwork = networkParam
149-
if role == "master" {
150-
primarySubnet = ""
151-
}
152-
} else {
153-
networkParam.NoAllowedAddressPairs = true
154-
additionalNetworks = append(additionalNetworks, networkParam)
155-
}
156-
}
157-
158135
for _, networkID := range mpool.AdditionalNetworkIDs {
159136
additionalNetworks = append(additionalNetworks, machinev1alpha1.NetworkParam{
160137
UUID: networkID,
@@ -181,8 +158,8 @@ func generateProvider(clusterID string, platform *openstack.Platform, mpool *ope
181158
// For the workers, we still use the AZ name as part of the server group name
182159
// so the user can control the scheduling policy per AZ and change the MachineSets
183160
// if needed on a day 2 operation.
184-
if role == "worker" && failureDomain.ComputeAvailabilityZone != "" {
185-
serverGroupName += "-" + failureDomain.ComputeAvailabilityZone
161+
if role == "worker" && failureDomain.AvailabilityZone != "" {
162+
serverGroupName += "-" + failureDomain.AvailabilityZone
186163
}
187164

188165
spec := machinev1alpha1.OpenstackProviderSpec{
@@ -196,7 +173,7 @@ func generateProvider(clusterID string, platform *openstack.Platform, mpool *ope
196173
UserDataSecret: &corev1.SecretReference{Name: userDataSecret},
197174
Networks: append([]machinev1alpha1.NetworkParam{controlPlaneNetwork}, additionalNetworks...),
198175
PrimarySubnet: primarySubnet,
199-
AvailabilityZone: failureDomain.ComputeAvailabilityZone,
176+
AvailabilityZone: failureDomain.AvailabilityZone,
200177
SecurityGroups: securityGroups,
201178
ServerGroupName: serverGroupName,
202179
Trunk: trunkSupport,
@@ -213,7 +190,7 @@ func generateProvider(clusterID string, platform *openstack.Platform, mpool *ope
213190
Size: mpool.RootVolume.Size,
214191
SourceUUID: osImage,
215192
VolumeType: mpool.RootVolume.Type,
216-
Zone: failureDomain.StorageAvailabilityZone,
193+
Zone: failureDomain.RootVolume.AvailabilityZone,
217194
}
218195
} else {
219196
spec.Image = osImage

pkg/asset/machines/openstack/machinesets.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
"k8s.io/apimachinery/pkg/runtime"
1010

11+
machinev1 "github.com/openshift/api/machine/v1"
1112
clusterapi "github.com/openshift/api/machine/v1beta1"
1213
"github.com/openshift/installer/pkg/types"
1314
"github.com/openshift/installer/pkg/types/openstack"
@@ -55,9 +56,11 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
5556
role,
5657
userDataSecret,
5758
trunkSupport,
58-
openstack.FailureDomain{
59-
ComputeAvailabilityZone: az,
60-
StorageAvailabilityZone: volumeAZs[idx%len(volumeAZs)],
59+
machinev1.OpenStackFailureDomain{
60+
AvailabilityZone: az,
61+
RootVolume: &machinev1.RootVolume{
62+
AvailabilityZone: volumeAZs[idx%len(volumeAZs)],
63+
},
6164
},
6265
)
6366
if err != nil {

pkg/tfvars/openstack/openstack.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,6 @@ func TFVars(
224224
// Terraform expects each master to get an array, empty or otherwise.
225225
additionalPorts[i] = []terraformPort{}
226226
machinesPorts[i] = defaultMachinesPort
227-
if mastermpool != nil && len(mastermpool.FailureDomains) > 0 {
228-
failureDomain := &mastermpool.FailureDomains[i%len(mastermpool.FailureDomains)]
229-
for j := range failureDomain.PortTargets {
230-
terraformPort, err := portTargetToTerraformPort(networkClient, failureDomain.PortTargets[j].PortTarget)
231-
if err != nil {
232-
return nil, fmt.Errorf("failed to resolve portTarget %q of master %d :%w", failureDomain.PortTargets[j].ID, i, err)
233-
}
234-
if failureDomain.PortTargets[j].ID == "control-plane" {
235-
machinesPorts[i] = &terraformPort
236-
} else {
237-
additionalPorts[i] = append(additionalPorts[i], terraformPort)
238-
}
239-
}
240-
}
241227
}
242228

243229
var additionalSecurityGroupIDs []string

pkg/tfvars/openstack/ports.go

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
package openstack
22

3-
import (
4-
"fmt"
5-
6-
"github.com/gophercloud/gophercloud"
7-
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
8-
"github.com/gophercloud/gophercloud/pagination"
9-
network_utils "github.com/gophercloud/utils/openstack/networking/v2/networks"
10-
11-
machinev1alpha1 "github.com/openshift/api/machine/v1alpha1"
12-
types_openstack "github.com/openshift/installer/pkg/types/openstack"
13-
)
14-
153
type terraformFixedIP struct {
164
SubnetID string `json:"subnet_id"`
175
IPAddress string `json:"ip_address"`
@@ -21,85 +9,3 @@ type terraformPort struct {
219
NetworkID string `json:"network_id"`
2210
FixedIP []terraformFixedIP `json:"fixed_ips"`
2311
}
24-
25-
func portTargetToTerraformPort(networkClient *gophercloud.ServiceClient, portTarget types_openstack.PortTarget) (terraformPort, error) {
26-
networkID := portTarget.Network.ID
27-
if networkID == "" && portTarget.Network.Name != "" {
28-
var err error
29-
networkID, err = network_utils.IDFromName(networkClient, portTarget.Network.Name)
30-
if err != nil {
31-
return terraformPort{}, fmt.Errorf("failed to resolve network ID for network name %q: %w", portTarget.Network.Name, err)
32-
}
33-
}
34-
35-
terraformFixedIPs := make([]terraformFixedIP, len(portTarget.FixedIPs))
36-
for i := range terraformFixedIPs {
37-
resolvedSubnetID, resolvedNetworkID, err := resolveSubnetFilter(networkClient, networkID, portTarget.FixedIPs[i].Subnet)
38-
if err != nil {
39-
return terraformPort{}, fmt.Errorf("failed to resolve the subnet filter: %w", err)
40-
}
41-
42-
if networkID == "" {
43-
networkID = resolvedNetworkID
44-
}
45-
46-
if networkID != resolvedNetworkID {
47-
return terraformPort{}, fmt.Errorf("port target has ports on multiple networks")
48-
}
49-
50-
terraformFixedIPs[i] = terraformFixedIP{
51-
SubnetID: resolvedSubnetID,
52-
}
53-
}
54-
55-
return terraformPort{
56-
NetworkID: networkID,
57-
FixedIP: terraformFixedIPs,
58-
}, nil
59-
}
60-
61-
func resolveSubnetFilter(networkClient *gophercloud.ServiceClient, networkID string, subnetFilter machinev1alpha1.SubnetFilter) (resolvedSubnetID, resolvedNetworkID string, err error) {
62-
if subnetFilter.ProjectID != "" {
63-
subnetFilter.TenantID = ""
64-
}
65-
if err = subnets.List(networkClient, subnets.ListOpts{
66-
NetworkID: networkID,
67-
Name: subnetFilter.Name,
68-
Description: subnetFilter.Description,
69-
TenantID: subnetFilter.TenantID,
70-
ProjectID: subnetFilter.ProjectID,
71-
IPVersion: subnetFilter.IPVersion,
72-
GatewayIP: subnetFilter.GatewayIP,
73-
CIDR: subnetFilter.CIDR,
74-
IPv6AddressMode: subnetFilter.IPv6AddressMode,
75-
IPv6RAMode: subnetFilter.IPv6RAMode,
76-
ID: subnetFilter.ID,
77-
SubnetPoolID: subnetFilter.SubnetPoolID,
78-
Tags: subnetFilter.Tags,
79-
TagsAny: subnetFilter.TagsAny,
80-
NotTags: subnetFilter.NotTags,
81-
NotTagsAny: subnetFilter.NotTagsAny,
82-
}).EachPage(func(page pagination.Page) (bool, error) {
83-
returnedSubnets, err := subnets.ExtractSubnets(page)
84-
if err != nil {
85-
return false, err
86-
}
87-
for _, subnet := range returnedSubnets {
88-
if resolvedSubnetID == "" {
89-
resolvedSubnetID = subnet.ID
90-
resolvedNetworkID = subnet.NetworkID
91-
} else {
92-
return false, fmt.Errorf("more than one subnet found")
93-
}
94-
}
95-
return true, nil
96-
}); err != nil {
97-
return "", "", fmt.Errorf("failed to list subnets: %w", err)
98-
}
99-
100-
if resolvedSubnetID == "" {
101-
return "", "", fmt.Errorf("no subnet found")
102-
}
103-
104-
return resolvedSubnetID, resolvedNetworkID, err
105-
}

pkg/types/openstack/machinepool.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ type MachinePool struct {
3333
// If no zones are provided, all instances will be deployed on OpenStack Nova default availability zone
3434
// +optional
3535
Zones []string `json:"zones,omitempty"`
36-
37-
// FailureDomains is a Tech Preview feature for resource placement. It
38-
// is incompatible with zones and rootVolume zones.
39-
FailureDomains []FailureDomain `json:"failureDomains,omitempty"`
4036
}
4137

4238
// Set sets the values from `required` to `o`.
@@ -75,10 +71,6 @@ func (o *MachinePool) Set(required *MachinePool) {
7571
if len(required.Zones) > 0 {
7672
o.Zones = required.Zones
7773
}
78-
79-
if len(required.FailureDomains) > 0 {
80-
o.FailureDomains = required.FailureDomains
81-
}
8274
}
8375

8476
// RootVolume defines the storage for an instance.
@@ -96,38 +88,6 @@ type RootVolume struct {
9688
Zones []string `json:"zones,omitempty"`
9789
}
9890

99-
// -=**
100-
// FailureDomain and its types are part of a Tech Preview feature, and may change before they're moved to openshift/api
101-
// **=-
102-
103-
// FailureDomain defines a set of correlated fault domains across different
104-
// OpenStack services: compute, storage, and network.
105-
type FailureDomain struct {
106-
// ComputeAvailabilityZone is the name of a valid nova availability zone. The server will be created in this availability zone.
107-
// +optional
108-
ComputeAvailabilityZone string `json:"computeAvailabilityZone"`
109-
110-
// StorageAvailabilityZone is the name of a valid cinder availability
111-
// zone. This will be the availability zone of the root volume if one is
112-
// specified.
113-
// +optional
114-
StorageAvailabilityZone string `json:"storageAvailabilityZone"`
115-
116-
// Ports defines a set of port targets which can be referenced by machines in this failure domain.
117-
//
118-
// +optional
119-
PortTargets []NamedPortTarget `json:"portTargets"`
120-
}
121-
122-
// NamedPortTarget includes an ID to characterize a PortTarget with its
123-
// intended purpose. If ID is set to "control-plane", then the PortTarget will
124-
// replace the default cluster primary network (or the machinesSubnet if
125-
// defined) as the first network for the machine.
126-
type NamedPortTarget struct {
127-
ID string `json:"id"`
128-
PortTarget `json:",inline"`
129-
}
130-
13191
// PortTarget defines, directly or indirectly, one or more subnets where to attach a port.
13292
type PortTarget struct {
13393
// Network is a query for an openstack network that the port will be created or discovered on.

pkg/types/openstack/validation/machinepool.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,5 @@ func ValidateMachinePool(_ *openstack.Platform, machinePool *openstack.MachinePo
2525
errs = append(errs, field.NotSupported(fldPath.Child("serverGroupPolicy"), machinePool.ServerGroupPolicy, validServerGroupPolicies))
2626
}
2727

28-
errs = append(errs, validateFailureDomains(machinePool, role, fldPath)...)
29-
30-
return errs
31-
}
32-
33-
func validateFailureDomains(machinePool *openstack.MachinePool, role string, fldPath *field.Path) (errs field.ErrorList) {
34-
if len(machinePool.FailureDomains) == 0 {
35-
return nil
36-
}
37-
38-
fldPath = fldPath.Child("failureDomains")
39-
40-
if role != "master" {
41-
return append(errs, field.Forbidden(fldPath, "failure domains can only be set on the master machine-pool"))
42-
}
43-
44-
// No failure domains together with zones
45-
if len(machinePool.Zones) > 1 || len(machinePool.Zones) > 0 && machinePool.Zones[0] != "" {
46-
errs = append(errs, field.Forbidden(fldPath, "failure domains can not be set together with zones"))
47-
}
48-
49-
// No failure domains together with root volume zones
50-
if machinePool.RootVolume != nil {
51-
if len(machinePool.RootVolume.Zones) > 1 || len(machinePool.RootVolume.Zones) > 0 && machinePool.RootVolume.Zones[0] != "" {
52-
errs = append(errs, field.Forbidden(fldPath, "failure domains can not be set together with rootVolume zones"))
53-
}
54-
}
55-
56-
// portTarget IDs must be unique
57-
for i := range machinePool.FailureDomains {
58-
ids := make(map[string]struct{})
59-
for _, portTarget := range machinePool.FailureDomains[i].PortTargets {
60-
if _, ok := ids[portTarget.ID]; ok {
61-
errs = append(errs, field.Duplicate(fldPath.Index(i).Child("id"), portTarget.ID))
62-
}
63-
ids[portTarget.ID] = struct{}{}
64-
}
65-
}
66-
6728
return errs
6829
}

0 commit comments

Comments
 (0)