diff --git a/internal/core/command/main.go b/internal/core/command/main.go index dd251ed034..f8a79f3f5e 100644 --- a/internal/core/command/main.go +++ b/internal/core/command/main.go @@ -91,6 +91,11 @@ func MessagingBootstrapHandler(ctx context.Context, wg *sync.WaitGroup, startupT lc := bootstrapContainer.LoggingClientFrom(dic.Get) configuration := container.ConfigurationFrom(dic.Get) + if len(configuration.Service.RequestTimeout) == 0 { + lc.Error("Service.RequestTimeout found empty in service's configuration, missing common config? Use -cp or -cc flags for common config") + return false + } + requestTimeout, err := time.ParseDuration(configuration.Service.RequestTimeout) if err != nil { lc.Errorf("Failed to parse Service.RequestTimeout configuration value: %v", err) diff --git a/internal/pkg/bootstrap/handlers/database.go b/internal/pkg/bootstrap/handlers/database.go index 80581d4057..0f65871bd1 100644 --- a/internal/pkg/bootstrap/handlers/database.go +++ b/internal/pkg/bootstrap/handlers/database.go @@ -74,8 +74,14 @@ func (d Database) BootstrapHandler( lc := bootstrapContainer.LoggingClientFrom(dic.Get) secretProvider := bootstrapContainer.SecretProviderFrom(dic.Get) - // get database credentials. + dbInfo := d.database.GetDatabaseInfo() + if len(dbInfo.Host) == 0 || dbInfo.Port == 0 || len(dbInfo.Type) == 0 || len(dbInfo.Timeout) == 0 { + lc.Error("Database configuration is empty or incomplete, missing common config? Use -cp or -cc flags for common config") + return false + } + var credentials bootstrapConfig.Credentials + dbCredsRetrieved := false for startupTimer.HasNotElapsed() { var err error @@ -86,13 +92,22 @@ func (d Database) BootstrapHandler( Password: secrets[secret.PasswordKey], } + dbCredsRetrieved = true break } - lc.Warnf("couldn't retrieve database credentials: %v", err.Error()) + lc.Warnf("couldn't retrieve database credentials: %v and will retry it again, %s", err.Error(), + "missing common config? Use -cp or -cc flags for common config") startupTimer.SleepForInterval() } + // using this check to avoid the confusion with the case of both Username and Password being set to empty from credentials + if !dbCredsRetrieved { + // shouldn't go further if database credentials failed to retrieve + lc.Error("bootstrap failed: couldn't retrieve database credentials after some retries, missing common config? Use -cp or -cc flags for common config") + return false + } + // initialize database. var dbClient interfaces.DBClient