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: Add temporal client rpc timeout #543

Merged
merged 3 commits into from
Nov 23, 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
40 changes: 21 additions & 19 deletions deployments/aws/fargate/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,33 @@ locals {

api_env = [
for k, v in merge({
LOG_LEVEL = var.log_level
TRACECAT__API_URL = local.internal_api_url
TRACECAT__API_ROOT_PATH = "/api"
TRACECAT__APP_ENV = var.tracecat_app_env
TRACECAT__PUBLIC_RUNNER_URL = local.public_api_url
TRACECAT__PUBLIC_APP_URL = local.public_app_url
TRACECAT__ALLOW_ORIGINS = local.allow_origins
TRACECAT__AUTH_TYPES = var.auth_types
TEMPORAL__CLUSTER_URL = local.temporal_cluster_url
TEMPORAL__CLUSTER_QUEUE = local.temporal_cluster_queue
SAML_SP_ACS_URL = local.saml_acs_url
RUN_MIGRATIONS = "true"
LOG_LEVEL = var.log_level
TRACECAT__API_URL = local.internal_api_url
TRACECAT__API_ROOT_PATH = "/api"
TRACECAT__APP_ENV = var.tracecat_app_env
TRACECAT__PUBLIC_RUNNER_URL = local.public_api_url
TRACECAT__PUBLIC_APP_URL = local.public_app_url
TRACECAT__ALLOW_ORIGINS = local.allow_origins
TRACECAT__AUTH_TYPES = var.auth_types
TEMPORAL__CLUSTER_URL = local.temporal_cluster_url
TEMPORAL__CLUSTER_QUEUE = local.temporal_cluster_queue
TEMPORAL__CLIENT_RPC_TIMEOUT = var.temporal_client_rpc_timeout
SAML_SP_ACS_URL = local.saml_acs_url
RUN_MIGRATIONS = "true"
}, local.tracecat_db_configs) :
{ name = k, value = tostring(v) }
]

worker_env = [
for k, v in merge({
LOG_LEVEL = var.log_level
TRACECAT__API_URL = local.internal_api_url
TRACECAT__API_ROOT_PATH = "/api"
TRACECAT__APP_ENV = var.tracecat_app_env
TRACECAT__PUBLIC_RUNNER_URL = local.public_api_url
TEMPORAL__CLUSTER_URL = local.temporal_cluster_url
TEMPORAL__CLUSTER_QUEUE = local.temporal_cluster_queue
LOG_LEVEL = var.log_level
TRACECAT__API_URL = local.internal_api_url
TRACECAT__API_ROOT_PATH = "/api"
TRACECAT__APP_ENV = var.tracecat_app_env
TRACECAT__PUBLIC_RUNNER_URL = local.public_api_url
TEMPORAL__CLUSTER_URL = local.temporal_cluster_url
TEMPORAL__CLUSTER_QUEUE = local.temporal_cluster_queue
TEMPORAL__CLIENT_RPC_TIMEOUT = var.temporal_client_rpc_timeout
}, local.tracecat_db_configs) :
{ name = k, value = tostring(v) }
]
Expand Down
5 changes: 5 additions & 0 deletions deployments/aws/fargate/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ variable "temporal_memory" {
default = "512"
}

variable "temporal_client_rpc_timeout" {
type = string
description = "RPC timeout for Temporal client in seconds"
}

variable "caddy_cpu" {
type = string
default = "256"
Expand Down
2 changes: 2 additions & 0 deletions tracecat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@
TEMPORAL__TLS_ENABLED = os.environ.get("TEMPORAL__TLS_ENABLED", False)
TEMPORAL__TLS_CLIENT_CERT = os.environ.get("TEMPORAL__TLS_CLIENT_CERT")
TEMPORAL__TLS_CLIENT_PRIVATE_KEY = os.environ.get("TEMPORAL__TLS_CLIENT_PRIVATE_KEY")
TEMPORAL__CLIENT_RPC_TIMEOUT = os.environ.get("TEMPORAL__CLIENT_RPC_TIMEOUT")
"""RPC timeout for Temporal workflows in seconds."""

# Secrets manager config
TRACECAT__UNSAFE_DISABLE_SM_MASKING = os.environ.get(
Expand Down
2 changes: 2 additions & 0 deletions tracecat/workflow/executions/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ async def _dispatch_workflow(
role=self.role,
wf_exec_id=wf_exec_id,
)
if rpc_timeout := config.TEMPORAL__CLIENT_RPC_TIMEOUT:
kwargs["rpc_timeout"] = datetime.timedelta(seconds=float(rpc_timeout))
try:
result = await self._client.execute_workflow(
DSLWorkflow.run,
Expand Down