Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres SSL support missing #347

Closed
BobyMCbobs opened this issue Oct 7, 2020 · 9 comments · Fixed by #355
Closed

Postgres SSL support missing #347

BobyMCbobs opened this issue Oct 7, 2020 · 9 comments · Fixed by #355

Comments

@BobyMCbobs
Copy link
Contributor

I'm trying to set up Analytics in Kubernetes with a Postgres database that requires SSL support.

I'm getting this error:

kubectl -n plausible logs plausible-654fd79d98-7ptnt -c plausible-init 
create Plausible.Repo database if it doesn't exist
06:15:41.518 [error] Task #PID<0.166.0> started from #PID<0.204.0> terminating
** (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:169: Postgrex.start_link/1
    (ecto_sql 3.4.4) lib/ecto/adapters/postgres.ex:258: anonymous fn/2 in Ecto.Adapters.Postgres.run_query/2
    (elixir 1.10.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.10.3) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: #Function<7.43614902/0 in Ecto.Adapters.Postgres.run_query/2>
    Args: []
** (MatchError) no match of right hand side value: {:error, "an exception was raised:\n    ** (RuntimeError) SSL connection can not be established because `:ssl` application is not started,\nyou can add it to `extra_application` in your `mix.exs`:\n\n  def application do\n    [extra_applications: [:ssl]]\n  end\n\n        (postgrex 0.15.5) lib/postgrex.ex:554: Postgrex.ensure_deps_started!/1\n        (postgrex 0.15.5) lib/postgrex.ex:169: Postgrex.start_link/1\n        (ecto_sql 3.4.4) lib/ecto/adapters/postgres.ex:258: anonymous fn/2 in Ecto.Adapters.Postgres.run_query/2\n        (elixir 1.10.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2\n        (elixir 1.10.3) lib/task/supervised.ex:35: Task.Supervised.reply/5\n        (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3

It appears that there is a elixir dependency missing for SSL support, from what I take from this error

@ukutaht
Copy link
Contributor

ukutaht commented Oct 7, 2020

Hey! Thanks for reporting.

I've added the ssl app in extra_applications as explained in the error message. The patched image is available as plausible/analytics:dev. Can you run that tag as a test and if it fixes your issue I will push the first patch release with it.

@BobyMCbobs
Copy link
Contributor Author

Hey! Thanks for reporting.

I've added the ssl app in extra_applications as explained in the error message. The patched image is available as plausible/analytics:dev. Can you run that tag as a test and if it fixes your issue I will push the first patch release with it.

Thank you for patching.

I tried with the image plausible/analytics:dev / plausible/analytics@sha256:c52073a862b6b0107d69c4e7de5e2c7f0699626ae95261bd3d6137441328e174. It appears to print the same message

@ukutaht
Copy link
Contributor

ukutaht commented Oct 7, 2020

Thanks for testing. I've managed to reproduce the issue.

I've pushed a fix to the dev tag that works on my setup, can you try again?

@BobyMCbobs
Copy link
Contributor Author

BobyMCbobs commented Oct 7, 2020

I think that your changes have helped.
Now getting a different error

kubectl -n plausible logs plausible-594c9cfbd6-4b85g -c plausible-init
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
19:10:51.857 [error] Clickhousex.Protocol (#PID<0.244.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible doesn't exist (version 20.9.2.20 (official build))\n"
19:10:51.857 [error] Clickhousex.Protocol (#PID<0.245.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible doesn't exist (version 20.9.2.20 (official build))\n"
19:10:53.704 [error] Clickhousex.Protocol (#PID<0.244.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible doesn't exist (version 20.9.2.20 (official build))\n"
19:10:54.646 [error] Clickhousex.Protocol (#PID<0.245.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible doesn't exist (version 20.9.2.20 (official build))\n"
** (MatchError) no match of right hand side value: {:error, "connection not available and request was dropped from queue after 2990ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:\n\n  1. By tracking down slow queries and making sure they are running fast enough\n  2. Increasing the pool_size (albeit it increases resource consumption)\n  3. Allow requests to wait longer by increasing :queue_target and :queue_interval\n\nSee DBConnection.start_link/2 for more information\n"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3

This one's unrelated - it's a Clickhouse error

@ukutaht
Copy link
Contributor

ukutaht commented Oct 9, 2020

Seems like a regular connection error to me. Have you overriden the CLICKHOUSE_DATABASE_URL in plausible-conf.env?

@BobyMCbobs
Copy link
Contributor Author

Seems like a regular connection error to me. Have you overriden the CLICKHOUSE_DATABASE_URL in plausible-conf.env?

The URL is present in the database. The error isn't occurring anymore for some reason. I'm following https://github.com/plausible/hosting/pull/3/files?short_path=d5864cb#diff-c544d0abe757f0dc4a7b1348011b8d0d to set it up

@BobyMCbobs
Copy link
Contributor Author

Hey @ukutaht,

Thank you for your changes.
I can't find them, are they merged in?

@BobyMCbobs
Copy link
Contributor Author

@ukutaht, this issue has come to my attention again.

Many thanks for implementing the change! 🎉
This is a great improvement 😃

@ukutaht
Copy link
Contributor

ukutaht commented Oct 27, 2020

Thanks @BobyMCbobs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants