NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.04k stars 14.09k forks source link

systemd: systemd-journal-gatewayd.socket exists but is invalid when services.journald.enableHttpGateway = false #62766

Open arianvp opened 5 years ago

arianvp commented 5 years ago

Issue description

We load an invalid unit when enableHttpGateway = false

The cause:

  1. We do not include the upstream unit when it is disabled (https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/systemd.nix#L162)

  2. This line creates an empty unit when enableHttpGateway is false. This should be fine if the upstream unit exist, as we will generate an empty override unit, but because the upstream unit doesn't exist when enableHttpGateway = false we create a new empty unit which has invalid contents, instead of overriding an existing unit with no new information

Potential Fix

Two options:

  1. Always include the upstream unit, but only have the optional wantedBy = "sockets.target <-- I prefer this one

  2. Bubble up the conditional, such that we do not create an empty systemd-journal-gatewayd unit:

systemd.sockets = mkIf (enaleHttpGateway) { sockets.systemd-journal-gatewayd.wantedBy = "sockets.target"; }

Steps to reproduce

[arian@t430s:/var/lib/machines/nginx/etc]$ systemctl status systemd-journal-gatewayd.socket 
● systemd-journal-gatewayd.socket
   Loaded: bad-setting (Reason: Unit systemd-journal-gatewayd.socket has a bad unit file setting.)
   Active: inactive (dead)

Jun 06 12:10:45 t430s systemd[1]: systemd-journal-gatewayd.socket: Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing.

[arian@t430s:/var/lib/machines/nginx/etc]$ systemctl cat systemd-journal-gatewayd.socket 
# /nix/store/kjdfr6g1yzwrhql726hiaghab4lwhwjb-unit-systemd-journal-gatewayd.socket/systemd-journal-gatewayd.socket
[Unit]

[Socket]

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the results.

flokli commented 4 years ago

@arianvp is this still applicable?

I'd personally be more in favour of option 2, and moving journal-gateway-specific stuff into a separate .nix file, similar to how it was handled with https://github.com/NixOS/nixpkgs/pull/87742.

arianvp commented 4 years ago

It still is! Assign it to me. I'll make a PR

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

flokli commented 3 years ago

@arianvp poke ;-)

tv42 commented 3 years ago

For anyone else stumbling on this, the option is called services.journald.enableHttpGateway = true now.

flokli commented 3 years ago

@tv42 But the bug still applies, right?

tv42 commented 3 years ago

@flokli I can't comment on that. After reading about the gateway, I realized it's not what I was looking for.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info