chore: disable pgcoord (HA) when --in-memory (#12919)

* chore: disable pgcoord (HA) when --in-memory

HA does not make any sense while using in-memory database
This commit is contained in:
Steven Masley
2024-04-10 11:05:55 -05:00
committed by GitHub
parent 838e8df5be
commit a607d5610e
2 changed files with 9 additions and 10 deletions

View File

@ -630,7 +630,13 @@ func (api *API) updateEntitlements(ctx context.Context) error {
if initial, changed, enabled := featureChanged(codersdk.FeatureHighAvailability); shouldUpdate(initial, changed, enabled) {
var coordinator agpltailnet.Coordinator
if enabled {
// If HA is enabled, but the database is in-memory, we can't actually
// run HA and the PG coordinator. So throw a log line, and continue to use
// the in memory AGPL coordinator.
if enabled && api.DeploymentValues.InMemoryDatabase.Value() {
api.Logger.Warn(ctx, "high availability is enabled, but cannot be configured due to the database being set to in-memory")
}
if enabled && !api.DeploymentValues.InMemoryDatabase.Value() {
haCoordinator, err := tailnet.NewPGCoord(api.ctx, api.Logger, api.Pubsub, api.Database)
if err != nil {
api.Logger.Error(ctx, "unable to set up high availability coordinator", slog.Error(err))