Page MenuHomePhabricator

[jobs-api] Split the API, core, and storage and runtime modules
Closed, ResolvedPublic

Description

We have three sets of data structures, the ones used in the API requests and responses, the internal objects, and the k8s objects we create from those.

This task is to split those three sets, creating a clear distinction between them and allowing us to modularize the application.

  • API layer:

This contains the logic to validate API requests, and how to create business model objects from them

  • Core (business) layer:

This contains our internal objects (ScheduledJob, OneOffJob, ContinuousJob, ...) and has logic related only to how to manage those.

  • Runtime layer:

This will have the logic on how to instantiate the business layer objects into k8s, using an abstract class to be able to easily change the infa layer in the future:

from abc import ABC, abstractmethod

class Engine(ABC):
   @abstractmethod
   def run_continuous_job(self, continuous_job: ContinuousJob) -> RunResult:
      pass

   @abstractmethod
   def run_scheduled_job(self, scheduled_job: ScheduledJob) -> RunResult:
      pass
...


class K8sEngine(Engine):
    def run_continuous_job(self, continuous_job: ContinuousJob) -> RunResult:
        ... do stuff on k8s to get the job running
  • Storage layer:

This serves the abstraction used to persist objects (currently on k8s), might use it's own datastructures (ex. k8s custom resources)

A diagram of how the layers should interact with each other (from https://docs.google.com/document/d/1hkUMuJ3JFszCWqGkA1vfLoQKnae4YND29oORppN7lKo/edit?tab=t.0):

image.png (1×2 px, 201 KB)

This is maximized to allow responsibility separation (API deals with the API interfacing, core with the business logic, storage with how to persist, ...) and keep cohesion to a maximum (if you change some code, the extra code that needs changing is as close to it as possible) while allowing for plugability of implementation details (http api, k8s runtime, k8s storage, ...).

Related Objects

StatusSubtypeAssignedTask
ResolvedLucasWerkmeister
Resolvedmatmarex
ResolvedLegoktm
ResolvedLegoktm
In Progressdcaro
Resolveddcaro
In Progresskomla
Resolveddcaro
Resolveddcaro
ResolvedRaymond_Ndibe
Opendcaro
OpenNone
In ProgressFeatureRaymond_Ndibe
ResolvedFeatureRaymond_Ndibe
OpenRaymond_Ndibe
ResolvedRaymond_Ndibe
In ProgressRaymond_Ndibe
OpenRaymond_Ndibe
ResolvedRaymond_Ndibe

Event Timeline

dcaro removed Raymond_Ndibe as the assignee of this task.
dcaro triaged this task as High priority.Mar 11 2024, 12:52 PM
dcaro moved this task from Backlog to Ready to be worked on on the Toolforge board.

project_1317_bot_df3177307bed93c3f34e421e26c86e38 opened https://gitlab.wikimedia.org/repos/cloud/toolforge/toolforge-deploy/-/merge_requests/259

jobs-api: bump to 0.0.291-20240415170518-fde04b2c

this is done right @dcaro? we should mark it as resolved if so

dcaro reopened this task as In Progress.
dcaro moved this task from In Progress to Done on the Toolforge (Toolforge iteration 10) board.
dcaro moved this task from Done to In Progress on the Toolforge (Toolforge iteration 10) board.

This doesn't seem to have had any progress since last May - why is it bouncing through every iteration as "in progress"?

dcaro renamed this task from [jobs-api] Split the API, business, and k8s models to [jobs-api] Split the API, core, and storage and runtime models.Mar 27 2025, 8:06 AM
dcaro updated the task description. (Show Details)

This doesn't seem to have had any progress since last May - why is it bouncing through every iteration as "in progress"?

I think the issue is that the task is very open-ended therefore many patches fit under it. There are already a number of patches submitted and merged and more to come before this can be marked as resolved. Obviously a better way to do it is to break everything down into piece meal sizes, haven't gotten around to doing that though

Raymond_Ndibe renamed this task from [jobs-api] Split the API, core, and storage and runtime models to [jobs-api] Split the API, core, and storage and runtime modules.Apr 8 2025, 3:25 AM