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

add setting for client to update wireguard port. #46

Merged
merged 1 commit into from
Sep 2, 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
1 change: 1 addition & 0 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ The `backend` code houses the `scheduler` and the `RESTful API`. The following e
- `DOCKER_API_RETRIES`: how many times to retry requests to the Docker daemon
- `DOCKER_API_RETRY_DURATION`: how long to wait before retrying a failed request
- `WIREGUARD_IMAGE`
- `WIREGUARD_PORT`: port for routing wireguard traffic in the wireguard container. This is not the exposed port.
- `WIREGUARD_KERNEL_MODULES`: where to load wireguard kernel modules from (default `/lib/modules`)
- `WIREGUARD_HEALTHCHECK_INTERVAL_SECONDS`
- `WIREGUARD_HEALTHCHECK_TIMEOUT_SECONDS`
Expand Down
1 change: 1 addition & 0 deletions worker/manager/src/mirrors_qa_manager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Settings:
WIREGUARD_CONTAINER_NAME = getenv(
"WIREGUARD_CONTAINER_NAME", default="mirrors-qa-wireguard"
)
WIREGUARD_PORT = int(getenv("WIREGUARD_PORT", default=51820))
# Optional path for loading kernel modules for wireguard container
WIREGUARD_KERNEL_MODULES_FPATH = Path(
getenv("WIREGUARD_KERNEL_MODULES", default="/lib/modules")
Expand Down
12 changes: 7 additions & 5 deletions worker/manager/src/mirrors_qa_manager/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import signal
import sys
import time
from collections.abc import Iterable
from collections.abc import Generator
from enum import Enum
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -131,8 +131,8 @@ def wg_container_is_healthy(self) -> ExecResult | None:
Settings.WIREGUARD_CONTAINER_NAME,
self.wg_healthcheck_cmd,
)
except APIError:
logger.error("error whlie performing healthcheck: {exc!s}")
except APIError as exc:
logger.error(f"error whlie performing healthcheck: {exc!s}")
return None

def wg_healthcheck_untill_healthy(
Expand Down Expand Up @@ -201,7 +201,9 @@ def start_wireguard_container(self, image_name: str, conf_fpath: Path) -> Contai
"timeout": Settings.WIREGUARD_HEALTHCHECK_TIMEOUT_NANOSECONDS,
"retries": Settings.WIREGUARD_HEALTHCHECK_RETRIES,
},
ports={"51820/udp": None}, # Let the host assign a random port
ports={
f"{Settings.WIREGUARD_PORT}/udp": None
}, # Let the host assign a random port
sysctls={"net.ipv4.conf.all.src_valid_mark": 1},
environment={
"PUID": 1000,
Expand Down Expand Up @@ -292,7 +294,7 @@ def update_countries_list(self):
"countries."
)

def fetch_tests(self) -> Iterable[dict[str, str]]:
def fetch_tests(self) -> Generator[dict[str, str], None, None]:
logger.debug("Fetching tasks from backend API")
# Fetch tasks that were assigned to the worker that haven't been expired
params = urlencode({"worker_id": self.worker_id, "status": "PENDING"})
Expand Down
Loading