hydra: Janitor does not report connection errors and ignores logging level

Describe the bug

I haven’t run into any SQL errors yet, but running the Janitor command with incorrect database credentials will give the impression that everything is working fine.

It also seems to ignore the log level set in a config file.

Reproducing the bug

Steps to reproduce the behavior:

  1. Run d./hydra janitor --requests --tokens -c hydra.yml

You’ll get back the following

{"audience":"application","level":"info","msg":"No tracer configured - skipping tracing setup","service_name":"ORY Hydra","service_version":"v1.10.6","time":"2021-09-09T18:47:07Z"}
Successfully completed Janitor run on access tokens
Successfully completed Janitor run on refresh tokens
Successfully completed Janitor run on login-consent requests

In the above example my hydra.yml file had incorrect login credentials for my database server. I had also set the log level to debug.

I know the config file is correct because if I do put the correct credentials in, my database tables are pruned.

Expected behavior

Some error message indicating a connection error

Environment

  • Version: v1.10.6, git sha f1771f13dd954b37330d4e90d89df41fc40be460
  • Environment: Ubuntu 20.0.4, AWS MySQL RDS cluster

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15 (15 by maintainers)

Most upvoted comments

@jay-lark @Benehiko I could not reproduce.

Am I missing something?

  1. spin up hydra + hydra-migrate + mysql
docker-compose -f quickstart.yml -f quickstart-mysql.yml up - d
  1. run janitor
DSN="mysql://root:WRONG@tcp(mysqld:3306)/mysql?max_conns=20&max_idle_conns=4" go run . janitor --requests --tokens -e
  1. also tried with a config file instead of env var
#hack.yaml
dsn: mysql://root:WRONG@tcp(localhost:3306)/mysql?max_conns=20&max_idle_conns=4

go run . janitor --requests --tokens -c hack.yaml 

Gives

INFO[2022-04-23T08:34:21+02:00] No tracer configured - skipping tracing setup  audience=application service_name=Ory Hydra service_version=master
Error: Could not cleanup inactive access tokens: unable to fetch records: mysql select many: Error 1045: Access denied for user 'root'@'172.18.0.1' (using password: YES)
[...]
Could not cleanup inactive access tokens: unable to fetch records: mysql select many: Error 1045: Access denied for user 'root'@'172.18.0.1' (using password: YES)
exit status 255

update

Checked out the commit https://github.com/ory/hydra/commit/f1771f13dd954b37330d4e90d89df41fc40be460. Indeed it does not complain about anything. Seems fixed on master. @aeneasr can you confirm ?

INFO[2022-04-23T08:49:34+02:00] No tracer configured - skipping tracing setup  audience=application service_name=ORY Hydra service_version=master
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
Successfully completed Janitor run on access tokens
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
Successfully completed Janitor run on refresh tokens
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
[mysql] 2022/04/23 08:49:34 packets.go:36: unexpected EOF
Successfully completed Janitor run on login-consent requests