Skip to content

Commit

Permalink
Bug 1987845: openstack: relax quota checks in BYON
Browse files Browse the repository at this point in the history
When deploying OCP with pre-provisioned networks, we do not need to have
available quotas for routers, networks and subnets for the machines
since they are created already.

This patch does the following:

* On Kuryr based deployment:
- Do not touch the quotas on networks / subnets, since we still need to
  have a bunch of quotas to create what's needed for Kuryr.
- Relax the quota on Routers, since it wouldn't create one in BYON mode.

* For other network types:
Relax routers, subnets, networks to be 0 by default and if we don't
configure OCP in BYON mode, then we add the necessary quotas (1 router,
1 network and 1 subnet).
  • Loading branch information
EmilienM committed Jul 30, 2021
1 parent 8d54dd4 commit dca1b39
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions pkg/asset/quota/openstack/openstack.go
Expand Up @@ -14,9 +14,10 @@ import (
// These numbers should reflect what is documented here:
// https://github.com/openshift/installer/tree/master/docs/user/openstack
// https://github.com/openshift/installer/blob/master/docs/user/openstack/kuryr.md
// Number or ports here don't include the constraints needed for each machine, which are calculated later
var networkConstraint = buildNetworkConstraint(15, 1, 1, 1, 3, 60)
var networkConstraintWithKuryr = buildNetworkConstraint(1500, 1, 250, 250, 250, 1000)
// Number of ports, routers, subnets and routers here don't include the constraints needed
// for each machine, which are calculated later
var minNetworkConstraint = buildNetworkConstraint(15, 0, 0, 0, 3, 60)
var minNetworkConstraintWithKuryr = buildNetworkConstraint(1500, 1, 250, 250, 250, 1000)

func buildNetworkConstraint(ports, routers, subnets, networks, securityGroups, securityGroupRules int64) []quota.Constraint {
return []quota.Constraint{
Expand All @@ -31,9 +32,9 @@ func buildNetworkConstraint(ports, routers, subnets, networks, securityGroups, s

func getNetworkConstraints(networkType string) []quota.Constraint {
if networkType == string(operv1.NetworkTypeKuryr) {
return networkConstraintWithKuryr
return minNetworkConstraintWithKuryr
}
return networkConstraint
return minNetworkConstraint
}

// Constraints returns a list of quota constraints based on the InstallConfig.
Expand All @@ -51,9 +52,14 @@ func Constraints(ci *validation.CloudInfo, controlPlanes []machineapi.Machine, c
constraints = append(constraints, machineSetConstraints(ci, &computes[i], networkType)...)
}
constraints = append(constraints, instanceConstraint(int64(len(computes))))

for _, constraint := range getNetworkConstraints(networkType) {
constraints = append(constraints, constraint)
constraints = append(constraints, getNetworkConstraints(networkType)...)

// If the cluster is using pre-provisioned networks, then the quota constraints should be
// null because the installer doesn't need to create any resources.
if ci.MachinesSubnet == nil {
if networkType != string(operv1.NetworkTypeKuryr) {
constraints = append(constraints, networkConstraint(1), routerConstraint(1), subnetConstraint(1))
}
}

return aggregate(constraints)
Expand Down Expand Up @@ -147,6 +153,18 @@ func portConstraint(count int64) quota.Constraint {
return generateConstraint("Port", count)
}

func routerConstraint(count int64) quota.Constraint {
return generateConstraint("Router", count)
}

func networkConstraint(count int64) quota.Constraint {
return generateConstraint("Network", count)
}

func subnetConstraint(count int64) quota.Constraint {
return generateConstraint("Subnet", count)
}

func generateConstraint(name string, count int64) quota.Constraint {
return quota.Constraint{
Name: name,
Expand Down

0 comments on commit dca1b39

Please sign in to comment.