docs(worker): document SIENTIA_RUNTIME_READY, log the skipped install, test install failure (SIENTIAPDE-2214)
From the code-review-python pass on #34: - README, CLAUDE.md and the module docstring: the worker re-executes itself after install_runtime, and SIENTIA_RUNTIME_READY is internal; setting it in .env/the chart would skip the install silently. - "Installing runtime" is now logged only on the pass that installs; the re-executed pass logs that the install was skipped. - The ponytail comment notes that the install success metrics are lost to the exec. - New test: a failed install propagates without setting the flag or calling os.execv (locks the install -> flag -> exec order).
This commit is contained in:
@@ -21,6 +21,8 @@ Environment Variables:
|
||||
- TEMPORAL_NAMESPACE: Temporal namespace (default: model-manager)
|
||||
- TEMPORAL_USE_TLS: Enable TLS for Temporal connection (default: false)
|
||||
- RUNTIME: Runtime identifier used in queue naming (default: single)
|
||||
- SIENTIA_RUNTIME_READY: Internal, set by the worker itself before re-executing after
|
||||
install_runtime. Never set it in the deployment: it skips the runtime install.
|
||||
- POD_ID: Kubernetes pod identifier for metrics
|
||||
- HTTP_METRICS_PORT: Prometheus metrics server port (default: 9090)
|
||||
- HTTP_SDK_METRICS_PORT: Temporal SDK metrics port (default: 9091)
|
||||
@@ -127,8 +129,6 @@ async def main():
|
||||
|
||||
metrics_controller = MetricsController(logger=logger)
|
||||
|
||||
logger.custom_info(f'Installing runtime {runtime}', metadata)
|
||||
|
||||
plugin_store_parameters = build_plugin_store_config()
|
||||
plugin_store = PluginStore(
|
||||
base_url=plugin_store_parameters['base_url'],
|
||||
@@ -147,11 +147,18 @@ async def main():
|
||||
)
|
||||
|
||||
if os.environ.get('SIENTIA_RUNTIME_READY') != '1':
|
||||
logger.custom_info(f'Installing runtime {runtime}', metadata)
|
||||
await plugin_store.install_runtime(runtime_name=runtime)
|
||||
os.environ['SIENTIA_RUNTIME_READY'] = '1'
|
||||
logger.custom_info(f'Runtime {runtime} installed, re-executing worker', metadata)
|
||||
# ponytail: fresh interpreter so loaded modules match the runtime on disk (SIENTIAPDE-2214)
|
||||
# ponytail: fresh interpreter so loaded modules match the runtime on disk (SIENTIAPDE-2214).
|
||||
# The install_runtime success metrics (count/lag) are lost to the exec; no dashboard uses them.
|
||||
os.execv(sys.executable, [sys.executable, *sys.orig_argv[1:]]) # noqa: S606
|
||||
else:
|
||||
logger.custom_info(
|
||||
f'SIENTIA_RUNTIME_READY=1, runtime {runtime} already installed, skipping install',
|
||||
metadata,
|
||||
)
|
||||
|
||||
activities = Activities(
|
||||
postgres_config=build_postgres_config(),
|
||||
|
||||
Reference in New Issue
Block a user