Page MenuHomePhabricator

[components-api] Get a skeleton of API webservice and implement `/tool/<toolname>/deploy` with single continuous job deployment only
Closed, ResolvedPublic

Description

This task is to bootstrap a minimally working API, focused only on the build phases for now.

Things to keep in mind:

  • Create skeleton repository (copy one of the ones we have already)
  • Using FastAPI for quick POC (https://fastapi.tiangolo.com)
  • Using standard toolforge component CI and helm chart
  • Add to the api-gateway both on nginx config and the values.yaml (python app config)

Data structures

Responses

Every response should be wrapped in a messages response, see T356974: [builds-api,jobs-api,envvars-api,api-gateway] Figure out and document how to do non-backwards compatible changes

Config

For the config datastructure see T362070: [components-api] Get a minimal version of the config with build-only data, it should be stored in the tool namespace as read-only.

Only one per namespace.

Deployment

Example potential deployment data structure:

deploy-id: "mytool-deploy-datestamp-randint"
creation-time: "2024-04-04 12:00:00"
builds:
    component1:
        build-id: build-id-1234
    component2:
        build-id: build-id-1235

It should be stored in the tool namespace as read-only.

Keep the latest 10.

Endpoints

GET /api/v1/tool/<toolname>/configReturns the current configuration if any or 404 if none found (returning it as-is, without filling up the defaults)
POST /api/v1/tool/<toolname>/configUpdates the configuration with the given one (storing it as-is, without filling up the defaults) - using the Config datastructure
POST /api/v1/tool/<toolname>/deployCreates a new deployment (Deployment datastructure) and starts all the builds from the stored configuration
GET /api/v1/tool/<toolname>/deploy/<deploy-id>Updates the deployment (if not in terminal "finished" or "error" states) and returns the deployment info (see details below)
GET /openapi.jsonReturns the openapi definition

Note the <toolname> in the path, currently we will just check that the user (as passed in the ssl header) is the same as the tool in the path, but this opens allowing to deploy a tool from a different user once we have proper user auth.

Details on the call to POST /tool/<toolname>/deploy

The call to the endpoint should create a deployment data structure (see below), and return it's ID.

It should cleanup the oldest deployments if reaching the quota limit.

It should trigger all the builds in parallel, we will have to play with tekton on how it handles many parallel builds, but should not be an issue

Details on the call to GET /tool/<toolname>/deploy/<deploy-id>

This should update the Deployment datastructure in k8s and return the updated one.

We might want to implement a background process for the updating of the datastructure when needing to do actual job deployments, but we can wait until the api is more stable as it might require evaluating alternatives (https://fastapi.tiangolo.com/tutorial/background-tasks, celery, redis, tekton, ...).

Related Objects

StatusSubtypeAssignedTask
ResolvedLucasWerkmeister
Resolvedmatmarex
ResolvedLegoktm
ResolvedLegoktm
In Progressdcaro
Resolveddcaro
In Progresskomla
Resolveddcaro
Resolveddcaro
Resolveddcaro
Opendcaro
Resolveddcaro
Opendcaro
Opendcaro
Resolveddcaro
ResolvedSlst2020
Resolveddcaro
ResolvedSlst2020
ResolvedSlst2020
Resolveddcaro
ResolvedSlst2020
OpenNone
Resolved aborrero
Resolveddcaro
Resolveddcaro
Resolveddcaro
Resolveddcaro

Event Timeline

dcaro renamed this task from [component-api] Get a skeleton of API webservice (unrefined) to [component-api] Get a skeleton of API webservice.Apr 10 2024, 9:45 AM
dcaro renamed this task from [component-api] Get a skeleton of API webservice to [component-api] Get a skeleton of API webservice and implement `/tool/<toolname>/deploy` with build-only features.
dcaro updated the task description. (Show Details)
dcaro triaged this task as High priority.Apr 10 2024, 10:53 AM
dcaro renamed this task from [component-api] Get a skeleton of API webservice and implement `/tool/<toolname>/deploy` with build-only features to [components-api] Get a skeleton of API webservice and implement `/tool/<toolname>/deploy` with build-only features.Apr 16 2024, 12:29 PM

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

api-gateway: bump to 0.0.32-20240731095342-26fae004

The initial boilerplate is done and deployed everywhere. The current endpoints are /healthz and /, which returns a 'hello world' json response.

Slst2020 changed the task status from Open to In Progress.Jul 31 2024, 12:16 PM
Slst2020 moved this task from Ready to be worked on to Toolforge iteration 13 on the Toolforge board.
Slst2020 edited projects, added Toolforge (Toolforge iteration 13); removed Toolforge.
Slst2020 moved this task from Next Up to In Progress on the Toolforge (Toolforge iteration 13) board.
dcaro renamed this task from [components-api] Get a skeleton of API webservice and implement `/tool/<toolname>/deploy` with build-only features to [components-api] Get a skeleton of API webservice and implement `/tool/<toolname>/deploy` with single continuous job deployment only.Nov 5 2024, 9:48 AM

I think this can be considered done no?

I think this can be considered done no?

I think so!

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

components-api: bump to 0.0.48-20241010123512-f12ab9d2