-
Notifications
You must be signed in to change notification settings - Fork 339
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: listen_addresses no longer sets PGHOST #1374
Comments
@DGollings, But I'm surprised to hear that the socket directory doesn't work for you. I wonder if it's because of the systemd service or the runner. For example, It might be a sign that we need to detect and use It's tough for us to document these things right now, because it's just an env var. We'll soon have a place to do so per service, language, etc. cc @k3yss |
what makes which makes setting it from devenv without being able to override it (easily) a little problematic :) It is however true that the root issue is likely the whole
? |
{ pkgs, lib, config, inputs, ... }:
{
services.postgres.enable = true;
env.PGHOST = "custom-pg-host";
} I can easily override it like this, does this not work for you? While sending the patch you mentioned before I was expecting people to change their |
You might be over estimating the average nix user. Was not aware that that would override the other value. But thanks, good to know, it'll make it easy to remove my workaround :) |
I am working on the new documentation here to resolve this exact issue, we can include a small guide in it on how to use postgres with devenv : )
The default value that we are setting for the |
Oh no, there's two issues here. One being But the other issue is that your default, and I believe you if you say it's a good default, for whatever reaso, does not play nicely with systemd and devenv shell combined (we think) The driver is not the issue, nor does it depend on localhost being the value. That's just a symptom As mentioned, I'd be happy to help debug? |
That would be awesome! I don't have any experience with systemd, but if you could provide detailed steps on how to create a reproducible setup of the problem and share some logs, I'd be happy to take a look. |
Sure, how does this sound? #1374 (comment) |
What I want to know is the step before these, specifically how to provision the CI environment locally and the steps how I would reproduce the error. |
If you happen to run NixOS it should be easy enough to set up your own version of this: github-runners = {
runner = {
name = config.networking.hostName;
user = *youruser*;
enable = true;
replace = true;
url = "redacted";
tokenFile = *github token runner file*;
extraPackages = with pkgs;
[
devenv
bash
# any other dependency you might want to add
];
extraEnvironment = {
NIXPKGS_ALLOW_UNFREE = "1";
JAVA_HOME = "${pkgs.openjdk}";
};
serviceOverrides = {
ProtectProc = "default";
ProtectSystem = "full";
};
};
}; if not, the above pretty much is a systemd service, which you could install like this As to how to reproduce in more detail, these steps work: processes = {
phoenix.exec = ''
# sets up db automatically
until psql -U "postgres" -c '\q' 2>/dev/null; do
sleep 1
done
mix ecto.setup
mix phx.server
'';
}; These are run by neither What does not work is this: - name: Build the devenv shell and run any pre-commit hooks
run: devenv shell mix check which is running the same Postgrex/Ecto-like code as in |
Describe the bug
After updating from devenv 1.0.2 to 1.0.8 we could no longer connect to our database during CI tests. After extensive debugging (mostly because I knew nothing about
PGHOST
) it was determined to be caused by this changegit diff v1.0.7..v1.0.8 src/modules/services/postgres.nix
In our CI it never quite worked until I set listen_addresses to "127.0.0.1", although I did not quite understnad at the time why
To be honest, I think how we fixed it merely worked around a different issue. The issue being that we run our CI on NixOS github runners which has a particular
runtimeDir
which is then overridden when we usedevenv shell
within that same environment. This manifests itself in the sense thatpsql
works duringdevenv process
but at some point thePGHOST
(orruntimeDir
) is changed againfrom memory,
/var/run/1000/devenv/something_socket
vs/tmp/devenv/something_socket
the current 'fix' I have now is setting
in our runtime config. Which should speak for itself
Anyway, this still raises a different question as to why is
PGHOST
currently 'hardcoded' or even set at all, with no clear way to override. Could it be that the previous code was better? Apart from thelisten_addreses = "*"
issue I believe was the cause of this change?Version
1.0.7 and 1.0.8
The text was updated successfully, but these errors were encountered: