mirror of
https://github.com/MAGICGrants/truenas-apps.git
synced 2026-01-09 20:47:58 -05:00
apps: use the helper method to setup the init container (#3261)
* apps: use the helper method to setup the init container * bump * update lib * update hash * update lib * rest * allow network on some
This commit is contained in:
@@ -12,8 +12,8 @@ icon: https://media.sys.truenas.net/apps/affine/icons/icon.svg
|
||||
keywords:
|
||||
- planning
|
||||
- knowledge base
|
||||
lib_version: 2.1.53
|
||||
lib_version_hash: 87d1db998a9aab3355a78a686d640251822e640125e65ad1237c9902a59e32f1
|
||||
lib_version: 2.1.54
|
||||
lib_version_hash: 84f6b0a92f465357aaea5f1a4742bbcd12cf998cae4614170a0a2503f65809ab
|
||||
maintainers:
|
||||
- email: dev@truenas.com
|
||||
name: truenas
|
||||
@@ -40,4 +40,4 @@ sources:
|
||||
- https://github.com/toeverything/AFFiNE
|
||||
title: AFFiNE
|
||||
train: community
|
||||
version: 1.0.24
|
||||
version: 1.0.26
|
||||
|
||||
@@ -39,10 +39,7 @@
|
||||
{# Migrations #}
|
||||
{% do migrations.depends.add_dependency(values.consts.postgres_container_name, "service_healthy") %}
|
||||
{% do migrations.depends.add_dependency(values.consts.redis_container_name, "service_healthy") %}
|
||||
{% do migrations.restart.set_policy("on-failure", 1) %}
|
||||
{% do migrations.healthcheck.disable() %}
|
||||
{% do migrations.deploy.resources.set_profile("low") %}
|
||||
{% do migrations.remove_devices() %}
|
||||
{% do migrations.setup_as_helper(disable_network=false) %}
|
||||
{% do migrations.set_command(['/bin/sh', '-c', 'node ./scripts/self-host-predeploy.js']) %}
|
||||
|
||||
{% do migrations.environment.add_user_envs(values.affine.additional_envs) %}
|
||||
|
||||
@@ -315,11 +315,14 @@ class Container:
|
||||
def add_usb_bus(self):
|
||||
self.devices.add_usb_bus()
|
||||
|
||||
def setup_as_helper(self):
|
||||
def setup_as_helper(self, profile: str = "low", disable_network: bool = True):
|
||||
self.restart.set_policy("on-failure", 1)
|
||||
self.healthcheck.disable()
|
||||
self.deploy.resources.set_profile("low")
|
||||
self.remove_devices()
|
||||
if profile:
|
||||
self.deploy.resources.set_profile(profile)
|
||||
if disable_network:
|
||||
self.set_network_mode("none")
|
||||
|
||||
def set_shm_size_mb(self, size: int):
|
||||
self._shm_size = size
|
||||
@@ -465,6 +465,48 @@ def test_setup_as_helper(mock_values):
|
||||
c1.setup_as_helper()
|
||||
output = render.render()
|
||||
assert output["services"]["test_container"]["restart"] == "on-failure:1"
|
||||
assert output["services"]["test_container"]["network_mode"] == "none"
|
||||
assert output["services"]["test_container"]["healthcheck"]["disable"] is True
|
||||
assert output["services"]["test_container"]["deploy"]["resources"]["limits"]["cpus"] == "1"
|
||||
assert output["services"]["test_container"]["deploy"]["resources"]["limits"]["memory"] == "512M"
|
||||
assert "devices" not in output["services"]["test_container"]
|
||||
|
||||
|
||||
def test_setup_as_helper_med_profile(mock_values):
|
||||
mock_values["resources"] = {"gpus": {"use_all_gpus": True}}
|
||||
render = Render(mock_values)
|
||||
c1 = render.add_container("test_container", "test_image")
|
||||
c1.setup_as_helper(profile="medium")
|
||||
output = render.render()
|
||||
assert output["services"]["test_container"]["restart"] == "on-failure:1"
|
||||
assert output["services"]["test_container"]["network_mode"] == "none"
|
||||
assert output["services"]["test_container"]["healthcheck"]["disable"] is True
|
||||
assert output["services"]["test_container"]["deploy"]["resources"]["limits"]["cpus"] == "2"
|
||||
assert output["services"]["test_container"]["deploy"]["resources"]["limits"]["memory"] == "1024M"
|
||||
assert "devices" not in output["services"]["test_container"]
|
||||
|
||||
|
||||
def test_setup_as_helper_no_profile(mock_values):
|
||||
mock_values["resources"] = {"gpus": {"use_all_gpus": True}}
|
||||
render = Render(mock_values)
|
||||
c1 = render.add_container("test_container", "test_image")
|
||||
c1.setup_as_helper(profile="")
|
||||
output = render.render()
|
||||
assert output["services"]["test_container"]["restart"] == "on-failure:1"
|
||||
assert output["services"]["test_container"]["network_mode"] == "none"
|
||||
assert output["services"]["test_container"]["healthcheck"]["disable"] is True
|
||||
assert output["services"]["test_container"]["deploy"]["resources"]["limits"]["cpus"] == "2.0"
|
||||
assert output["services"]["test_container"]["deploy"]["resources"]["limits"]["memory"] == "4096M"
|
||||
assert "devices" not in output["services"]["test_container"]
|
||||
|
||||
|
||||
def test_setup_as_helper_with_net(mock_values):
|
||||
mock_values["resources"] = {"gpus": {"use_all_gpus": True}}
|
||||
render = Render(mock_values)
|
||||
c1 = render.add_container("test_container", "test_image")
|
||||
c1.setup_as_helper(disable_network=False)
|
||||
output = render.render()
|
||||
assert output["services"]["test_container"]["restart"] == "on-failure:1"
|
||||
assert output["services"]["test_container"]["healthcheck"]["disable"] is True
|
||||
assert output["services"]["test_container"]["deploy"]["resources"]["limits"]["cpus"] == "1"
|
||||
assert output["services"]["test_container"]["deploy"]["resources"]["limits"]["memory"] == "512M"
|
||||
@@ -12,8 +12,8 @@ icon: https://media.sys.truenas.net/apps/arti/icons/icon.png
|
||||
keywords:
|
||||
- tor
|
||||
- privacy
|
||||
lib_version: 2.1.53
|
||||
lib_version_hash: 87d1db998a9aab3355a78a686d640251822e640125e65ad1237c9902a59e32f1
|
||||
lib_version: 2.1.54
|
||||
lib_version_hash: 84f6b0a92f465357aaea5f1a4742bbcd12cf998cae4614170a0a2503f65809ab
|
||||
maintainers:
|
||||
- email: dev@truenas.com
|
||||
name: truenas
|
||||
@@ -31,4 +31,4 @@ sources:
|
||||
- https://github.com/MAGICGrants/arti-docker
|
||||
title: Arti
|
||||
train: community
|
||||
version: 1.1.17
|
||||
version: 1.1.19
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
{% do config.set_user(values.consts.run_as_user, values.consts.run_as_group) %}
|
||||
{% do config.add_caps(["FOWNER"]) %}
|
||||
{% do config.add_extra_host("host.docker.internal", "host-gateway") %}
|
||||
{% do config.restart.set_policy("on-failure", 1) %}
|
||||
{% do config.healthcheck.disable() %}
|
||||
{% do config.deploy.resources.set_profile("low") %}
|
||||
{% do config.remove_devices() %}
|
||||
{% do config.setup_as_helper(disable_network=false) %}
|
||||
{% do config.configs.add("setup.py", setup_py(values), "/setup.py", "0755") %}
|
||||
{% do config.configs.add("entrypoint.sh", values.consts.config_entrypoint, "/entrypoint.sh", "0755") %}
|
||||
{% do config.set_entrypoint(["/entrypoint.sh"]) %}
|
||||
|
||||
@@ -315,11 +315,14 @@ class Container:
|
||||
def add_usb_bus(self):
|
||||
self.devices.add_usb_bus()
|
||||
|
||||
def setup_as_helper(self):
|
||||
def setup_as_helper(self, profile: str = "low", disable_network: bool = True):
|
||||
self.restart.set_policy("on-failure", 1)
|
||||
self.healthcheck.disable()
|
||||
self.deploy.resources.set_profile("low")
|
||||
self.remove_devices()
|
||||
if profile:
|
||||
self.deploy.resources.set_profile(profile)
|
||||
if disable_network:
|
||||
self.set_network_mode("none")
|
||||
|
||||
def set_shm_size_mb(self, size: int):
|
||||
self._shm_size = size
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user