fix for mixing limited and unlimited resource counts (#680)

This commit is contained in:
Michael Quigley 2024-06-25 16:09:51 -04:00
parent 5fe2530076
commit 466ae110d2
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -134,15 +134,15 @@ func (a *Agent) CanCreateShare(acctId, envId int, reserved, uniqueName bool, _ s
uniqueNames++
}
}
if total+1 > rc.GetShares() {
if rc.GetShares() > store.Unlimited && total+1 > rc.GetShares() {
logrus.Debugf("account '#%d', environment '%d' over shares limit '%d'", acctId, envId, a.cfg.Shares)
return false, nil
}
if reserved && reserveds+1 > rc.GetReservedShares() {
if reserved && rc.GetReservedShares() > store.Unlimited && reserveds+1 > rc.GetReservedShares() {
logrus.Debugf("account '#%d', environment '%d' over reserved shares limit '%d'", acctId, envId, a.cfg.ReservedShares)
return false, nil
}
if reserved && uniqueName && uniqueNames+1 > rc.GetUniqueNames() {
if reserved && uniqueName && rc.GetUniqueNames() > store.Unlimited && uniqueNames+1 > rc.GetUniqueNames() {
logrus.Debugf("account '#%d', environment '%d' over unique names limit '%d'", acctId, envId, a.cfg.UniqueNames)
return false, nil
}