Skip to content

Commit

Permalink
Add quota validation for server group
Browse files Browse the repository at this point in the history
- Added a quota constraint for server groups with a default of 2, reducing to 1 when no worker nodes are provisioned.
- Added a quota constraint for server group members, equal to the number of instances provisioned.
  • Loading branch information
dkokkino committed Jan 2, 2025
1 parent 43fa24e commit 5bc0e7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/asset/installconfig/openstack/validation/cloudinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ func getComputeLimits(ctx context.Context, ci *CloudInfo, projectID string) ([]q
addQuota("Cores", qs.Cores)
addQuota("Instances", qs.Instances)
addQuota("RAM", qs.RAM)
addQuota("ServerGroups", qs.ServerGroups)
addQuota("ServerGroupMembers", qs.ServerGroupMembers)

return quotas, nil
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/asset/quota/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ func Constraints(ci *validation.CloudInfo, controlPlanes []machineapi.Machine, c
if len(ci.ControlPlanePortSubnets) == 0 {
constraints = append(constraints, networkConstraint(1), routerConstraint(1), subnetConstraint(1))
}
// if the cluster does not have worker nodes then reduce the server group value from 2 to 1
numServerGroups := int64(2)
if len(computes) == 0 {
numServerGroups--
}
constraints = append(constraints, serverGroupsConstraint(numServerGroups))
constraints = append(constraints, serverGroupMembersConstraint(int64(len(controlPlanes)+len(computes))))

return aggregate(constraints)
}
Expand Down Expand Up @@ -163,3 +170,11 @@ func generateConstraint(name string, count int64) quota.Constraint {
Count: count,
}
}

func serverGroupsConstraint(count int64) quota.Constraint {
return generateConstraint("ServerGroups", count)
}

func serverGroupMembersConstraint(count int64) quota.Constraint {
return generateConstraint("ServerGroupMembers", count)
}

0 comments on commit 5bc0e7e

Please sign in to comment.