Skip to content

Commit 46ef19a

Browse files
committed
chore(quickwit): add send app log to quickwit
1 parent 46ca0ad commit 46ef19a

31 files changed

Lines changed: 121 additions & 82 deletions

charts/controller/templates/_helpers.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ env:
106106
- name: WORKFLOW_MANAGER_SECRET_KEY
107107
value: "{{ .Values.workflowManagerSecretKey }}"
108108
{{- end }}
109+
- name: POD_IP
110+
valueFrom:
111+
fieldRef:
112+
fieldPath: status.podIP
113+
- name: POD_NAME
114+
valueFrom:
115+
fieldRef:
116+
fieldPath: metadata.name
109117
- name: WORKFLOW_NAMESPACE
110118
valueFrom:
111119
fieldRef:
@@ -154,6 +162,8 @@ env:
154162
name: controller-creds
155163
key: passport-secret
156164
{{- end }}
165+
- name: QUICKWIT_INDEXER_URL
166+
value: http://drycc-quickwit-indexer:7280
157167
- name: QUICKWIT_SEARCHER_URL
158168
value: http://drycc-quickwit-searcher:7280
159169
- name: QUICKWIT_LOG_INDEX_PREFIX

charts/controller/templates/controller-celery-deloyment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spec:
4747
args:
4848
- /bin/bash
4949
- -c
50-
- celery --app api worker --queues controller.low,controller.middle,controller.high --autoscale=32,1 --loglevel=WARNING
50+
- celery --app api worker --queues controller.low,controller.high,controller.middle --autoscale=32,1 --loglevel=WARNING
5151
{{- end }}
5252
{{- with index .Values "celery" "resources" }}
5353
resources:

rootfs/api/filer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from django.core.cache import cache
66
from requests.auth import HTTPBasicAuth
77

8-
from .utils import random_string, get_session, CacheLock
8+
from .tasks import send_app_log
9+
from .utils import random_string, get_httpclient, CacheLock
910

1011
logger = logging.getLogger(__name__)
1112

@@ -21,6 +22,7 @@ def __init__(self, app_id, volume, scheduler):
2122

2223
def log(self, message, level=logging.INFO):
2324
logger.log(level, "[{}]: {}".format(self.app_id, message))
25+
send_app_log.delay(self.app_id, message, level)
2426

2527
@property
2628
def server(self):
@@ -90,7 +92,8 @@ def request(self, method, server, path="/", **kwargs):
9092
cache.touch(self.cache_key, timeout=settings.DRYCC_FILER_DURATION)
9193
url = f"http://{server["address"]}:{self.bind.split(":")[1]}/{path}"
9294
kwargs["auth"] = HTTPBasicAuth(server["username"], server["password"])
93-
return get_session().request(method, url, **kwargs)
95+
with get_httpclient() as session:
96+
session.request(method, url, **kwargs)
9497

9598
def get(self, path, **kwargs):
9699
return self.request("GET", self.server, path, **kwargs)

rootfs/api/models/app.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
from django.contrib.auth import get_user_model
2121
from rest_framework.exceptions import ValidationError
2222

23-
from api.utils import get_session, dict_diff
23+
from api.tasks import send_app_log
24+
from api.utils import get_httpclient, dict_diff
2425
from api.exceptions import AlreadyExists, DryccException, ServiceUnavailable
2526
from api.utils import (
2627
CacheLock, DeployLock, generate_app_name, apply_tasks, validate_reserved_names)
@@ -185,6 +186,7 @@ def log(self, message, level=logging.INFO):
185186
as "belonging" to the application instead of the controller and will be handled
186187
accordingly.
187188
"""
189+
send_app_log.delay(self.id, message, level)
188190
logger.log(level, "[{}]: {}".format(self.id, message))
189191

190192
def create(self, *args, **kwargs): # noqa
@@ -1007,9 +1009,10 @@ def _verify_http_health(self, service, **kwargs):
10071009
response = None
10081010
for _ in range(10):
10091011
try:
1010-
# http://docs.python-requests.org/en/master/user/advanced/#timeouts
1011-
response = get_session().get(url, timeout=req_timeout)
1012-
failed = False
1012+
with get_httpclient() as session:
1013+
# http://docs.python-requests.org/en/master/user/advanced/#timeouts
1014+
response = session.get(url, timeout=req_timeout)
1015+
failed = False
10131016
except requests.exceptions.RequestException:
10141017
# In case of a failure where response object is not available
10151018
failed = True

rootfs/api/models/appsettings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from rest_framework.exceptions import NotFound
88
from django.contrib.auth import get_user_model
9+
from api.tasks import send_app_log
910
from api.utils import dict_diff
1011
from api.exceptions import DryccException, AlreadyExists, UnprocessableEntity
1112
from .base import UuidAuditedModel
@@ -48,6 +49,7 @@ def log(self, message, level=logging.INFO):
4849
as "belonging" to the application instead of the controller and will be handled
4950
accordingly.
5051
"""
52+
send_app_log.delay(self.app.id, message, level)
5153
logger.log(level, "[{}]: {}".format(self.app.id, message))
5254

5355
def previous(self):

rootfs/api/models/base.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django.utils.translation import gettext_lazy as _
1212

1313

14-
from api.utils import get_session, validate_json, get_scheduler
14+
from api.utils import get_httpclient, validate_json, get_scheduler
1515

1616
token_manager_oauth_schema = {
1717
"$schema": "http://json-schema.org/schema#",
@@ -49,18 +49,18 @@ class Meta:
4949
abstract = True
5050

5151
def app_log(self, app_id, msg):
52-
session = get_session()
53-
session.post(
54-
"",
55-
json={
56-
"timestamp": int(time.time()),
57-
"log": msg,
58-
"kubernetes": {
59-
"namespace": app_id,
60-
"container_name": "drycc-controller",
52+
with get_httpclient() as session:
53+
session.post(
54+
"",
55+
json={
56+
"timestamp": int(time.time()),
57+
"log": msg,
58+
"kubernetes": {
59+
"namespace": app_id,
60+
"container_name": "drycc-controller",
61+
}
6162
}
62-
}
63-
)
63+
)
6464

6565
@property
6666
def scheduler(self):

rootfs/api/models/gateway.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.db.models import Q
77
from django.http import Http404
88

9+
from api.tasks import send_app_log
910
from api.utils import validate_label
1011
from api.exceptions import ServiceUnavailable
1112
from scheduler import KubeException
@@ -35,6 +36,7 @@ def log(self, message, level=logging.INFO):
3536
as "belonging" to the application instead of the controller and will be handled
3637
accordingly.
3738
"""
39+
send_app_log.delay(self.app.id, message, level)
3840
logger.log(level, "[{}]: {}".format(self.app.id, message))
3941

4042
def add(self, port, protocol):
@@ -255,6 +257,7 @@ def log(self, message, level=logging.INFO):
255257
as "belonging" to the application instead of the controller and will be handled
256258
accordingly.
257259
"""
260+
send_app_log.delay(self.app.id, message, level)
258261
logger.log(level, "[{}]: {}".format(self.app.id, message))
259262

260263
def refresh_to_k8s(self):

rootfs/api/models/release.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.db.models import Q
88
from django.contrib.auth import get_user_model
99
from django.db.models import F, Func, Value, JSONField
10-
from api.tasks import run_pipeline
10+
from api.tasks import run_pipeline, send_app_log
1111
from api.exceptions import DryccException, AlreadyExists
1212
from scheduler import KubeHTTPException
1313
from scheduler.resources.pod import DEFAULT_CONTAINER_PORT
@@ -130,6 +130,7 @@ def log(self, message, level=logging.INFO):
130130
as "belonging" to the application instead of the controller and will be handled
131131
accordingly.
132132
"""
133+
send_app_log.delay(self.app.id, message, level)
133134
logger.log(level, "[{}]: {}".format(self.app.id, message))
134135

135136
def new(self, user, config, build, summary=None):

rootfs/api/models/resource.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.db import models, transaction
44
from django.contrib.auth import get_user_model
55
from api.exceptions import DryccException, AlreadyExists, ServiceUnavailable
6+
from api.tasks import send_app_log
67
from api.utils import validate_label, get_scheduler
78
from scheduler import KubeException
89
from .base import UuidAuditedModel
@@ -124,6 +125,7 @@ def log(self, message, level=logging.INFO):
124125
as "belonging" to the application instead of the controller and will be handled
125126
accordingly.
126127
"""
128+
send_app_log.delay(self.app.id, message, level)
127129
logger.log(level, "[{}]: {}".format(self.app.id, message))
128130

129131
def bind(self, *args, **kwargs):

rootfs/api/models/service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from functools import partial
33
from django.db import models
44
from django.contrib.auth import get_user_model
5+
from api.tasks import send_app_log
56
from api.utils import validate_json
67
from api.exceptions import ServiceUnavailable
78
from scheduler import KubeException
@@ -131,6 +132,7 @@ def log(self, message, level=logging.INFO):
131132
as "belonging" to the application instead of the controller and will be handled
132133
accordingly.
133134
"""
135+
send_app_log.delay(self.app.id, message, level)
134136
logger.log(level, "[{}]: {}".format(self.app.id, message))
135137

136138
def refresh_k8s_svc(self):

0 commit comments

Comments
 (0)