Skip to content

Commit

Permalink
tenantcapabilitiesauthorizer: use ReportOrPanic where applicable
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
knz committed Apr 20, 2023
1 parent 8591452 commit aa0e26f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/settings",
"//pkg/settings/cluster",
"//pkg/util/log",
"//pkg/util/log/logcrash",
"//pkg/util/syncutil",
"@com_github_cockroachdb_errors//:errors",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/log/logcrash"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/errors"
)
Expand Down Expand Up @@ -105,7 +106,9 @@ func (a *Authorizer) HasCapabilityForBatch(
case authorizerModeV222:
return a.authBatchNoCap(ctx, tenID, ba)
default:
return errors.AssertionFailedf("unknown authorizer mode: %d", mode)
err := errors.AssertionFailedf("unknown authorizer mode: %d", mode)
logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err)
return err
}
}

Expand Down Expand Up @@ -249,7 +252,9 @@ func (a *Authorizer) HasNodeStatusCapability(ctx context.Context, tenID roachpb.
case authorizerModeV222:
return errFn()
default:
return errors.AssertionFailedf("unknown authorizer mode: %d", mode)
err := errors.AssertionFailedf("unknown authorizer mode: %d", mode)
logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err)
return err
}

if !tenantcapabilities.MustGetBoolByID(
Expand Down Expand Up @@ -277,7 +282,9 @@ func (a *Authorizer) HasTSDBQueryCapability(ctx context.Context, tenID roachpb.T
case authorizerModeV222:
return errFn()
default:
return errors.AssertionFailedf("unknown authorizer mode: %d", mode)
err := errors.AssertionFailedf("unknown authorizer mode: %d", mode)
logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err)
return err
}

if !tenantcapabilities.MustGetBoolByID(
Expand Down Expand Up @@ -306,7 +313,9 @@ func (a *Authorizer) HasNodelocalStorageCapability(
case authorizerModeV222:
return errFn()
default:
return errors.AssertionFailedf("unknown authorizer mode: %d", mode)
err := errors.AssertionFailedf("unknown authorizer mode: %d", mode)
logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err)
return err
}

if !tenantcapabilities.MustGetBoolByID(
Expand All @@ -331,7 +340,8 @@ func (a *Authorizer) IsExemptFromRateLimiting(ctx context.Context, tenID roachpb
case authorizerModeV222:
return false
default:
log.Warningf(ctx, "unknown authorizer mode: %d", mode)
err := errors.AssertionFailedf("unknown authorizer mode: %d", mode)
logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err)
return false
}

Expand Down

0 comments on commit aa0e26f

Please sign in to comment.