Skip to content

Commit b0c0a0c

Browse files
author
Davide Arcuri
committed
2.4.2 wip
1 parent e34f52e commit b0c0a0c

36 files changed

+7040
-2134
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ repos:
2121
- id: isort
2222

2323
- repo: https://github.com/hadialqattan/pycln
24-
rev: v2.4.0
24+
rev: v2.6.0
2525
hooks:
2626
- id: pycln

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
## Changelog
2+
<details>
3+
<summary><b>OROCHI 2.4.2 WIP</b></summary>
4+
5+
* Run management task on workers [[#272](https://github.com/LDO-CERT/orochi/issues/272)]
6+
* Update libs and UI
7+
</details>
8+
29
<details>
310
<summary><b>OROCHI 2.4.1</b></summary>
411

compose/local/dask/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.13.6-slim-bookworm as common-base
1+
FROM python:3.13.11-slim-bookworm as common-base
22

33
# DISABLE TZDATA INTERACTION
44
ENV DEBIAN_FRONTEND noninteractive
@@ -91,4 +91,3 @@ RUN apt-get update && apt-get install -y tini && rm -rf /var/lib/apt/lists/*
9191
COPY --from=go-builder /dwarf2json/dwarf2json /dwarf2json/dwarf2json
9292

9393
ENTRYPOINT ["/usr/bin/tini", "-g", "--", "/usr/bin/prepare.sh"]
94-

compose/local/django/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.13.6-slim-bookworm as common-base
1+
FROM python:3.13.11-slim-bookworm as common-base
22

33

44
ENV DJANGO_SETTINGS_MODULE config.settings.local

config/settings/base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@
283283
},
284284
}
285285

286+
# TASKS
287+
# -------------------------------------------------------------------------------
288+
TASKS = {
289+
"default": {
290+
"BACKEND": "orochi.backends.dask.DaskTaskBackend",
291+
"QUEUES": [], # Empty list = allow all queue names
292+
"OPTIONS": {
293+
"ADDRESS": env("DASK_SCHEDULER_URL"),
294+
},
295+
},
296+
}
297+
286298
# LDAP
287299
# ------------------------------------------------------------------------------
288300
AUTH_LDAP_SERVER_URI = env("AUTH_LDAP_SERVER_URI")

orochi/api/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ninja import NinjaAPI
2+
from ninja.security import django_auth
23

34
from orochi.api.routers.admin import router as admin_router
45
from orochi.api.routers.auth import router as auth_router
@@ -12,7 +13,7 @@
1213
from orochi.api.routers.users import router as users_router
1314
from orochi.api.routers.utils import router as utils_router
1415

15-
api = NinjaAPI(csrf=True, title="Orochi API", urls_namespace="api")
16+
api = NinjaAPI(auth=django_auth, title="Orochi API", urls_namespace="api")
1617
api.add_router("/admin/", admin_router, tags=["Admin"])
1718
api.add_router("/auth/", auth_router, tags=["Auth"])
1819
api.add_router("/users/", users_router, tags=["Users"])

orochi/api/routers/admin.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,9 @@ def update_plugins(request):
9393
Exception: If an error occurs during plugin synchronization.
9494
"""
9595

96-
try:
97-
management.call_command("plugins_sync", verbosity=0)
98-
messages.add_message(request, messages.INFO, "Sync Plugin done")
99-
return 200, {"message": "Sync Plugin done"}
100-
except Exception as e:
101-
messages.add_message(request, messages.ERROR, f"Sync Plugin failed: {e}")
102-
return 400, {"errors": "Error syncing plugins"}
96+
management.call_command("plugins_sync", verbosity=0)
97+
messages.add_message(request, messages.INFO, "Sync Plugin started")
98+
return 200, {"message": "Sync Plugin started"}
10399

104100

105101
@router.get(
@@ -123,10 +119,6 @@ def update_symbols(request):
123119
Exception: If an error occurs during symbol synchronization.
124120
"""
125121

126-
try:
127-
management.call_command("symbols_sync", verbosity=0)
128-
messages.add_message(request, messages.INFO, "Sync Symbols done")
129-
return 200, {"message": "Sync Symbols done"}
130-
except Exception as e:
131-
messages.add_message(request, messages.ERROR, f"Sync Symbols failed: {e}")
132-
return 400, {"errors": "Error syncing symbols"}
122+
management.call_command("symbols_sync", verbosity=0)
123+
messages.add_message(request, messages.INFO, "Sync Symbols started")
124+
return 200, {"message": "Sync Symbols started"}

orochi/backends/dask.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import logging
2+
from copy import deepcopy
3+
4+
from dask.distributed import Client, fire_and_forget
5+
from django.conf import settings
6+
from django.tasks.backends.base import BaseTaskBackend
7+
from django.tasks.base import TaskResult, TaskResultStatus
8+
9+
logger = logging.getLogger(__name__)
10+
11+
12+
class DaskTaskBackend(BaseTaskBackend):
13+
14+
def __init__(self, alias, **kwargs):
15+
super().__init__(alias, **kwargs)
16+
self._client = None
17+
18+
@property
19+
def client(self):
20+
if self._client is None or self._client.status in ("closed", "closing"):
21+
self._client = Client(settings.DASK_SCHEDULER_URL)
22+
return self._client
23+
24+
def enqueue(self, task, args, kwargs):
25+
logger.info(f"Enqueuing task {task.name}")
26+
future = self.client.submit(task.func, *args, pure=False, **kwargs)
27+
fire_and_forget(future)
28+
result = TaskResult(
29+
task=task,
30+
id=future.key,
31+
status=TaskResultStatus.READY,
32+
enqueued_at=None,
33+
started_at=None,
34+
last_attempted_at=None,
35+
finished_at=None,
36+
args=args,
37+
kwargs=kwargs,
38+
backend=self.alias,
39+
errors=[],
40+
worker_ids=[],
41+
)
42+
return deepcopy(result)

orochi/static/README.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# Bootstrap [MAIN CSS]
22
--> https://getbootstrap.com/
3-
--> version 5.3.3
3+
--> version 5.3.8
44

55
# Fontawesome [ICON]
66
--> https://fontawesome.com/
7-
--> version 6.6.0
7+
--> version 7.0.0
88

99
# diff_view [COMPARE 2 PLUGIN RESULT]
1010
--> https://benjamine.github.io/jsondiffpatch/demo/index.html
1111
--> code taken directly from html example
1212

1313
# jsonedit [VIEW JSON FILE, eg. HIVE]
1414
--> https://github.com/josdejong/jsoneditor/tree/master
15-
--> version 10.1.0
15+
--> version 10.4.2
1616

1717
# bootbox [INPUT & CONFIRM DIALOG]
1818
--> http://bootboxjs.com/
19-
--> version 6.0.0
19+
--> version 6.0.4
2020

2121
# wunderbaum [TREE VIEW FOR PSTREE]
2222
--> https://github.com/mar10/wunderbaum/
23-
--> version 0.11.0
23+
--> version 0.13.0
2424

2525
# Datatables [TABLE RENDERING]
2626
--> https://datatables.net/
@@ -33,11 +33,11 @@
3333

3434
# Keyrune [MTG icons]
3535
--> https://github.com/andrewgioia/keyrune
36-
--> version 3.14.0
36+
--> version 3.18.0
3737

3838
# Marked [Changelog with MD]
3939
--> https://github.com/markedjs/marked
40-
--> version 14.1.0
40+
--> version 17.0.1
4141

4242
# Handlebars [Template rendering]
4343
--> https://handlebarsjs.com/

orochi/static/css/bootstrap/bootstrap.min.css

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)