Skip to content

Conversation

@agners
Copy link
Member

@agners agners commented Sep 24, 2025

Proposed change

This PR adds support for configurable ulimits (resource limits) in addon configuration. Add-ons can now specify ulimits in their config.yaml to control system resource limits such as open files, processes, memory locks, and other kernel resource limits.

The implementation supports both simple format:

ulimits:
  nofile: 65535

And detailed format for fine-grained control over soft and hard limits:

ulimits:
  nofile:
    soft: 20000
    hard: 40000

This is e.g. useful for the InfluxDB add-on. InfluxDB does not have options to raise the limit in its configuration. See also hassio-addons/addon-influxdb#383 and influxdata/influxdb#16065.

Type of change

  • New feature (which adds functionality to the supervisor)

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to cli pull request:
  • Link to client library pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Ruff (ruff format supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints or add-on configuration are added/changed:

Similar to docker-compose, this adds support for setting ulimits
for addons via the addon config. This is useful e.g. for InfluxDB
which on its own does not support setting higher open file descriptor
limits, but recommends increasing limits on the host.
@agners agners added missing-documentation Added to pull requests that needs a docs, but none is linked new-feature A new feature and removed cla-signed labels Sep 24, 2025
@agners agners requested a review from sairon September 24, 2025 09:26
@agners
Copy link
Member Author

agners commented Sep 24, 2025

So far we relied on the application to raise the limit itself (e.g. Core and Frigate. But setting this as part of the add-on configuration seems a bit less invasive for application which don't support raising on their own, and aligns with what Docker/ Docker compose offers.

@agners
Copy link
Member Author

agners commented Oct 1, 2025

I do run into issues on my Supervised based installation:

Can't start addon_local_ssh: 500 Server Error for http+docker://localhost/v1.51/containers/463601d793353126b377afc6dff3a7ab62338ed4620f22ebbc13bd40cba26a05/start: Internal Server Error ("failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error setting rlimits for ready process: error setting rlimit type 7: operation not permitted: unknown")

But that seems to be really a problem with the underlying

$ docker run -it --rm --ulimit nofile=50000000 alpine /bin/sh -c "ulimit -a"
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error setting rlimits for ready process: error setting rlimit type 7: operation not permitted: unknown

Run 'docker run --help' for more information

It seems to be a problem as soon as I try to raise the limit higher than the default 1048576. Not sure if this is a containerd 1.7.x linage limitation 🤔 .

@agners agners marked this pull request as ready for review October 1, 2025 10:02
@frenck frenck requested a review from Copilot October 1, 2025 17:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for configurable ulimits (user limits) in add-on configuration, allowing add-ons to specify system resource limits such as open files, processes, and memory locks. The implementation supports both simple format (single value for both soft and hard limits) and detailed format (separate soft and hard limits).

  • Adds ulimits configuration option to add-on schema validation with support for both simple and detailed formats
  • Integrates ulimits into the Docker container creation process, combining with existing realtime ulimits
  • Comprehensive test coverage for validation logic and Docker integration

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
supervisor/const.py Adds ATTR_ULIMITS constant for configuration attribute
supervisor/addons/validate.py Implements schema validation for ulimits configuration supporting both simple and detailed formats
supervisor/addons/model.py Adds ulimits property to Addon model for accessing configuration
supervisor/docker/addon.py Integrates ulimits into Docker container creation, merging with existing realtime limits
tests/addons/test_config.py Adds comprehensive validation tests for ulimits configuration formats
tests/docker/test_addon.py Tests Docker integration including interaction with realtime ulimits

Copy link
Member

@sairon sairon left a comment

Choose a reason for hiding this comment

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

Nice and clean, thanks!

@agners agners merged commit 53a8044 into main Oct 8, 2025
24 checks passed
@agners agners deleted the add-support-for-ulimit-in-addon-config branch October 8, 2025 10:43
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2025
@agners agners removed the missing-documentation Added to pull requests that needs a docs, but none is linked label Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants