Skip to content

nixos/nginx: don't hide nginx config errors on nixos-rebuild --switch with reload enabled - #76179

Merged
danbst merged 8 commits into
NixOS:masterfrom
danbst:nginx-reload-warn-errors
Jan 4, 2020
Merged

danbst merged 8 commits into
NixOS:masterfrom
danbst:nginx-reload-warn-errors

Conversation

@danbst

@danbst danbst commented Dec 22, 2019

Copy link
Copy Markdown
Contributor

Closes #73455

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @domenkozar @Izorkin @aanderse @ckauhaus

@danbst

danbst commented Dec 22, 2019

Copy link
Copy Markdown
Contributor Author

I know about #74072, but I have a test working so it is not blocked by that PR.

@ofborg ofborg Bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Dec 22, 2019

@domenkozar domenkozar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

@danbst

danbst commented Dec 23, 2019

Copy link
Copy Markdown
Contributor Author

@Mic92 you are right, the systemctl reload was redundant. However I now changed it a bit - it doesn't reload nginx, but only checks config file for errors.

The reason I still do systemctl reload is to create an entry in log file for nginx.service:

# journalctl -u nginx | tail -n2
Dec 23 09:35:07 c1 systemd[1]: Reloading Nginx Web Server.
Dec 23 09:35:07 c1 systemd[1]: Reloaded Nginx Web Server.

I can implement that with running logger manually from reload script. Do you think it is better to run logger explicitly, rather than relying on systemd reload?

I also removed stopIfChanged = false;. Due to how nixos activation works, on nginx confiuration change it tries to a) restart nginx-config-reload.service and b) start multi-user.target. If there is an error in config, it will fail twice - first time during restart, second time during start, because those are done as separate systemctl commands. In some cases (DNS lookup error) this may cause very long activation delay.

However, if unit is stopped first, then activate starts both nginx-config-reload.service and multi-user.target together, which produces only one failure.

@ckauhaus

ckauhaus commented Jan 2, 2020

Copy link
Copy Markdown
Contributor

@danbst Looks good to me. Please rebase to current master.

@danbst
danbst merged commit cef68c4 into NixOS:master Jan 4, 2020
@danbst
danbst deleted the nginx-reload-warn-errors branch January 4, 2020 22:39
@danbst

danbst commented Jan 4, 2020

Copy link
Copy Markdown
Contributor Author

@domenkozar @ckauhaus what do you think, this has to be backported to 19.09? I believe it should, but I need confirmation

@domenkozar

Copy link
Copy Markdown
Member

Yup.

dtzWill pushed a commit to dtzWill/nixpkgs that referenced this pull request Jan 16, 2020
… with reload enabled (NixOS#76179)

nixos/nginx: don't hide nginx config errors on nixos-rebuild --switch
with reload enabled

Closes NixOS#73455

(cherry picked from commit cef68c4)
dtzWill pushed a commit to dtzWill/nixpkgs that referenced this pull request Mar 31, 2020
… with reload enabled (NixOS#76179)

nixos/nginx: don't hide nginx config errors on nixos-rebuild --switch
with reload enabled

Closes NixOS#73455

(cherry picked from commit cef68c4)
Comment on lines +721 to 724
${execCommand} -t && \
${pkgs.systemd}/bin/systemctl reload nginx.service
fi
'';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line breaks nginx. It causes directories in /var/cache/nginx/ to be owned by nobody, which breaks large POST uploads. I think this might due the fact that nginx is no longer started as root. cc @Izorkin

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#85820 - fix variant and #85820 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I have a simpler version. Will post.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nginx reloading is bad UX

6 participants