Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single Postgres Configuration In API #3656

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions config/armada/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,4 @@ postgres:
dbname: lookout
sslmode: disable
queryapi:
enabled: false
maxQueryItems: 500
postgres:
connection:
host: postgres
port: 5432
user: postgres
password: psw
dbname: lookout
sslmode: disable
4 changes: 1 addition & 3 deletions internal/armada/configuration/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ArmadaConfig struct {

EventsApiRedis redis.UniversalOptions
Pulsar PulsarConfig
Postgres PostgresConfig // Used for Pulsar submit API deduplication
Postgres PostgresConfig // Needs to point to the lookout db
QueryApi QueryApiConfig

// Period At which the Queue cache will be refreshed
Expand Down Expand Up @@ -131,7 +131,5 @@ type PostgresConfig struct {
}

type QueryApiConfig struct {
Enabled bool
Postgres PostgresConfig
MaxQueryItems int
}
21 changes: 6 additions & 15 deletions internal/armada/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/apache/pulsar-client-go/pulsar"
"github.com/google/uuid"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/redis/go-redis/extra/redisprometheus/v9"
Expand Down Expand Up @@ -78,14 +77,14 @@ func Serve(ctx *armadacontext.Context, config *configuration.ArmadaConfig, healt
return nil
})

// Create database connection. This is used for the query api and also to store queues
// In a subsequent pr we will move deduplication here too and move the config out of the `queryapi` namespace
queryDb, err := database.OpenPgxPool(config.QueryApi.Postgres)
// Create database connection. This is used for the query api, queues and for job deduplication
dbPool, err := database.OpenPgxPool(config.Postgres)
if err != nil {
return errors.WithMessage(err, "error creating QueryApi postgres pool")
return errors.WithMessage(err, "error creating postgres pool")
}
defer dbPool.Close()
queryapiServer := queryapi.New(
queryDb,
dbPool,
config.QueryApi.MaxQueryItems,
func() compress.Decompressor { return compress.NewZlibDecompressor() })
api.RegisterJobsServer(grpcServer, queryapiServer)
Expand All @@ -99,7 +98,7 @@ func Serve(ctx *armadacontext.Context, config *configuration.ArmadaConfig, healt
prometheus.MustRegister(
redisprometheus.NewCollector("armada", "events_redis", eventDb))

queueRepository := queue.NewPostgresQueueRepository(queryDb)
queueRepository := queue.NewPostgresQueueRepository(dbPool)
queueCache := queue.NewCachedQueueRepository(queueRepository, config.QueueCacheRefreshPeriod)
services = append(services, func() error {
return queueCache.Run(ctx)
Expand All @@ -114,14 +113,6 @@ func Serve(ctx *armadacontext.Context, config *configuration.ArmadaConfig, healt
),
)

// If pool settings are provided, open a connection pool to be shared by all services.
var dbPool *pgxpool.Pool
dbPool, err = database.OpenPgxPool(config.Postgres)
if err != nil {
return err
}
defer dbPool.Close()

serverId := uuid.New()
var pulsarClient pulsar.Client
// API endpoints that generate Pulsar messages.
Expand Down