-
-
Notifications
You must be signed in to change notification settings - Fork 881
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
Issue with run files for nginx start with system start #1372
Comments
Related PR #1352 (comment) |
The discussion of this seems to have mostly happened over in #1352. I think it belongs here so I'll try to summarize the points from there. Prior Discussion
Workaround 1#1352 (comment) contains a suggested workaround, namely to add two lines to [Service]
RuntimeDirectory=nginx In #1352 (comment), @smortex points out that this will result in a non-converging configuration where Puppet will "fight" the system. I would add that the existence and location of Workaround 2Use version 1.1.0 and undo the effect of #1352: file { '/var/nginx' :
ensure => 'directory',
group => 'root',
mode => '0644',
}
class { '::nginx':
client_body_temp_path => '/var/nginx/client_body_temp',
proxy_temp_path => '/var/nginx/proxy_temp',
require => File['/var/nginx'],
} Possible Solutions
I'd be happy to help with a solution but I could use some guidance from maintainers as to what's the preferred path forward. Personally, I don't know how to do (1), (2) means this package will be broken until an unknown date, and (3) would mean stepping on @anarcat's toes pretty hard which I with my grand total of zero commits to this project certainly have no authority or desire to do. |
awesome, thanks for summarizing this so accurately! :) i do agree it would be too bad to revert #1352... we don't we just a systemd override for now (1), that seems the simplest... we don't depend on the systemd module yet, but that would not be a big hurdle to cross. i don't think (2) is really an option in the short term - it will take time to update the debian package... |
@anarcat Can you elaborate a little more on how this would work? A few specific questions I was wondering about while thinking this through:
|
You're right this might be too invasive. I'm starting to be convinced this could be rolled back and pushed into my profile instead. Feel free to revert, but i will note that the previous value for this was |
Not sure whether I'm telling things everybody is already familiar with, but in case not: systemd scans a lot of directories for unit configurations, see man systemd.unit. a systemd override in a directory If the meaningful_name is chosen carefully, this is an as-subtile-as-possible fix imho with a low chance to mess up existing configurations. I think (but am not completely sure) So the module needs to ensure the directory
I don't think it's necessary to use the camptocamp/systemd module (and risk dependency problems) for this as we would only ensure one directory and one file (you could even make the filename (not the dirname) configurable via a param, or allow to disable creating the systemd override). I agree overwriting the whole systemd config for nginx might be a bit invasive, but doing it by the override as proposed by @anarcat would leave the rest of the ngix config alone and fix only the reboot bug. It might be a good idea to avoid the fight over file permissions pointed out by @smortex in his 1352 comment by checking whether the module could switch to a 0700 umask for the |
Running into this too, adding the At least in my situation, I'm running Bolt not full blown puppet, so I'm not worried about Puppet 'fighting' the config. |
This also work if you still want to be in tmpfs /run and not change systemd or go back to /var. client_body_temp_path => "/run/nginx_client_body_temp",
proxy_temp_path => "/run/nginx_proxy_temp", |
I would propose to revert the change #1352 because of following reasons:
|
FWIW, #1352 didn't just move from /var/run to /run, it moved from So I think that, after @SebastianJ91's comment, i'd be okay with a patch changing the path (again), but please don't put it in |
@anarcat FYI,
A systemd drop-in is a clean way to work around the problem: file { '/etc/systemd/system/nginx.service.d/override.conf':
ensure => file,
owner => 0,
group => 0,
mode => '0644',
content => "[Service]\nRuntimeDirectory=nginx\n",
notify => [
Exec['daemon-reload'],
Service['nginx'],
]
} |
I should have looked into the open issues first ... anyway, here is my workaround, in hiera: nginx::run_dir: /tmp/
nginx::client_body_temp_path: /tmp/nginx-client_body_temp
nginx::proxy_temp_path: /tmp/nginx-proxy_temp_path Because temp data should probably be in /tmp? It would be nicer to have /tmp/nginx as the run-dir instead of /tmp - but as some systems have /tmp set up as a tmpfs, it would be the same problem as with /run. The run-dir construct is a bit weird, it is only used for setting the default values for nginx::client_body_temp_path and nginx::proxy_temp_path (and to me those looks more fitting to belong under a tmp_dir than a run_dir), but setting nginx::run_dir does not help, those two variables have the default value rooted in nginx::params::run_dir rather than nginx::run_dir. |
I just ran into this too. 😒 This is a particularly nasty bug because you don’t know that there’s a problem until your first reboot, and your nginx doesn’t start. I'm using the systemd dropin file workaround in my nginx profile: systemd::dropin_file { 'runtimedirectory.conf':
unit => 'nginx.service',
content => @(EOT),
# Managed by Puppet
[Service]
RuntimeDirectory=nginx
| EOT
} Can we agree on this as a fix? |
I have eventually concluded that the best fix (for this and multiple other problems) is to use package/service pattern and avoid using voxpupuli-nginx. :-( |
…tional The [general description of `/run/`](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html) is fairly vague and not in the original spec however my high level reading is that it relates more to small files which are used for service orchestration and not data (temporary or otherwise) which is specific to the programs operations for the later /var/lib which states the following seems more appropriate: > Furthermore, this hierarchy holds state information pertaining to an application .... State information is data that programs modify while they run, and that pertains to one specific host. https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/Linux-Filesystem-Hierarchy.html#var And as we see from the [debian packages](https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/rules#L61-63) this is the route they have gone (and likely don't consider this a bug). although it is worth noting they only override this only for the full package, the light package keeps the default which ends up being `--prefix` and thus `/usr/share/nginx/client_temp/`. Of course there is a performance argument to make that says theses files should be in a ramdisk, however its also possible that this dir could become very large and putting it in a ramdisk could cause swapping or other system issues as such i think this decision should be left to the operator with sane defaults provided by the package maintain As run_dir is only ever used for setting `proxy_temp_path` and `client_body_temp_path` i suggest that we completely drop run_dir and make `client_body_temp_path` and `proxy_temp_path` optional, thus ensuring the configuration uses the distro configured defaults. if we don't want to use the package defaults then we should ensure we ensure things work correctly annd in this case i think using the systemd dropin would make the most senses Fixes #1372
tl;dr i think by default we should set proxy_temp_path and client_body_temp_path to undef and let the defaults chosen by the package maintainers take precedence #1478 i just came across this and i think the main issue here is the assumption that now the general description of
https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/Linux-Filesystem-Hierarchy.html#var And as we see from the debian packages this is the route they have gone (and likely don't consider this a bug). although it is worth noting they only override this only for the full package, the light package keeps the default which ends up being Of course there is a performance argument to make that says theses files should be in a ramdisk, however its also possible that this dir could become very large and putting it in a ramdisk could cause swapping or other system issues as such i think this decision should be left to the operator with sane defaults provided by the package maintain As run_dir is only ever used for setting |
I would be in favor of that. At least in the default nginx config on Debian 10 & 11 and CentOS 7 & 8 (via EPEL) these options are not present at all. Making them optional would move it closer to the distro default packaging which I generally feel like is a sane default. |
…tional The [general description of `/run/`](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html) is fairly vague and not in the original spec however my high level reading is that it relates more to small files which are used for service orchestration and not data (temporary or otherwise) which is specific to the programs operations for the later /var/lib which states the following seems more appropriate: > Furthermore, this hierarchy holds state information pertaining to an application .... State information is data that programs modify while they run, and that pertains to one specific host. https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/Linux-Filesystem-Hierarchy.html#var And as we see from the [debian packages](https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/rules#L61-63) this is the route they have gone (and likely don't consider this a bug). although it is worth noting they only override this only for the full package, the light package keeps the default which ends up being `--prefix` and thus `/usr/share/nginx/client_temp/`. Of course there is a performance argument to make that says theses files should be in a ramdisk, however its also possible that this dir could become very large and putting it in a ramdisk could cause swapping or other system issues as such i think this decision should be left to the operator with sane defaults provided by the package maintain As run_dir is only ever used for setting `proxy_temp_path` and `client_body_temp_path` i suggest that we completely drop run_dir and make `client_body_temp_path` and `proxy_temp_path` optional, thus ensuring the configuration uses the distro configured defaults. if we don't want to use the package defaults then we should ensure we ensure things work correctly annd in this case i think using the systemd dropin would make the most senses This CR also adds resources to manage the creation of proxy_cache_path and fastcgi_cache_path directories Fixes #1372
I too ran into this when upgrading from a very old version of the puppetforge module. Regarding all different workarounds, I dislike the one above, since it adds a dependency to another puppet module. |
Affected Puppet, Ruby, OS and module versions/distributions
What are you seeing
The latest upgrade to this module may have broken the nginx service startup process when rebooting server. After a server reboot the nginx status reads as
nginx.service - nginx - high performance web server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2020-02-05 15:17:34 AEDT; 7min ago Docs: http://nginx.org/en/docs/ Process: 664 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
Feb 05 15:17:33 jamfp02 systemd[1]: Starting nginx - high performance web server... Feb 05 15:17:34 jamfp02 nginx[664]: nginx: [emerg] mkdir() "/run/nginx/client_body_temp" failed (2: No such file or directory) Feb 05 15:17:34 jamfp02 systemd[1]: nginx.service: Control process exited, code=exited status=1 Feb 05 15:17:34 jamfp02 systemd[1]: nginx.service: Failed with result 'exit-code'. Feb 05 15:17:34 jamfp02 systemd[1]: Failed to start nginx - high performance web server.
When puppet runs it fixes things and this is the output.
Info: Using configured environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Retrieving locales Info: Loading facts Info: Caching catalog for jamfp02.svi.edu.au Info: Applying configuration version '1580876853' Info: /Stage[main]/Ntp::Service/Service[ntp]: Unscheduling refresh on Service[ntp] Notice: /Stage[main]/Nginx::Config/File[/run/nginx]/ensure: created (corrective) Notice: /Stage[main]/Nginx::Config/File[/run/nginx/client_body_temp]/ensure: created (corrective) Notice: /Stage[main]/Nginx::Config/File[/run/nginx/proxy_temp]/ensure: created (corrective) Info: Class[Nginx::Config]: Scheduling refresh of Class[Nginx::Service] Info: Class[Nginx::Service]: Scheduling refresh of Service[nginx] Notice: /Stage[main]/Nginx::Service/Service[nginx]/ensure: ensure changed 'stopped' to 'running' (corrective) Info: /Stage[main]/Nginx::Service/Service[nginx]: Unscheduling refresh on Service[nginx]
What behaviour did you expect instead
I expected the nginx process to start at startup before a puppet run corrects things.
The text was updated successfully, but these errors were encountered: