Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: decouple Docker image builder from substrapp #689

Closed
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
1 change: 0 additions & 1 deletion backend/backend/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

app.steps["worker"].add(DjangoStructLogInitStep)


# Load task modules from all registered Django app configs.
app.autodiscover_tasks()

Expand Down
1 change: 1 addition & 0 deletions backend/backend/settings/celery/dev.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ..deps.image_build import *
from ..deps.ledger import *
from ..deps.orchestrator import *
from ..dev import *
1 change: 1 addition & 0 deletions backend/backend/settings/celery/prod.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ..deps.image_build import *
from ..deps.ledger import *
from ..deps.orchestrator import *
from ..prod import *
6 changes: 6 additions & 0 deletions backend/backend/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"api",
"drf_spectacular",
"django_filters",
"builder",
]

AUTHENTICATION_BACKENDS = [
Expand Down Expand Up @@ -301,6 +302,11 @@
"handlers": ["console"],
"propagate": False,
},
"builder": {
"level": LOG_LEVEL,
"handlers": ["console"],
"propagate": False,
},
# third-party libraries
"celery": {
"level": "INFO",
Expand Down
4 changes: 4 additions & 0 deletions backend/backend/settings/deps/image_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# How long we wait before throwing errors, in seconds
IMAGE_BUILD_TIMEOUT = 3 * 60 * 60 # 3 hours
# Delay before two check
IMAGE_BUILD_CHECK_DELAY = 5
1 change: 1 addition & 0 deletions backend/backend/settings/worker/events/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ...deps.image_build import *
from ...deps.ledger import *
from ...deps.orchestrator import *
from ...dev import *
Expand Down
Empty file added backend/builder/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions backend/builder/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class BuilderConfig(AppConfig):
name = "builder"
42 changes: 42 additions & 0 deletions backend/builder/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from io import BytesIO

from substrapp.compute_tasks.errors import CeleryNoRetryError
from substrapp.compute_tasks.errors import CeleryRetryError
from substrapp.compute_tasks.errors import ComputeTaskErrorType
from substrapp.compute_tasks.errors import _ComputeTaskError


class PodError(Exception):
pass


class PodTimeoutError(Exception):
pass


class BuildRetryError(_ComputeTaskError, CeleryRetryError):
"""An error occurred during the build of a container image.

Args:
logs (str): the container image build logs
"""

error_type = ComputeTaskErrorType.BUILD_ERROR

def __init__(self, logs: str, *args, **kwargs):
self.logs = BytesIO(str.encode(logs))
super().__init__(logs, *args, **kwargs)


class BuildError(_ComputeTaskError, CeleryNoRetryError):
"""An error occurred during the build of a container image.

Args:
logs (str): the container image build logs
"""

error_type = ComputeTaskErrorType.BUILD_ERROR

def __init__(self, logs: str, *args, **kwargs):
self.logs = BytesIO(str.encode(logs))
super().__init__(logs, *args, **kwargs)
Empty file.
Loading
Loading