Skip to content
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

Feat(): Set UNICORN_SIDEKIQ_MAX_RSS env variable #307

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,8 @@ options:
type: string
description: "Throttle level - blocks excessive usage by ip. Accepted values: none, permissive, strict."
default: none
sidekiq_max_memory:
description: Maximum memory for sidekiq in megabytes. This configuration
will set the UNICORN_SIDEKIQ_MAX_RSS environment variable.
type: int
default: 1000
1 change: 1 addition & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ def _create_discourse_environment_settings(self) -> typing.Dict[str, str]:
"DISCOURSE_SMTP_PORT": str(self.config["smtp_port"]),
"DISCOURSE_SMTP_USER_NAME": self.config["smtp_username"],
"RAILS_ENV": "production",
"UNICORN_SIDEKIQ_MAX_RSS": str(self.config["sidekiq_max_memory"]),
}
pod_config.update(self._get_saml_config())

Expand Down
22 changes: 22 additions & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,28 @@ def bundle_handler(args: ops.testing.ExecArgs) -> None:
assert expected_exec_call_was_made


def test_sidekiq_env_variable():
"""
arrange: given a deployed discourse charm with all the required relations
act: trigger the pebble ready event on a leader unit
assert: the pebble plan gets updated
"""
harness = helpers.start_harness(run_initial_hooks=False)

harness.set_can_connect(CONTAINER_NAME, True)
harness.container_pebble_ready(CONTAINER_NAME)
plan_before_set_config = (
harness.get_container_pebble_plan(CONTAINER_NAME).services["discourse"].environment
)
harness.update_config({"sidekiq_max_memory": 500})
plan_after_set_config = (
harness.get_container_pebble_plan(CONTAINER_NAME).services["discourse"].environment
)
assert plan_before_set_config != plan_after_set_config
assert "1000" in plan_before_set_config["UNICORN_SIDEKIQ_MAX_RSS"]
assert "500" in plan_after_set_config["UNICORN_SIDEKIQ_MAX_RSS"]


def test_handle_pebble_ready_event():
"""
arrange: given a deployed discourse charm with all the required relations
Expand Down
Loading