Icingadb can’t connect to postgres.
Icingadb version 1.1.0 (docker image).
PostgreSQL 13.9 install via dnf or run in podman, no difference.
OS: Alma linux 8
podman version: 4.2.0
podman-compose: 1.0.3
The icingadb database in postgres is configured according to the instructions:: CentOS - Icinga DB
Part from docker-compose.yml with icingadb service:
icingadb:
environment:
ICINGADB_DATABASE_HOST: some ip if install via dnf or container name if using docker image in podman
ICINGADB_DATABASE_PORT: 5432
ICINGADB_DATABASE_DATABASE: icingadb
ICINGADB_DATABASE_USER: icingadb
ICINGADB_DATABASE_PASSWORD: icingadb
ICINGADB_REDIS_HOST: icingadb-redis
ICINGADB_REDIS_PORT: 6379
depends_on:
- icingadb-redis
image: icinga/icingadb:1.1.0
logging: *default-logging
Log from Icingadb container:
2023-01-10T16:36:12.630Z DEBUG entrypoint/main.go:42 translating env vars to YAML config
2023-01-10T16:36:12.631Z DEBUG entrypoint/main.go:108 checking SQL database
2023-01-10T16:37:12.638Z DEBUG driver/driver.go:90 [unexpected EOF]
2023-01-10T16:37:12.638Z WARN driver/driver.go:46 Can't connect to database. Retrying {"error": "driver: bad connection"}
github.com/icinga/icingadb/pkg/driver.RetryConnector.Connect.func2
/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/driver/driver.go:46
github.com/icinga/icingadb/pkg/retry.WithBackoff
/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/retry/retry.go:54
github.com/icinga/icingadb/pkg/driver.RetryConnector.Connect
/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/driver/driver.go:32
database/sql.(*DB).conn
/usr/local/go/src/database/sql/sql.go:1393
database/sql.(*DB).query
/usr/local/go/src/database/sql/sql.go:1730
database/sql.(*DB).QueryContext
/usr/local/go/src/database/sql/sql.go:1708
database/sql.(*DB).Query
/usr/local/go/src/database/sql/sql.go:1726
main.dbHasSchema
/entrypoint/main.go:176
main.initDb
/entrypoint/main.go:127
main.runDaemon
/entrypoint/main.go:98
main.main
/entrypoint/main.go:38
runtime.main
/usr/local/go/src/runtime/proc.go:250
...
...
...
...
...
2023-01-10T16:50:13.461Z DEBUG driver/driver.go:90 [unexpected EOF]
2023-01-10T16:51:12.790Z WARN driver/driver.go:46 Can't connect to database. Retrying {"error": "context deadline exceeded"}
github.com/icinga/icingadb/pkg/driver.RetryConnector.Connect.func2
/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/driver/driver.go:46
github.com/icinga/icingadb/pkg/retry.WithBackoff
/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/retry/retry.go:54
github.com/icinga/icingadb/pkg/driver.RetryConnector.Connect
/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/driver/driver.go:32
database/sql.(*DB).conn
/usr/local/go/src/database/sql/sql.go:1393
database/sql.(*DB).query
/usr/local/go/src/database/sql/sql.go:1730
database/sql.(*DB).QueryContext
/usr/local/go/src/database/sql/sql.go:1715
database/sql.(*DB).Query
/usr/local/go/src/database/sql/sql.go:1726
main.dbHasSchema
/entrypoint/main.go:176
main.initDb
/entrypoint/main.go:127
main.runDaemon
/entrypoint/main.go:98
main.main
/entrypoint/main.go:38
runtime.main
/usr/local/go/src/runtime/proc.go:250
2023-01-10T16:51:12.790Z FATAL entrypoint/main.go:38 failed {"error": "can't connect to database: can't retry: driver: bad connection", "errorVerbose": "driver: bad connection\ncan't retry\ngithub.com/icinga/icingadb/pkg/retry.WithBackoff\n\t/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/retry/retry.go:78\ngithub.com/icinga/icingadb/pkg/driver.RetryConnector.Connect\n\t/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/driver/driver.go:32\ndatabase/sql.(*DB).conn\n\t/usr/local/go/src/database/sql/sql.go:1393\ndatabase/sql.(*DB).query\n\t/usr/local/go/src/database/sql/sql.go:1730\ndatabase/sql.(*DB).QueryContext\n\t/usr/local/go/src/database/sql/sql.go:1715\ndatabase/sql.(*DB).Query\n\t/usr/local/go/src/database/sql/sql.go:1726\nmain.dbHasSchema\n\t/entrypoint/main.go:176\nmain.initDb\n\t/entrypoint/main.go:127\nmain.runDaemon\n\t/entrypoint/main.go:98\nmain.main\n\t/entrypoint/main.go:38\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1594\ncan't connect to database\ngithub.com/icinga/icingadb/pkg/driver.RetryConnector.Connect\n\t/go/pkg/mod/github.com/icinga/icingadb@v1.0.0/pkg/driver/driver.go:32\ndatabase/sql.(*DB).conn\n\t/usr/local/go/src/database/sql/sql.go:1393\ndatabase/sql.(*DB).query\n\t/usr/local/go/src/database/sql/sql.go:1730\ndatabase/sql.(*DB).QueryContext\n\t/usr/local/go/src/database/sql/sql.go:1715\ndatabase/sql.(*DB).Query\n\t/usr/local/go/src/database/sql/sql.go:1726\nmain.dbHasSchema\n\t/entrypoint/main.go:176\nmain.initDb\n\t/entrypoint/main.go:127\nmain.runDaemon\n\t/entrypoint/main.go:98\nmain.main\n\t/entrypoint/main.go:38\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1594"}
main.main
/entrypoint/main.go:38
runtime.main
/usr/local/go/src/runtime/proc.go:250
Please help me figure out why icingadb doesn’t work with postgres. I tried to run with mysql and everything works fine, but I need to get icingadb to work with postgres.