Skip to content

Commit

Permalink
Replaced Daphne with uvicorn and enabled multiple workers for perform…
Browse files Browse the repository at this point in the history
…ance optimization (#132)

Fixed broken kioscadmin url
  • Loading branch information
stolpeo committed Jan 28, 2022
1 parent f9e88aa commit f9b8db8
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 215 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ Changelog for the **Kiosc** Django app package.
Loosely follows the `Keep a Changelog <http://keepachangelog.com/en/1.0.0/>`_ guidelines.


HEAD (unreleased)
=================

General
-------

- Replaced Daphne with uvicorn and enabled multiple workers for performance optimization (#132)

Kioscadmin
----------

- Fixed broken kioscadmin url (#132)


v0.4.0 (2021-11-08)
===================

Expand Down
4 changes: 2 additions & 2 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
TemplateView.as_view(template_name="pages/about.html"),
name="about",
),
# Admin URLs - most occur before Django Admin, otherwise urls will be matched by that.
url(r"^kioscadmin/", include("kioscadmin.urls")),
# Django Admin, use {% url 'admin:index' %}
url(settings.ADMIN_URL, admin.site.urls),
# Login and logout
Expand Down Expand Up @@ -52,8 +54,6 @@
url(r"^containers/", include("containers.urls")),
# Containertemplates URLs
url(r"^containertemplates/", include("containertemplates.urls")),
# Admin URLs
url(r"^kioscadmin/", include("kioscadmin.urls")),
# Iconify icon URLs
url(r"^icons/", include("dj_iconify.urls")),
# These are the SAML2 related URLs. You can change "^saml2_auth/" regex to
Expand Down
2 changes: 1 addition & 1 deletion containers/statemachines.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def on_pull(self):
)

for key, value in environment.items():
if "__KIOSC_URL_PREFIX__" in value:
if isinstance(value, str) and "__KIOSC_URL_PREFIX__" in value:
environment[key] = value.replace(
"__KIOSC_URL_PREFIX__", url_prefix
)
Expand Down
37 changes: 18 additions & 19 deletions containers/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ def setUp(self):
def log_entry1():
"""First log entry."""
dt = dateutil.parser.parse("2021-01-01 01:01:01.000001+00:00")
return dt, "{} 2021/01/01 10:00:00 [info] Log entry 1".format(
dateformat.format(dt.replace(tzinfo=None), "c") + "000Z"
return (
dt,
"{} 2021/01/01 10:00:00 [info] Log entry 1".format(
dateformat.format(dt.replace(tzinfo=None), "c") + "000Z"
),
)


Expand All @@ -87,16 +90,22 @@ def log_entry1_no_date():
def log_entry2():
"""Second log entry, same second but different millisecond."""
dt = dateutil.parser.parse("2021-01-01 01:01:01.500001+00:00")
return dt, "{} 2021/01/01 10:00:00 [info] Log entry 2".format(
dateformat.format(dt.replace(tzinfo=None), "c") + "000Z"
return (
dt,
"{} 2021/01/01 10:00:00 [info] Log entry 2".format(
dateformat.format(dt.replace(tzinfo=None), "c") + "000Z"
),
)


def log_entry3():
"""Third log entry happening the next second"""
dt = dateutil.parser.parse("2021-01-01 01:01:02.000001+00:00")
return dt, "{} 2021/01/01 10:00:01 [info] Log entry 3".format(
dateformat.format(dt.replace(tzinfo=None), "c") + "000Z"
return (
dt,
"{} 2021/01/01 10:00:01 [info] Log entry 3".format(
dateformat.format(dt.replace(tzinfo=None), "c") + "000Z"
),
)


Expand Down Expand Up @@ -126,11 +135,7 @@ class DockerMock:
logs_no_date = log_entry1_no_date().encode("utf-8")
logs_since = "\n".join([log_entry2()[1], log_entry3()[1]]).encode("utf-8")

networks = [
{
"Id": "abcdef",
}
]
networks = [{"Id": "abcdef"}]
inspect_network = {
"Name": "network1",
"Id": "abcdef",
Expand All @@ -139,10 +144,7 @@ class DockerMock:
"Config": [{"Subnet": "172.17.0.0/16", "Gateway": "172.17.0.1"}]
},
"Containers": {
"9": {
"Name": "container1",
"IPv4Address": "172.17.0.5/16",
},
"9": {"Name": "container1", "IPv4Address": "172.17.0.5/16"},
},
}
images = [
Expand All @@ -153,10 +155,7 @@ class DockerMock:
]
volumes = {
"Volumes": [
{
"Mountpoint": "/var/lib/docker/volumes/volume1",
"Name": "abcdef",
}
{"Mountpoint": "/var/lib/docker/volumes/volume1", "Name": "abcdef"}
]
}
containers = [
Expand Down
12 changes: 2 additions & 10 deletions containers/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,7 @@ def test_environment_secret_keys_mismatching(self):

@override_settings(KIOSC_NETWORK_MODE="host")
def test_environment_no_json(self):
self.form_data_all.update(
{
"environment": "abc",
}
)
self.form_data_all.update({"environment": "abc"})
form = ContainerForm(self.form_data_all)
self.assertEqual(
form.errors["environment"],
Expand All @@ -157,11 +153,7 @@ def test_environment_no_json(self):

@override_settings(KIOSC_NETWORK_MODE="host")
def test_environment_no_dict(self):
self.form_data_all.update(
{
"environment": '["some", "list"]',
}
)
self.form_data_all.update({"environment": '["some", "list"]'})
form = ContainerForm(self.form_data_all)
self.assertEqual(
form.errors["environment"],
Expand Down
10 changes: 2 additions & 8 deletions containers/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,7 @@ def test_get_non_existent(self):
response = self.client.get(
reverse(
"containers:proxy",
kwargs={
"container": self.fake_uuid,
"path": "",
},
kwargs={"container": self.fake_uuid, "path": ""},
)
)

Expand Down Expand Up @@ -1376,10 +1373,7 @@ def test_get_non_existent(self):
response = self.client.get(
reverse(
"containers:proxy-lobby",
kwargs={
"container": self.fake_uuid,
"path": "",
},
kwargs={"container": self.fake_uuid, "path": ""},
)
)

Expand Down
12 changes: 3 additions & 9 deletions containers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@
LOG_LEVEL_ERROR,
)
from containers.tasks import container_task
from containertemplates.forms import (
ContainerTemplateSelectorForm,
)
from containertemplates.forms import ContainerTemplateSelectorForm


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -265,9 +263,7 @@ def get_success_url(self):
)
return reverse(
"containers:restart",
kwargs={
"container": self.object.sodar_uuid,
},
kwargs={"container": self.object.sodar_uuid},
)

def form_valid(self, form):
Expand Down Expand Up @@ -695,9 +691,7 @@ def dispatch(self, request, *args, **kwargs):
_redirect = redirect(
reverse(
"containers:list",
kwargs={
"project": container.project.sodar_uuid,
},
kwargs={"project": container.project.sodar_uuid},
)
)

Expand Down
Loading

0 comments on commit f9b8db8

Please sign in to comment.