Skip to content

Commit b4aa433

Browse files
committed
Direct quota exceeders to request quote
1 parent 2f834a3 commit b4aa433

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

enterprise/server/quota/quota_manager.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ import (
2929
qpb "github.com/buildbuddy-io/buildbuddy/proto/quota"
3030
)
3131

32-
var (
33-
quotaManagerEnabled = flag.Bool("app.enable_quota_management", false, "If set, quota management will be enabled")
34-
)
32+
var quotaManagerEnabled = flag.Bool("app.enable_quota_management", false, "If set, quota management will be enabled")
3533

3634
const (
3735
// The maximum number of attempts to update rate limit data in redis.
@@ -140,7 +138,8 @@ func fetchConfigFromDB(env environment.Env, namespace string) (map[string]*names
140138
func(ctx context.Context, qbg *struct {
141139
tables.QuotaBucket
142140
*tables.QuotaGroup
143-
}) error {
141+
},
142+
) error {
144143
qb := &qbg.QuotaBucket
145144
ns, ok := config[qb.Namespace]
146145
if !ok {
@@ -339,7 +338,6 @@ func (qm *QuotaManager) findBucket(nsName string, key string) Bucket {
339338

340339
func (qm *QuotaManager) Allow(ctx context.Context, namespace string, quantity int64) error {
341340
key, err := quota.GetKey(ctx, qm.env)
342-
343341
if err != nil {
344342
metrics.QuotaKeyEmptyCount.With(prometheus.Labels{
345343
metrics.QuotaNamespace: namespace,
@@ -366,7 +364,7 @@ func (qm *QuotaManager) Allow(ctx context.Context, namespace string, quantity in
366364
metrics.QuotaNamespace: namespace,
367365
metrics.QuotaKey: key,
368366
}).Inc()
369-
return status.ResourceExhaustedErrorf("quota exceeded for %q", namespace)
367+
return status.ResourceExhaustedErrorf("quota exceeded for %q. Increase your limit at https://buildbuddy.io/request-quote", namespace)
370368
}
371369
}
372370

@@ -570,7 +568,6 @@ func (qm *QuotaManager) reloadNamespaces() error {
570568
ns, err := qm.createNamespace(qm.env, nsName, nsConfig)
571569
if err != nil {
572570
return err
573-
574571
}
575572
qm.namespaces.Store(nsName, ns)
576573
}

0 commit comments

Comments
 (0)