mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: avoid deleting peers on graceful close (#14165)
* fix: avoid deleting peers on graceful close - Fixes an issue where a coordinator deletes all its peers on shutdown. This can cause disconnects whenever a coderd is redeployed.
This commit is contained in:
@ -35,6 +35,7 @@ type options struct {
|
||||
dumpOnFailure bool
|
||||
returnSQLDB func(*sql.DB)
|
||||
logger slog.Logger
|
||||
url string
|
||||
}
|
||||
|
||||
type Option func(*options)
|
||||
@ -59,6 +60,12 @@ func WithLogger(logger slog.Logger) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithURL(u string) Option {
|
||||
return func(o *options) {
|
||||
o.url = u
|
||||
}
|
||||
}
|
||||
|
||||
func withReturnSQLDB(f func(*sql.DB)) Option {
|
||||
return func(o *options) {
|
||||
o.returnSQLDB = f
|
||||
@ -92,6 +99,9 @@ func NewDB(t testing.TB, opts ...Option) (database.Store, pubsub.Pubsub) {
|
||||
ps := pubsub.NewInMemory()
|
||||
if WillUsePostgres() {
|
||||
connectionURL := os.Getenv("CODER_PG_CONNECTION_URL")
|
||||
if connectionURL == "" && o.url != "" {
|
||||
connectionURL = o.url
|
||||
}
|
||||
if connectionURL == "" {
|
||||
var (
|
||||
err error
|
||||
|
Reference in New Issue
Block a user