OTP migrations fail to connect to Postgres with SSL
Environment
- Installation type (OTP or From Source): OTP
- Pleroma version (could be found in the "Version" tab of settings in Pleroma-FE):
2.0.50-2385-g47698fc3-develop
- Elixir version (
elixir -v
for from source installations, N/A for OTP): N/A - Operating system: Alpine (in Docker), macOS
- PostgreSQL version (
psql -V
): 11
Bug description
Running Pleroma migrations fails with the following when connecting via SSL:
** (EXIT from #PID<0.164.0>) an exception was raised:
** (RuntimeError) SSL connection can not be established because `:ssl` application is not started,
you can add it to `extra_application` in your `mix.exs`:
def application do
[extra_applications: [:ssl]]
end
(postgrex 0.15.5) lib/postgrex.ex:554: Postgrex.ensure_deps_started!/1
(postgrex 0.15.5) lib/postgrex.ex:496: Postgrex.child_spec/1
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:459: Ecto.Adapters.SQL.init/3
(ecto 3.4.5) lib/ecto/repo/supervisor.ex:178: Ecto.Repo.Supervisor.init/1
(stdlib 3.12.1) supervisor.erl:295: :supervisor.init/1
(stdlib 3.12.1) gen_server.erl:374: :gen_server.init_it/2
(stdlib 3.12.1) gen_server.erl:342: :gen_server.init_it/6
(stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
There's a related issue and PR against Postgrex.
To replicate:
- Run Postgres with SSL
- Build a new release via
MIX_ENV=prod mix release
- Set
ssl: true
inprod.secret.exs
- Run
./bin/pleroma_ctl migrate
. This should fail with the error above.
It looks like a reasonable patch for this is adding:
Application.ensure_all_started(:ssl)
to lib/mix/tasks/pleroma/ecto/migrate.ex
.
The above snippet has fixed it in my case, so I'll raise a PR shortly. Raised: !2894 (merged)
I'm still a little confused why having :ssl
in mix.exs
in extra_applications
doesn't fix this to begin with..