Remove dbconfig migration deployability code (#5348)

Default boulder code paths to exclusively use the `db` config key

Fixes #5338
This commit is contained in:
Samantha 2021-03-18 16:41:15 -07:00 committed by GitHub
parent bfd3f83717
commit 5a92926b0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 49 additions and 166 deletions

View File

@ -47,9 +47,6 @@ args:
type config struct {
Revoker struct {
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
// Similarly, the Revoker needs a TLSConfig to set up its GRPC client certs,
// but doesn't get the TLS field from ServiceConfig, so declares its own.
TLS cmd.TLSConfig
@ -76,9 +73,6 @@ func setupContext(c config) (core.RegistrationAuthority, blog.Logger, *db.Wrappe
cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to RA")
rac := bgrpc.NewRegistrationAuthorityClient(rapb.NewRegistrationAuthorityClient(raConn))
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&c.Revoker.DB, &c.Revoker.DeprecatedDBConfig)
dbURL, err := c.Revoker.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{

View File

@ -339,10 +339,7 @@ func (bkr *badKeyRevoker) invoke() (bool, error) {
func main() {
var config struct {
BadKeyRevoker struct {
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
DB cmd.DBConfig
DebugAddr string
TLS cmd.TLSConfig
@ -392,9 +389,6 @@ func main() {
scope.MustRegister(certsRevoked)
scope.MustRegister(mailErrors)
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.BadKeyRevoker.DB, &config.BadKeyRevoker.DeprecatedDBConfig)
dbURL, err := config.BadKeyRevoker.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")

View File

@ -26,10 +26,7 @@ type config struct {
CA struct {
cmd.ServiceConfig
// TODO(#5275): Refactor to named field once all configs in dev,
// staging and prod have been updated to contain `dbconfig`
// field
cmd.DBConfig
DB cmd.DBConfig
cmd.HostnamePolicyConfig
GRPCCA *cmd.GRPCServerConfig

View File

@ -30,10 +30,6 @@ type JanitorConfig struct {
// Common database connection configuration.
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
// JobConfigs is a list of configs for individual cleanup jobs.
JobConfigs []JobConfig
}
@ -67,9 +63,6 @@ func New(clk clock.Clock, config JanitorConfig) (*Janitor, error) {
defer logger.AuditPanic()
logger.Info(cmd.VersionString())
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.DB, &config.DeprecatedDBConfig)
// Create DB Map
dbURL, err := config.DB.URL()
if err != nil {

View File

@ -18,9 +18,6 @@ type config struct {
SA struct {
cmd.ServiceConfig
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
Features map[string]bool
@ -60,11 +57,6 @@ func main() {
logger.Info(cmd.VersionString())
saConf := c.SA
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&saConf.DB, &saConf.DeprecatedDBConfig)
saDbSettings := sa.DbSettings{
MaxOpenConns: saConf.DB.MaxOpenConns,
MaxIdleConns: saConf.DB.MaxIdleConns,

View File

@ -310,9 +310,6 @@ func (c *certChecker) checkCert(cert core.Certificate, ignoredLints map[string]b
type config struct {
CertChecker struct {
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
cmd.HostnamePolicyConfig
Workers int
@ -362,7 +359,7 @@ func main() {
cmd.FailOnError(err, "Failed to set audit logger")
if *connect != "" {
config.CertChecker.DBConnect = *connect
config.CertChecker.DB.DBConnect = *connect
}
if *workers != 0 {
config.CertChecker.Workers = *workers
@ -374,9 +371,6 @@ func main() {
// Validate PA config and set defaults if needed
cmd.FailOnError(config.PA.CheckChallenges(), "Invalid PA configuration")
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.CertChecker.DB, &config.CertChecker.DeprecatedDBConfig)
saDbURL, err := config.CertChecker.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{

View File

@ -75,13 +75,6 @@ type DBConfig struct {
ConnMaxIdleTime ConfigDuration
}
// DeprecatedDBConfig is a temporary type that acts as a receiver for
// fields unmarshalled from the root of a component's JSON config
// (deprecated).
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
type DeprecatedDBConfig DBConfig
// URL returns the DBConnect URL represented by this DBConfig object, either
// loading it from disk or returning a default value. Leading and trailing
// whitespace is stripped.
@ -93,24 +86,6 @@ func (d *DBConfig) URL() (string, error) {
return d.DBConnect, nil
}
// DefaultDBConfig is a temporary helper function that copies DBConfig
// fields unmarshalled from the root of a component's JSON config
// (deprecated) to the named `DBConfig` substruct of the service config.
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
func DefaultDBConfig(dbConfig *DBConfig, databaseConfig *DeprecatedDBConfig) {
if dbConfig.DBConnectFile != "" {
// dbConfig was specified properly in the JSON return early
return
}
dbConfig.DBConnect = databaseConfig.DBConnect
dbConfig.DBConnectFile = databaseConfig.DBConnectFile
dbConfig.MaxOpenConns = databaseConfig.MaxOpenConns
dbConfig.MaxIdleConns = databaseConfig.MaxIdleConns
dbConfig.ConnMaxIdleTime = databaseConfig.ConnMaxIdleTime
dbConfig.ConnMaxLifetime = databaseConfig.ConnMaxLifetime
}
type SMTPConfig struct {
PasswordConfig
Server string

View File

@ -98,36 +98,3 @@ func TestTLSConfigLoad(t *testing.T) {
})
}
}
func TestDefaultDBConfig(t *testing.T) {
exampleDBConfig := &DBConfig{}
exampleDatabaseConfig := &DeprecatedDBConfig{
DBConnect: "some secret",
DBConnectFile: "foo/bar",
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: ConfigDuration{10000},
ConnMaxIdleTime: ConfigDuration{10000},
}
expected := &DBConfig{
DBConnect: "some secret",
DBConnectFile: "foo/bar",
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: ConfigDuration{10000},
ConnMaxIdleTime: ConfigDuration{10000},
}
DefaultDBConfig(exampleDBConfig, exampleDatabaseConfig)
test.AssertDeepEquals(t, exampleDBConfig, expected)
exampleDBConfig = &DBConfig{
DBConnect: "some secret",
DBConnectFile: "foo/bar",
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: ConfigDuration{10000},
ConnMaxIdleTime: ConfigDuration{10000}}
exampleDatabaseConfig = &DeprecatedDBConfig{}
DefaultDBConfig(exampleDBConfig, exampleDatabaseConfig)
test.AssertDeepEquals(t, exampleDBConfig, expected)
}

View File

@ -364,9 +364,6 @@ type config struct {
Mailer struct {
cmd.ServiceConfig
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
cmd.SMTPConfig
From string
@ -477,9 +474,6 @@ func main() {
c.Mailer.CertLimit = 100
}
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&c.Mailer.DB, &c.Mailer.DeprecatedDBConfig)
// Configure DB
dbURL, err := c.Mailer.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")

View File

@ -3,8 +3,10 @@
"syslog": {
"stdoutLevel": 6
},
"dbConnectFile": "test/secrets/purger_dburl",
"maxOpenConns": 10,
"db": {
"dbConnectFile": "test/secrets/purger_dburl",
"maxOpenConns": 10
},
"gracePeriod": "168h",
"batchSize": 1000,
"debugAddr": ":8015"

View File

@ -17,10 +17,7 @@ import (
type config struct {
ExpiredAuthzPurger2 struct {
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
DB cmd.DBConfig
DebugAddr string
Syslog cmd.SyslogConfig
Features map[string]bool
@ -79,9 +76,6 @@ func main() {
clk := cmd.Clock()
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&c.ExpiredAuthzPurger2.DB, &c.ExpiredAuthzPurger2.DeprecatedDBConfig)
dbURL, err := c.ExpiredAuthzPurger2.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{

View File

@ -146,9 +146,6 @@ func main() {
type config struct {
ContactExporter struct {
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
cmd.PasswordConfig
Features map[string]bool
}
@ -177,9 +174,6 @@ func main() {
err = features.Set(cfg.ContactExporter.Features)
cmd.FailOnError(err, "Failed to set feature flags")
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&cfg.ContactExporter.DB, &cfg.ContactExporter.DeprecatedDBConfig)
dbURL, err := cfg.ContactExporter.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{

View File

@ -407,9 +407,6 @@ func main() {
type config struct {
NotifyMailer struct {
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
cmd.PasswordConfig
cmd.SMTPConfig
Features map[string]bool
@ -442,9 +439,6 @@ func main() {
log := cmd.NewLogger(cfg.Syslog)
defer log.AuditPanic()
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&cfg.NotifyMailer.DB, &cfg.NotifyMailer.DeprecatedDBConfig)
dbURL, err := cfg.NotifyMailer.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{

View File

@ -195,13 +195,8 @@ func (src *dbSource) Response(req *ocsp.Request) ([]byte, http.Header, error) {
type config struct {
OCSPResponder struct {
cmd.ServiceConfig
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
// Source indicates the source of pre-signed OCSP responses to be used. It
// can be a DBConnect string or a file URL. The file URL style is used
// when responding from a static file for intermediates and roots.
@ -275,9 +270,6 @@ as generated by Boulder's ceremony command.
source, err = bocsp.NewMemorySourceFromFile(filename, logger)
cmd.FailOnError(err, fmt.Sprintf("Couldn't read file: %s", url.Path))
} else {
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.DB, &config.DeprecatedDBConfig)
// For databases, DBConfig takes precedence over Source, if present.
dbConnect, err := config.DB.URL()
cmd.FailOnError(err, "Reading DB config")

View File

@ -281,10 +281,6 @@ type OCSPUpdaterConfig struct {
cmd.ServiceConfig
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
OldOCSPWindow cmd.ConfigDuration
OldOCSPBatchSize int
@ -345,9 +341,6 @@ func main() {
defer logger.AuditPanic()
logger.Info(cmd.VersionString())
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&conf.DB, &conf.DeprecatedDBConfig)
// Configure DB
dbURL, err := conf.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")

View File

@ -19,10 +19,7 @@ import (
type fillerConfig struct {
Filler struct {
DB cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DeprecatedDBConfig
DB cmd.DBConfig
Parallelism uint
}
}
@ -47,9 +44,6 @@ func main() {
err = json.Unmarshal(configJSON, &config)
cmd.FailOnError(err, "Failed to parse config")
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.Filler.DB, &config.Filler.DeprecatedDBConfig)
// Configure DB
dbURL, err := config.Filler.DB.URL()
cmd.FailOnError(err, "Couldn't load DB URL")

View File

@ -1,7 +1,9 @@
{
"revoker": {
"dbConnectFile": "test/secrets/revoker_dburl",
"maxOpenConns": 1,
"db": {
"dbConnectFile": "test/secrets/revoker_dburl",
"maxOpenConns": 1
},
"tls": {
"caCertFile": "test/grpc-creds/minica.pem",
"certFile": "test/grpc-creds/admin-revoker.boulder/cert.pem",

View File

@ -1,7 +1,9 @@
{
"BadKeyRevoker": {
"dbConnectFile": "test/secrets/badkeyrevoker_dburl",
"maxOpenConns": 10,
"db": {
"dbConnectFile": "test/secrets/badkeyrevoker_dburl",
"maxOpenConns": 10
},
"debugAddr": ":8020",
"tls": {
"caCertFile": "test/grpc-creds/minica.pem",

View File

@ -1,7 +1,9 @@
{
"certChecker": {
"dbConnectFile": "test/secrets/cert_checker_dburl",
"maxOpenConns": 10,
"db": {
"dbConnectFile": "test/secrets/cert_checker_dburl",
"maxOpenConns": 10
},
"hostnamePolicyFile": "test/hostname-policy.yaml",
"ignoredLints": [
"n_subject_common_name_included"

View File

@ -1,7 +1,9 @@
{
"contactExporter": {
"passwordFile": "test/secrets/smtp_password",
"dbConnectFile": "test/secrets/mailer_dburl",
"maxOpenConns": 10
"db": {
"dbConnectFile": "test/secrets/mailer_dburl",
"maxOpenConns": 10
}
}
}

View File

@ -5,8 +5,10 @@
"username": "cert-manager@example.com",
"from": "Expiry bot <test@example.com>",
"passwordFile": "test/secrets/smtp_password",
"dbConnectFile": "test/secrets/mailer_dburl",
"maxOpenConns": 10,
"db": {
"dbConnectFile": "test/secrets/mailer_dburl",
"maxOpenConns": 10
},
"nagTimes": ["24h", "72h", "168h", "336h"],
"nagCheckInterval": "24h",
"emailTemplate": "test/example-expiration-template",

View File

@ -3,8 +3,10 @@
"syslog": {
"stdoutLevel": 6
},
"dbConnectFile": "test/secrets/janitor_dburl",
"maxOpenConns": 10,
"db": {
"dbConnectFile": "test/secrets/janitor_dburl",
"maxOpenConns": 10
},
"debugAddr": ":8014",
"jobConfigs": [
{

View File

@ -4,8 +4,10 @@
"port": "9380",
"username": "cert-manager@example.com",
"passwordFile": "test/secrets/smtp_password",
"dbConnectFile": "test/secrets/mailer_dburl",
"maxOpenConns": 10
"db": {
"dbConnectFile": "test/secrets/mailer_dburl",
"maxOpenConns": 10
}
},
"syslog": {
"stdoutLevel": 7,

View File

@ -1,7 +1,9 @@
{
"ocspResponder": {
"dbConnectFile": "test/secrets/ocsp_responder_dburl",
"maxOpenConns": 10,
"db": {
"dbConnectFile": "test/secrets/ocsp_responder_dburl",
"maxOpenConns": 10
},
"path": "/",
"listenAddress": "0.0.0.0:4002",
"maxAge": "10s",

View File

@ -1,7 +1,9 @@
{
"ocspUpdater": {
"dbConnectFile": "test/secrets/ocsp_updater_dburl",
"maxOpenConns": 10,
"db": {
"dbConnectFile": "test/secrets/ocsp_updater_dburl",
"maxOpenConns": 10
},
"oldOCSPWindow": "2s",
"oldOCSPBatchSize": 5000,
"parallelGenerateOCSPRequests": 10,

View File

@ -1,7 +1,9 @@
{
"sa": {
"dbConnectFile": "test/secrets/sa_dburl",
"maxOpenConns": 100,
"db": {
"dbConnectFile": "test/secrets/sa_dburl",
"maxOpenConns": 100
},
"ParallelismPerRPC": 20,
"debugAddr": ":8003",
"tls": {