Skip to content

Commit bfebec1

Browse files
Merge pull request #157 from DrDroidLab/fix/dual-worker-poc
jenkins latest debug toolkit
2 parents 392f59e + 5b62922 commit bfebec1

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

agent/settings.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def load_yaml(filepath, native_k8s_connector_mode=False):
4040

4141
# SECURITY WARNING: keep the secret key used in production secret!
4242
SECRET_KEY = env.str("DJANGO_SECRET_KEY", default='django-insecure-3-9*i+n@+)07+$lde6v%+705m+jz9_v9r6##qizm+0&x%)963g')
43+
NATIVE_KUBERNETES_API_MODE = env.bool("NATIVE_KUBERNETES_API_MODE", default=False)
4344

4445
# SECURITY WARNING: don't run with debug turned on in production!
4546
DEBUG = env.bool("DJANGO_DEBUG", default=True)
@@ -141,20 +142,46 @@ def load_yaml(filepath, native_k8s_connector_mode=False):
141142
CELERY_WORKER_PREFETCH_MULTIPLIER = 1
142143
CELERY_WORKER_MAX_TASKS_PER_CHILD = 1000
143144

145+
# Task timeout settings
146+
CELERY_TASK_TIME_LIMIT = 40 # Hard timeout: 100s (task will be killed, and worker respawned)
147+
CELERY_TASK_SOFT_TIME_LIMIT = 35
148+
144149
# Define task queues and route tasks to appropriate queues
145150
CELERY_TASK_DEFAULT_QUEUE = 'celery'
146151
CELERY_TASK_QUEUES = (
147152
Queue('celery'),
148153
Queue('exec'),
149154
Queue('asset_extraction'),
150155
)
151-
CELERY_TASK_ROUTES = {
152-
# Regular playbook task execution - high priority, needs good resources
153-
'playbooks_engine.tasks.execute_task_and_send_result': {'queue': 'exec'},
154-
155-
# Asset extraction tasks - can run slower, dedicated resources
156-
'asset_manager.tasks.populate_connector_metadata': {'queue': 'asset_extraction'},
157-
'asset_manager.tasks.extractor_async_method_call': {'queue': 'asset_extraction'},
156+
if NATIVE_KUBERNETES_API_MODE:
157+
CELERY_TASK_ROUTES = {
158+
# Regular playbook task execution - high priority, needs good resources
159+
'playbooks_engine.tasks.execute_task_and_send_result': {'queue': 'exec'},
160+
161+
# Asset extraction tasks - can run slower, dedicated resources
162+
'asset_manager.tasks.populate_connector_metadata': {'queue': 'asset_extraction'},
163+
'asset_manager.tasks.extractor_async_method_call': {'queue': 'asset_extraction'},
164+
}
165+
166+
else:
167+
CELERY_TASK_ROUTES = {
168+
'playbooks_engine.tasks.execute_task_and_send_result': {'queue': 'exec'},
169+
}
170+
171+
# Queue-specific timeout settings
172+
CELERY_TASK_ANNOTATIONS = {
173+
'playbooks_engine.tasks.execute_task_and_send_result': {
174+
'time_limit': 40,
175+
'soft_time_limit': 35,
176+
},
177+
'asset_manager.tasks.populate_connector_metadata': {
178+
'time_limit': 40,
179+
'soft_time_limit': 35,
180+
},
181+
'asset_manager.tasks.extractor_async_method_call': {
182+
'time_limit': 40,
183+
'soft_time_limit': 35,
184+
},
158185
}
159186

160187
# Celery Beat Configuration Options
@@ -250,8 +277,6 @@ def load_yaml(filepath, native_k8s_connector_mode=False):
250277
DRD_CLOUD_API_HOST = env.str("DRD_CLOUD_API_HOST", default="https://agent-api.drdroid.io")
251278
VPC_AGENT_COMMIT_HASH = env.str("VPC_AGENT_COMMIT_HASH", default="unknown")
252279

253-
NATIVE_KUBERNETES_API_MODE = env.bool("NATIVE_KUBERNETES_API_MODE", default=False)
254-
255280
SECRETS_FILE_PATH = BASE_DIR / 'credentials/secrets.yaml'
256281
LOADED_CONNECTIONS = load_yaml(SECRETS_FILE_PATH, NATIVE_KUBERNETES_API_MODE)
257282

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,5 @@ wcwidth==0.2.13
149149
websocket-client==1.8.0
150150
yarl==1.12.1
151151
zstandard==0.23.0
152-
# Latest version of drdroid-debug-toolkit -> with ES metadata
152+
# Latest version of drdroid-debug-toolkit -> with jenkins tools improvements
153153
git+https://github.com/DrDroidLab/drdroid-debug-toolkit.git@master

0 commit comments

Comments
 (0)