mirror of
https://github.com/openziti/zrok.git
synced 2025-01-03 20:49:13 +01:00
fix for scoped bandwidth limits in agent.CanCreateShare; make relax actions error without failing (#606, #451)
This commit is contained in:
parent
efd16c2760
commit
afc8d22a9f
@ -87,15 +87,24 @@ func (a *Agent) CanCreateShare(acctId, envId int, reserved, uniqueName bool, _ s
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
bwcs := ul.toBandwidthArray(backendMode)
|
if scopedBwc, found := ul.scopes[backendMode]; found {
|
||||||
for _, bwc := range bwcs {
|
latestScopedJe, err := a.isBandwidthClassLimitedForAccount(acctId, scopedBwc, trx)
|
||||||
latestJe, err := a.isBandwidthClassLimitedForAccount(acctId, bwc, trx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if latestJe != nil {
|
if latestScopedJe != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for _, bwc := range ul.bandwidth {
|
||||||
|
latestJe, err := a.isBandwidthClassLimitedForAccount(acctId, bwc, trx)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if latestJe != nil {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ul.resource.GetShares() > store.Unlimited || (reserved && ul.resource.GetReservedShares() > store.Unlimited) || (reserved && uniqueName && ul.resource.GetUniqueNames() > store.Unlimited) {
|
if ul.resource.GetShares() > store.Unlimited || (reserved && ul.resource.GetReservedShares() > store.Unlimited) || (reserved && uniqueName && ul.resource.GetUniqueNames() > store.Unlimited) {
|
||||||
|
@ -44,11 +44,11 @@ func (a *relaxAction) HandleAccount(acct *store.Account, _, _ int64, bwc store.B
|
|||||||
switch shr.ShareMode {
|
switch shr.ShareMode {
|
||||||
case string(sdk.PublicShareMode):
|
case string(sdk.PublicShareMode):
|
||||||
if err := relaxPublicShare(a.str, edge, shr, trx); err != nil {
|
if err := relaxPublicShare(a.str, edge, shr, trx); err != nil {
|
||||||
return errors.Wrap(err, "error relaxing public share")
|
logrus.Errorf("error relaxing public share '%v' for account '%v' (ignoring): %v", shr.Token, acct.Email, err)
|
||||||
}
|
}
|
||||||
case string(sdk.PrivateShareMode):
|
case string(sdk.PrivateShareMode):
|
||||||
if err := relaxPrivateShare(a.str, edge, shr, trx); err != nil {
|
if err := relaxPrivateShare(a.str, edge, shr, trx); err != nil {
|
||||||
return errors.Wrap(err, "error relaxing private share")
|
logrus.Errorf("error relaxing private share '%v' for account '%v' (ignoring): %v", shr.Token, acct.Email, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user