Skip to content
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
20 changes: 19 additions & 1 deletion agent/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
import sys

import requests
from django.apps import AppConfig
Expand All @@ -8,6 +10,18 @@

logger = logging.getLogger(__name__)

_MANAGEMENT_CMDS_SKIP_DRD_PING = frozenset(
{'check', 'test', 'makemigrations', 'migrate', 'showmigrations'}
)


def _skip_drd_cloud_startup_ping() -> bool:
if os.environ.get('SKIP_DRD_CLOUD_STARTUP_PING', '').lower() in ('1', 'true', 'yes'):
return True
if len(sys.argv) >= 2 and sys.argv[1] in _MANAGEMENT_CMDS_SKIP_DRD_PING:
return True
return False


class AgentConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
Expand All @@ -28,7 +42,11 @@ def ready(self):
if settings.NATIVE_KUBERNETES_API_MODE:
logger.info('Native Kubernetes API mode is enabled')

# Establish reachability with DRD Cloud
# Establish reachability with DRD Cloud (skipped for check/test/migrate etc.)
if _skip_drd_cloud_startup_ping():
logger.info('Skipping DRD Cloud startup ping for this management command')
return

response = requests.get(f'{drd_cloud_host}/connectors/proxy/ping',
headers={'Authorization': f'Bearer {drd_cloud_api_token}'},
params={'commit_hash': commit_hash})
Expand Down
2 changes: 1 addition & 1 deletion agent/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/
"""

import os
Expand Down
18 changes: 9 additions & 9 deletions agent/settings.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Django settings for agent project.

Generated by 'django-admin startproject' using Django 4.2.16.
Generated by 'django-admin startproject' using Django 4.2.16; upgraded to Django 5.2 LTS.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
https://docs.djangoproject.com/en/5.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
https://docs.djangoproject.com/en/5.2/ref/settings/
"""

import os
Expand Down Expand Up @@ -36,7 +36,7 @@ def load_yaml(filepath, native_k8s_connector_mode=False):


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str("DJANGO_SECRET_KEY", default='django-insecure-3-9*i+n@+)07+$lde6v%+705m+jz9_v9r6##qizm+0&x%)963g')
Expand Down Expand Up @@ -102,7 +102,7 @@ def load_yaml(filepath, native_k8s_connector_mode=False):
WSGI_APPLICATION = 'agent.wsgi.application'

# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases

DATABASES = {
'default': {
Expand Down Expand Up @@ -205,7 +205,7 @@ def load_yaml(filepath, native_k8s_connector_mode=False):
REDIS_URL = env.str('REDIS_URL', default='redis://localhost:6379')

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -223,7 +223,7 @@ def load_yaml(filepath, native_k8s_connector_mode=False):
]

# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
# https://docs.djangoproject.com/en/5.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

Expand All @@ -234,13 +234,13 @@ def load_yaml(filepath, native_k8s_connector_mode=False):
USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
# https://docs.djangoproject.com/en/5.2/howto/static-files/

STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Expand Down
2 changes: 1 addition & 1 deletion agent/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
URL configuration for agent project.

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
https://docs.djangoproject.com/en/5.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
Expand Down
2 changes: 1 addition & 1 deletion agent/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
"""

import os
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ distro==1.9.0
dj-database-url==1.2.0
dj-email-url==1.0.6
dj-rest-auth==2.2.7
Django>=4.2.14,<5
Django>=5.2,<5.3
django-allauth>=65.14.1
django-appconf==1.0.5
django-cache-url==3.4.4
Expand Down Expand Up @@ -100,7 +100,7 @@ oauthlib==3.2.2
openai==1.35.15
opsgenie-sdk==2.1.5
packaging==24.1
pandas==2.3.1
pandas>=2.3.3,<2.4
paramiko==3.4.1
pdpyras==5.2.0
portalocker==2.10.1
Expand Down Expand Up @@ -150,4 +150,4 @@ websocket-client==1.8.0
yarl==1.12.1
zstandard==0.23.0
# Latest version of drdroid-debug-toolkit -> added logql cleanup
git+https://github.com/DrDroidLab/drdroid-debug-toolkit.git@master
git+https://github.com/DrDroidLab/drdroid-debug-toolkit.git@feat/django-5-introduced
Loading