Skip to content

Commit

Permalink
Remove dbconfig migration deployability code
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Mar 18, 2021
1 parent bae699f commit e47b1a4
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 166 deletions.
6 changes: 0 additions & 6 deletions cmd/admin-revoker/main.go
Expand Up @@ -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
Expand All @@ -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{
Expand Down
8 changes: 1 addition & 7 deletions cmd/bad-key-revoker/main.go
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down
5 changes: 1 addition & 4 deletions cmd/boulder-ca/main.go
Expand Up @@ -34,10 +34,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
Expand Down
7 changes: 0 additions & 7 deletions cmd/boulder-janitor/janitor/janitor.go
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 0 additions & 8 deletions cmd/boulder-sa/main.go
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions cmd/cert-checker/main.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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{
Expand Down
25 changes: 0 additions & 25 deletions cmd/config.go
Expand Up @@ -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.
Expand All @@ -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
Expand Down
33 changes: 0 additions & 33 deletions cmd/config_test.go
Expand Up @@ -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)
}
6 changes: 0 additions & 6 deletions cmd/expiration-mailer/main.go
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions cmd/expired-authz-purger2/config.json
Expand Up @@ -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"
Expand Down
8 changes: 1 addition & 7 deletions cmd/expired-authz-purger2/main.go
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down
6 changes: 0 additions & 6 deletions cmd/id-exporter/main.go
Expand Up @@ -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
}
Expand Down Expand Up @@ -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{
Expand Down
6 changes: 0 additions & 6 deletions cmd/notify-mailer/main.go
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down
8 changes: 0 additions & 8 deletions cmd/ocsp-responder/main.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down
7 changes: 0 additions & 7 deletions cmd/ocsp-updater/main.go
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down
8 changes: 1 addition & 7 deletions test/authz-filler/main.go
Expand Up @@ -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
}
}
Expand All @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions test/config/admin-revoker.json
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions test/config/bad-key-revoker.json
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions test/config/cert-checker.json
@@ -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"
Expand Down

0 comments on commit e47b1a4

Please sign in to comment.