Skip to content

Commit

Permalink
Merge #117977
Browse files Browse the repository at this point in the history
117977: multitenant: use log.everyN in capability authorizer r=dt a=stevendanna

We've seen this log message produce a high volume of log entries.

Fixes #117973

Release note: None

Co-authored-by: Steven Danna <[email protected]>
  • Loading branch information
craig[bot] and stevendanna committed Jan 20, 2024
2 parents f740c07 + ad5f7b6 commit c0cdacd
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package tenantcapabilitiesauthorizer

import (
"context"
"time"

"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
"github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities"
Expand Down Expand Up @@ -70,6 +71,8 @@ type Authorizer struct {
// have started accepting requests.
syncutil.Mutex
capabilitiesReader tenantcapabilities.Reader

logEvery log.EveryN
}

var _ tenantcapabilities.Authorizer = &Authorizer{}
Expand All @@ -83,6 +86,12 @@ func New(settings *cluster.Settings, knobs *tenantcapabilities.TestingKnobs) *Au
a := &Authorizer{
settings: settings,
knobs: testingKnobs,
// We don't want to spam the log but since this is
// used to report authorization decisions that
// possibly don't respect the actual tenant
// capabilities, we also want to make sure the user
// sees the problem if it is persistent.
logEvery: log.Every(10 * time.Second),
// capabilitiesReader is set post construction, using BindReader.
}
return a
Expand Down Expand Up @@ -364,7 +373,9 @@ func (a *Authorizer) getMode(
if reader == nil {
// The server has started but the reader hasn't started/bound
// yet. Block requests that would need specific capabilities.
log.Warningf(ctx, "capability check for tenant %s before capability reader exists, assuming capability is unavailable", tid)
if a.logEvery.ShouldLog() {
log.Warningf(ctx, "capability check for tenant %s before capability reader exists, assuming capability is unavailable", tid)
}
selectedMode = authorizerModeV222
} else {
// We have a reader. Did we get data from the rangefeed yet?
Expand Down

0 comments on commit c0cdacd

Please sign in to comment.