Compare commits

...

6 Commits

Author SHA1 Message Date
3d2d759d6b build: bump version 1.17.1 -> 1.18.0 2025-07-03 22:55:51 +00:00
Jon
b73de03d27 Merge pull request #851 from nofusscomputing/850-fix-itim-validation-failure 2025-07-04 08:08:00 +09:30
Jon
a9e953812c feat(python): upgrade django 5.1.9 -> 5.1.10
ref: #851
2025-07-04 07:47:21 +09:30
Jon
4344265ed5 fix(itim): Correct config that is in the incorrect format
Users can input config that contains bytecode chars which inturn, makes the config entered a str. convert any config that is a str to a dict, the correct format.

ref: #851 fixes #850
2025-07-04 07:42:05 +09:30
4fb94bdd6d build: bump version 1.17.0 -> 1.17.1 2025-06-02 00:05:20 +00:00
Jon
e2582373ad fix(base): Add python metrics to prometheus exporter
ref: #436
2025-06-02 08:25:37 +09:30
6 changed files with 104 additions and 4 deletions

View File

@ -17,5 +17,5 @@ commitizen:
prerelease_offset: 1
tag_format: $version
update_changelog_on_bump: false
version: 1.17.0
version: 1.18.0
version_scheme: semver

View File

@ -1,3 +1,19 @@
## 1.18.0 (2025-07-03)
### feat
- **python**: upgrade django 5.1.9 -> 5.1.10
### Fixes
- **itim**: Correct config that is in the incorrect format
## 1.17.1 (2025-06-02)
### Fixes
- **base**: Add python metrics to prometheus exporter
## 1.17.0 (2025-05-16)
### feat

78
app/centurion/celery.py Normal file
View File

@ -0,0 +1,78 @@
import logging
import os
from django.conf import settings
from celery import Celery, signals
from pathlib import Path
from prometheus_client import multiprocess, start_http_server, REGISTRY
logger = logging.getLogger(__name__)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'centurion.settings')
worker = Celery('app')
worker.config_from_object(f'django.conf:settings', namespace='CELERY')
worker.autodiscover_tasks()
@worker.task(bind=True, ignore_result=True)
def debug_task(self):
print(f'Request: {self!r}')
@signals.worker_ready.connect()
def setup_prometheus(**kwargs):
if not getattr(settings, 'METRICS_ENABLED', False):
return
proc_path = None
try:
proc_path = os.environ["PROMETHEUS_MULTIPROC_DIR"]
except:
pass
if not proc_path:
os.environ["PROMETHEUS_MULTIPROC_DIR"] = settings.METRICS_MULTIPROC_DIR
proc_path = os.environ["PROMETHEUS_MULTIPROC_DIR"]
logger.info(f'Setting up prometheus metrics HTTP server on port {str(settings.METRICS_EXPORT_PORT)}.')
multiproc_folder_path = _setup_multiproc_folder()
registry = REGISTRY
logger.info(f'Setting up prometheus metrics directory.')
multiprocess.MultiProcessCollector(registry, path=multiproc_folder_path)
logger.info(f'Starting prometheus metrics server.')
start_http_server( settings.METRICS_EXPORT_PORT, registry=registry)
logger.info(f'Starting prometheus serving on port {str(settings.METRICS_EXPORT_PORT)}.')
def _setup_multiproc_folder():
coordination_dir = Path(os.environ["PROMETHEUS_MULTIPROC_DIR"])
coordination_dir.mkdir(parents=True, exist_ok=True)
for filepath in coordination_dir.glob("*.db"):
filepath.unlink()
return coordination_dir

View File

@ -1,3 +1,5 @@
import json
from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import post_delete
@ -355,6 +357,10 @@ class Cluster(TenancyObject):
if self.config:
if isinstance(self.config, str):
self.config = json.loads(self.config)
self.save()
rendered_config.update(
self.config
)

View File

@ -5,7 +5,7 @@ from pathlib import Path
from django.conf import settings
from prometheus_client import CollectorRegistry, multiprocess, start_http_server
from prometheus_client import multiprocess, start_http_server, REGISTRY
@ -50,7 +50,7 @@ def when_ready(_):
multiproc_folder_path = _setup_multiproc_folder()
registry = CollectorRegistry()
registry = REGISTRY
logger.info(f'Setting up prometheus metrics directory.')

View File

@ -1,5 +1,5 @@
django==5.1.9
django==5.1.10
django-cors-headers==4.4.0
django-debug-toolbar==5.1.0