-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(taskworker): Attempt to add healthcheck logic #583
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,3 +55,6 @@ output/ | |
| # gocd generated output | ||
| gocd/templates/vendor/ | ||
| gocd/generated-pipelines/ | ||
|
|
||
| # uv | ||
| uv.lock | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,14 @@ | |
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| DEFAULT_HEALTH_CHECK_FILE_PATH = "/tmp/health" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there only one worker running per node?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. supposedly the K8s liveness probe needs a static path baked into the pod spec. A PID-based path would break it. And since each pod has its own isolated /tmp, there's no collision risk anyway |
||
|
|
||
|
|
||
NicoHinderling marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @dataclass | ||
| class WorkerConfig: | ||
| rpc_hosts: list[str] | ||
| concurrency: int | ||
| health_check_file_path: str | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def get_worker_config() -> WorkerConfig: | ||
|
|
@@ -34,16 +38,20 @@ def get_worker_config() -> WorkerConfig: | |
| except ValueError: | ||
| raise ValueError(f"LAUNCHPAD_WORKER_CONCURRENCY must be a valid integer, got: {concurrency_str}") | ||
|
|
||
| return WorkerConfig(rpc_hosts=rpc_hosts, concurrency=concurrency) | ||
| health_check_file_path = os.getenv("LAUNCHPAD_WORKER_HEALTH_CHECK_FILE_PATH", DEFAULT_HEALTH_CHECK_FILE_PATH) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here also re maybe needing to include the pid/soem random number |
||
|
|
||
| return WorkerConfig(rpc_hosts=rpc_hosts, concurrency=concurrency, health_check_file_path=health_check_file_path) | ||
|
|
||
|
|
||
| def run_worker() -> None: | ||
| initialize_sentry_sdk() | ||
| config = get_worker_config() | ||
|
|
||
| logger.info(f"Starting TaskWorker (rpc_hosts={config.rpc_hosts}, concurrency={config.concurrency})") | ||
| logger.info( | ||
| f"Starting TaskWorker (rpc_hosts={config.rpc_hosts}, concurrency={config.concurrency}, " | ||
| f"health_check_file_path={config.health_check_file_path})" | ||
| ) | ||
|
|
||
| # TODO: Should we explore setting health_check_file_path for K8s file-based liveness probes (TaskWorker has no HTTP server) | ||
| worker = TaskWorker( | ||
| app_module="launchpad.worker.app:app", | ||
| broker_hosts=config.rpc_hosts, | ||
|
|
@@ -54,6 +62,7 @@ def run_worker() -> None: | |
| rebalance_after=16, | ||
| processing_pool_name="launchpad", | ||
| process_type="forkserver", | ||
| health_check_file_path=config.health_check_file_path, | ||
| ) | ||
|
|
||
| exitcode = worker.start() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want
uv.lockhere long term - I think we should be usinguv.lockbut can do this for now.