Skip to content

Commit

Permalink
Deprecate MaxDBConns for MaxOpenConns
Browse files Browse the repository at this point in the history
In #5235 we replaced MaxDBConns in favor of MaxOpenConns.

One week ago MaxDBConns was removed from all dev, staging, and
production configurations. This change completes the removal of
MaxDBConns from all components and test/config.

Fixes #5249
  • Loading branch information
beautifulentropy committed Feb 6, 2021
1 parent 82b200b commit a2158df
Show file tree
Hide file tree
Showing 22 changed files with 20 additions and 73 deletions.
2 changes: 1 addition & 1 deletion cmd/admin-revoker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func setupContext(c config) (core.RegistrationAuthority, blog.Logger, *db.Wrappe
dbURL, err := c.Revoker.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
MaxOpenConns: c.Revoker.DBConfig.GetMaxOpenConns(),
MaxOpenConns: c.Revoker.DBConfig.MaxOpenConns,
MaxIdleConns: c.Revoker.DBConfig.MaxIdleConns,
ConnMaxLifetime: c.Revoker.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: c.Revoker.DBConfig.ConnMaxIdleTime.Duration,
Expand Down
2 changes: 1 addition & 1 deletion cmd/bad-key-revoker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func main() {
cmd.FailOnError(err, "Couldn't load DB URL")

dbSettings := sa.DbSettings{
MaxOpenConns: config.BadKeyRevoker.DBConfig.GetMaxOpenConns(),
MaxOpenConns: config.BadKeyRevoker.DBConfig.MaxOpenConns,
MaxIdleConns: config.BadKeyRevoker.DBConfig.MaxIdleConns,
ConnMaxLifetime: config.BadKeyRevoker.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: config.BadKeyRevoker.DBConfig.ConnMaxIdleTime.Duration,
Expand Down
2 changes: 1 addition & 1 deletion cmd/boulder-janitor/janitor/janitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func New(clk clock.Clock, config JanitorConfig) (*Janitor, error) {
return nil, err
}
dbSettings := sa.DbSettings{
MaxOpenConns: config.DBConfig.GetMaxOpenConns(),
MaxOpenConns: config.DBConfig.MaxOpenConns,
MaxIdleConns: config.DBConfig.MaxIdleConns,
ConnMaxLifetime: config.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: config.DBConfig.ConnMaxIdleTime.Duration,
Expand Down
2 changes: 1 addition & 1 deletion cmd/boulder-sa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func main() {

saConf := c.SA
saDbSettings := sa.DbSettings{
MaxOpenConns: saConf.DBConfig.GetMaxOpenConns(),
MaxOpenConns: saConf.DBConfig.MaxOpenConns,
MaxIdleConns: saConf.DBConfig.MaxIdleConns,
ConnMaxLifetime: saConf.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: saConf.DBConfig.ConnMaxIdleTime.Duration,
Expand Down
2 changes: 1 addition & 1 deletion cmd/cert-checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func main() {
saDbURL, err := config.CertChecker.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
MaxOpenConns: config.CertChecker.DBConfig.GetMaxOpenConns(),
MaxOpenConns: config.CertChecker.DBConfig.MaxOpenConns,
MaxIdleConns: config.CertChecker.DBConfig.MaxIdleConns,
ConnMaxLifetime: config.CertChecker.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: config.CertChecker.DBConfig.ConnMaxIdleTime.Duration,
Expand Down
20 changes: 0 additions & 20 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ type DBConfig struct {
// A file containing a connect URL for the DB.
DBConnectFile string

// MaxDBConns sets the maximum number of open connections to the
// database. If MaxIdleConns is greater than 0 and MaxOpenConns is
// less than MaxIdleConns, then MaxIdleConns will be reduced to
// match the new MaxOpenConns limit. If n < 0, then there is no
// limit on the number of open connections.
// TODO(#5249): This field can be removed once MaxDBConns has been
// removed from test/config and all prod and staging configs.
MaxDBConns int

// MaxOpenConns sets the maximum number of open connections to the
// database. If MaxIdleConns is greater than 0 and MaxOpenConns is
// less than MaxIdleConns, then MaxIdleConns will be reduced to
Expand Down Expand Up @@ -95,17 +86,6 @@ func (d *DBConfig) URL() (string, error) {
return d.DBConnect, nil
}

// GetMaxOpenConns defaults MaxOpenConns to the value of MaxDBConns if
// MaxDBConns was specified in the config json.
// TODO(#5249): This method can be removed once MaxDBConns has been
// removed from test/config and all prod and staging configs.
func (d *DBConfig) GetMaxOpenConns() int {
if d.MaxOpenConns == 0 {
d.MaxOpenConns = d.MaxDBConns
}
return d.MaxOpenConns
}

type SMTPConfig struct {
PasswordConfig
Server string
Expand Down
33 changes: 0 additions & 33 deletions cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,6 @@ func TestDBConfigURL(t *testing.T) {
}
}

func TestGetMaxOpenConns(t *testing.T) {
tests := []struct {
conf DBConfig
expected int
}{
{
// Test with config that contains both fields with different values
conf: DBConfig{MaxDBConns: 1, MaxOpenConns: 100},
expected: 100,
},
{
// Test with config that contains only MaxDBConns
conf: DBConfig{MaxDBConns: 100},
expected: 100,
},
{
// Test with config that contains only MaxOpenConns
conf: DBConfig{MaxOpenConns: 1},
expected: 1,
},
{
// Test with config that contains neither field
conf: DBConfig{},
expected: 0,
},
}

for _, tc := range tests {
maxOpenConns := tc.conf.GetMaxOpenConns()
test.AssertEquals(t, maxOpenConns, tc.expected)
}
}

func TestPasswordConfig(t *testing.T) {
tests := []struct {
pc PasswordConfig
Expand Down
2 changes: 1 addition & 1 deletion cmd/expiration-mailer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func main() {
dbURL, err := c.Mailer.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
MaxOpenConns: c.Mailer.DBConfig.GetMaxOpenConns(),
MaxOpenConns: c.Mailer.DBConfig.MaxOpenConns,
MaxIdleConns: c.Mailer.DBConfig.MaxIdleConns,
ConnMaxLifetime: c.Mailer.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: c.Mailer.DBConfig.ConnMaxIdleTime.Duration,
Expand Down
2 changes: 1 addition & 1 deletion cmd/expired-authz-purger2/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"stdoutLevel": 6
},
"dbConnectFile": "test/secrets/purger_dburl",
"maxDBConns": 10,
"maxOpenConns": 10,
"gracePeriod": "168h",
"batchSize": 1000,
"debugAddr": ":8015"
Expand Down
2 changes: 1 addition & 1 deletion cmd/expired-authz-purger2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func main() {
dbURL, err := c.ExpiredAuthzPurger2.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
MaxOpenConns: c.ExpiredAuthzPurger2.DBConfig.GetMaxOpenConns(),
MaxOpenConns: c.ExpiredAuthzPurger2.DBConfig.MaxOpenConns,
MaxIdleConns: c.ExpiredAuthzPurger2.DBConfig.MaxIdleConns,
ConnMaxLifetime: c.ExpiredAuthzPurger2.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: c.ExpiredAuthzPurger2.DBConfig.ConnMaxIdleTime.Duration,
Expand Down
2 changes: 1 addition & 1 deletion cmd/ocsp-responder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ as generated by Boulder's ceremony command.
}
logger.Infof("Loading OCSP Database for CA Cert: %s", c.Common.IssuerCert)
dbSettings := sa.DbSettings{
MaxOpenConns: config.DBConfig.GetMaxOpenConns(),
MaxOpenConns: config.DBConfig.MaxOpenConns,
MaxIdleConns: config.DBConfig.MaxIdleConns,
ConnMaxLifetime: config.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: config.DBConfig.ConnMaxIdleTime.Duration,
Expand Down
2 changes: 1 addition & 1 deletion cmd/ocsp-updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func main() {
dbURL, err := conf.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
MaxOpenConns: conf.DBConfig.GetMaxOpenConns(),
MaxOpenConns: conf.DBConfig.MaxOpenConns,
MaxIdleConns: conf.DBConfig.MaxIdleConns,
ConnMaxLifetime: conf.DBConfig.ConnMaxLifetime.Duration,
ConnMaxIdleTime: conf.DBConfig.ConnMaxIdleTime.Duration}
Expand Down
2 changes: 1 addition & 1 deletion test/config/admin-revoker.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"revoker": {
"dbConnectFile": "test/secrets/revoker_dburl",
"maxDBConns": 1,
"maxOpenConns": 1,
"tls": {
"caCertFile": "test/grpc-creds/minica.pem",
"certFile": "test/grpc-creds/admin-revoker.boulder/cert.pem",
Expand Down
2 changes: 1 addition & 1 deletion test/config/bad-key-revoker.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"BadKeyRevoker": {
"dbConnectFile": "test/secrets/badkeyrevoker_dburl",
"maxDBConns": 10,
"maxOpenConns": 10,
"debugAddr": ":8020",
"tls": {
"caCertFile": "test/grpc-creds/minica.pem",
Expand Down
2 changes: 1 addition & 1 deletion test/config/cert-checker.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"certChecker": {
"dbConnectFile": "test/secrets/cert_checker_dburl",
"maxDBConns": 10,
"maxOpenConns": 10,
"hostnamePolicyFile": "test/hostname-policy.yaml",
"ignoredLints": [
"n_subject_common_name_included"
Expand Down
2 changes: 1 addition & 1 deletion test/config/contact-exporter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"contactExporter": {
"passwordFile": "test/secrets/smtp_password",
"dbConnectFile": "test/secrets/mailer_dburl",
"maxDBConns": 10
"maxOpenConns": 10
}
}
2 changes: 1 addition & 1 deletion test/config/expiration-mailer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"from": "Expiry bot <test@example.com>",
"passwordFile": "test/secrets/smtp_password",
"dbConnectFile": "test/secrets/mailer_dburl",
"maxDBConns": 10,
"maxOpenConns": 10,
"nagTimes": ["24h", "72h", "168h", "336h"],
"nagCheckInterval": "24h",
"emailTemplate": "test/example-expiration-template",
Expand Down
2 changes: 1 addition & 1 deletion test/config/janitor.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"stdoutLevel": 6
},
"dbConnectFile": "test/secrets/janitor_dburl",
"maxDBConns": 10,
"maxOpenConns": 10,
"debugAddr": ":8014",
"jobConfigs": [
{
Expand Down
2 changes: 1 addition & 1 deletion test/config/notify-mailer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"username": "cert-manager@example.com",
"passwordFile": "test/secrets/smtp_password",
"dbConnectFile": "test/secrets/mailer_dburl",
"maxDBConns": 10
"maxOpenConns": 10
},
"syslog": {
"stdoutLevel": 7,
Expand Down
2 changes: 1 addition & 1 deletion test/config/ocsp-responder.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ocspResponder": {
"dbConnectFile": "test/secrets/ocsp_responder_dburl",
"maxDBConns": 10,
"maxOpenConns": 10,
"path": "/",
"listenAddress": "0.0.0.0:4002",
"maxAge": "10s",
Expand Down
2 changes: 1 addition & 1 deletion test/config/ocsp-updater.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ocspUpdater": {
"dbConnectFile": "test/secrets/ocsp_updater_dburl",
"maxDBConns": 10,
"maxOpenConns": 10,
"oldOCSPWindow": "2s",
"oldOCSPBatchSize": 5000,
"parallelGenerateOCSPRequests": 10,
Expand Down
2 changes: 1 addition & 1 deletion test/config/sa.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sa": {
"dbConnectFile": "test/secrets/sa_dburl",
"maxDBConns": 100,
"maxOpenConns": 100,
"ParallelismPerRPC": 20,
"debugAddr": ":8003",
"tls": {
Expand Down

0 comments on commit a2158df

Please sign in to comment.