From 05620bc8ede3f38abb04d144f42cc0568028d8ce Mon Sep 17 00:00:00 2001 From: hamistao Date: Tue, 10 Dec 2024 01:28:08 -0300 Subject: [PATCH] lxd/network/ovn: Check uplink IP limits on `validateUplinkNetwork` Signed-off-by: hamistao --- lxd/network/driver_ovn.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lxd/network/driver_ovn.go b/lxd/network/driver_ovn.go index 30e265576dd5..8424e1d856b5 100644 --- a/lxd/network/driver_ovn.go +++ b/lxd/network/driver_ovn.go @@ -2049,6 +2049,16 @@ func (n *ovn) validateUplinkNetwork(p *api.Project, uplinkNetworkName string) (s uplinkNetworkName = allowedUplinkNetworks[0] } + // Check project quota for uplink IPs in this uplink after confirming the uplink is allowed. + quotaAvailable, err := n.projectUplinkIPQuotaAvailable(p, uplinkNetworkName) + if err != nil { + return "", err + } + + if !quotaAvailable { + return "", fmt.Errorf("Project %s's quota for uplink IPs on network %s is exhausted", p.Name, uplinkNetworkName) + } + return uplinkNetworkName, nil }