nixpkgs/nixos/doc/manual
Oliver Schmidt e362fe9c6d security/acme: limit concurrent certificate generations
fixes #232505

Implements the new option `security.acme.maxConcurrentRenewals` to limit
the number of certificate generation (or renewal) jobs that can run in
parallel. This avoids overloading the system resources with many
certificates or running into acme registry rate limits and network
timeouts.

Architecture considerations:
- simplicity, lightweight: Concerns have been voiced about making this
  already rather complex module even more convoluted. Additionally,
  locking solutions shall not significantly increase performance and
  footprint of individual job runs.
  To accomodate these concerns, this solution is implemented purely in
  Nix, bash, and using the light-weight `flock` util. To reduce
  complexity, jobs are already assigned their lockfile slot at system
  build time instead of dynamic locking and retrying. This comes at the
  cost of not always maxing out the permitted concurrency at runtime.
- no stale locks: Limiting concurrency via locking mechanism is usually
  approached with semaphores. Unfortunately, both SysV as well as
  POSIX-Semaphores are *not* released when the process currently locking
  them is SIGKILLed. This poses the danger of stale locks staying around
  and certificate renewal being blocked from running altogether.
  `flock` locks though are released when the process holding the file
  descriptor of the lock file is KILLed or terminated.
- lockfile generation: Lock files could either be created at build time
  in the Nix store or at script runtime in a idempotent manner.
  While the latter would be simpler to achieve, we might exceed the number
  of permitted concurrent runs during a system switch: Already running
  jobs are still locked on the existing lock files, while jobs started
  after the system switch will acquire locks on freshly created files,
  not being blocked by the still running services.
  For this reason, locks are generated and managed at runtime in the
  shared state directory `/var/lib/locks/`.

nixos/security/acme: move locks to /run

also, move over permission and directory management to systemd-tmpfiles

nixos/security/acme: fix some linter remarks in my code

there are some remarks left for existing code, not touching that

nixos/security/acme: redesign script locking flow

- get rid of subshell
- provide function for wrapping scripts in a locked environment

nixos/acme: improve visibility of blocking on locks

nixos/acme: add smoke test for concurrency limitation

heavily inspired by m1cr0man

nixos/acme: release notes entry on new concurrency limits

nixos/acme: cleanup, clarifications
2023-09-09 20:13:18 +02:00
..
administration nixos/manual: Add chapter about instance unit overrides 2023-08-13 14:40:25 +02:00
configuration nixos/manual: rename references to services.udev.initrdRules 2023-06-27 14:36:49 +02:00
development nixos/stc: Improve mount unit handling 2023-08-21 09:07:14 +02:00
installation Merge pull request #232491 from 6t8k/20230517_nixos_manual_installing_partitioning 2023-07-26 15:12:51 +02:00
release-notes security/acme: limit concurrent certificate generations 2023-09-09 20:13:18 +02:00
common.nix nixos manual: extract some build paths 2023-07-25 17:03:12 +07:00
contributing-to-this-manual.chapter.md Merge pull request #248701 from doronbehar/nixos/manpages 2023-08-16 15:49:49 +00:00
default.nix nixos/doc: small rephrase in documentation of documentation 2023-08-16 06:24:37 +00:00
manual.md nixos/manual: render html with nixos-render-doc if !allowDocBook 2023-02-21 18:26:41 +01:00
nixos-options.md nixos-render-docs: add structural includes, use for manual 2023-02-12 13:02:42 +01:00
preface.md manual: fix matrix room link (#231523) 2023-05-12 18:55:19 -04:00
README.md
shell.nix nixpkgs/NixOS manuals: devmode feature 2023-07-25 17:03:15 +07:00