Skip to content

Commit

Permalink
SA: Add feature flag DisableLegacyLimitWrites
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Sep 27, 2024
1 parent c034221 commit f2a5ccd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ type Config struct {
// to be the authoritative source of rate limiting information for
// new-account callers and disables the legacy rate limiting checks.
UseKvLimitsForNewAccount bool

// DisableLegacyLimitWrites when enabled, disables writes to the newOrdersRL
// table at new-order time. This flag should only be used in conjunction with
// UseKvLimitsForNewOrder.
DisableLegacyLimitWrites bool
}

var fMu = new(sync.RWMutex)
Expand Down
10 changes: 6 additions & 4 deletions sa/sa.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,12 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
return nil, fmt.Errorf("casting error in NewOrderAndAuthzs")
}

// Increment the order creation count
err = addNewOrdersRateLimit(ctx, ssa.dbMap, req.NewOrder.RegistrationID, ssa.clk.Now().Truncate(time.Minute))
if err != nil {
return nil, err
if !features.Get().DisableLegacyLimitWrites {
// Increment the order creation count
err = addNewOrdersRateLimit(ctx, ssa.dbMap, req.NewOrder.RegistrationID, ssa.clk.Now().Truncate(time.Minute))
if err != nil {
return nil, err
}
}

return order, nil
Expand Down
3 changes: 2 additions & 1 deletion test/config-next/sa.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"healthCheckInterval": "4s",
"features": {
"MultipleCertificateProfiles": true,
"TrackReplacementCertificatesARI": true
"TrackReplacementCertificatesARI": true,
"DisableLegacyLimitWrites": true
}
},
"syslog": {
Expand Down

0 comments on commit f2a5ccd

Please sign in to comment.