Skip to content

Commit

Permalink
Merge pull request #5122 from shiftstack/bp48_bz1978213
Browse files Browse the repository at this point in the history
Bug 1987848: openstack: quotas/BYON improvements
  • Loading branch information
openshift-merge-robot committed Aug 27, 2021
2 parents 24fcf7a + ad49282 commit c06e9b1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
33 changes: 25 additions & 8 deletions pkg/asset/quota/openstack/openstack.go
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/sirupsen/logrus"

"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
operv1 "github.com/openshift/api/operator/v1"
"github.com/openshift/installer/pkg/asset/installconfig/openstack/validation"
"github.com/openshift/installer/pkg/quota"
machineapi "github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1"
Expand All @@ -13,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(4, 0, 0, 0, 2, 56)
var minNetworkConstraintWithKuryr = buildNetworkConstraint(1490, 0, 249, 249, 249, 996)

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

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

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

for _, constraint := range getNetworkConstraints(networkType) {
constraints = append(constraints, constraint)
// 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 {
constraints = append(constraints, networkConstraint(1), routerConstraint(1), subnetConstraint(1))
}

return aggregate(constraints)
Expand Down Expand Up @@ -146,6 +151,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
5 changes: 5 additions & 0 deletions pkg/asset/quota/quota.go
Expand Up @@ -3,6 +3,7 @@ package quota
import (
"context"
"fmt"
"os"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -122,6 +123,10 @@ func (a *PlatformQuotaCheck) Generate(dependencies asset.Parents) error {
}
summarizeReport(reports)
case typesopenstack.Name:
if skip := os.Getenv("OPENSHIFT_INSTALL_SKIP_PREFLIGHT_VALIDATIONS"); skip == "1" {
logrus.Warnf("OVERRIDE: pre-flight validation disabled.")
return nil
}
ci, err := openstackvalidation.GetCloudInfo(ic.Config)
if err != nil {
return errors.Wrap(err, "failed to get cloud info")
Expand Down

0 comments on commit c06e9b1

Please sign in to comment.