Skip to content

Commit 1750975

Browse files
committed
Fix postgres connection error message displayed even with successful connection
1 parent 6c9704c commit 1750975

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/tasks/db.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ func (db *DBTask) RunInit(ctx context.Context) error {
113113
defer cancel()
114114
if err := postgres.Ping(); err == nil {
115115
ok = true
116+
logrus.WithFields(logrus.Fields{"attempt": errcnt}).Info("Connected to postgres database.")
116117
cancel()
118+
} else if errcnt < maxAttempts-1 {
119+
logrus.WithFields(logrus.Fields{"attempt": errcnt}).Warn("Could not connect to postgres database. Another attempt is scheduled.")
120+
} else {
121+
logrus.WithFields(logrus.Fields{"attempt": errcnt}).Warn("Could not connect to postgres database.")
117122
}
118-
logrus.WithFields(logrus.Fields{"attempt": errcnt}).Warn("Could not connect to postgres database. Retrying.")
119123
// blocks until success, timeout, or ctx.Done()
120124
select {
121125
case <-wait.Done():

0 commit comments

Comments
 (0)