Skip to content

Refactor: move CE project selection to job creation time#2109

Open
ElePT wants to merge 4 commits into
mainfrom
refactor-ce-project
Open

Refactor: move CE project selection to job creation time#2109
ElePT wants to merge 4 commits into
mainfrom
refactor-ce-project

Conversation

@ElePT
Copy link
Copy Markdown
Collaborator

@ElePT ElePT commented May 11, 2026

Summary

This PR is built on top of the changes from #2108 and is currently blocked by it.

Up until now the gateway selected a Code Engine project the first time the scheduler touched a job, deep inside FleetsRunner. This PR moves that decision to RunJobSerializer.create(), the moment the job is written to the database.

The zone-lookup logic (reading FLEETS_PROFILE_ZONE_MAP and querying CodeEngineProject by zone) moves into a new select_ce_project() helper in core/model_managers/. The serializer calls it for every Fleets job and writes the chosen project onto the job record in the same save, so the runner never has to figure this out. If no suitable project exists the API returns a 400 right away instead of the job sitting in the queue and failing later.

On the runner side, _get_or_assign_project() is replaced by a much simpler _get_project() that just reads and validates whatever the serializer already put there.

Details and comments

This PR also fixes thesync_ce_project management command to define two separate initialization paths:

  • a single_project path that uses the existing CE_PROJECT_ID variable. This path assumes automatic zone selection is available for resource provisioning (which is not the case currently, but should be in the future).
  • a multi-project path with 2 new variables:CE_ZONE lets single-project deployments pin their project to an availability zone, and CE_PROJECTS accepts a JSON array for multi-zone setups where each zone has its own CE project.

@ElePT ElePT changed the title Refactor: Move CE project selection to job creation time Refactor: move CE project selection to job creation time May 11, 2026
@ElePT ElePT marked this pull request as ready for review May 12, 2026 15:09
@ElePT ElePT requested a review from a team as a code owner May 12, 2026 15:09
Copy link
Copy Markdown
Member

@Tansito Tansito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially the code here looks good to me but I would like to take a better look as soon as we merge #2108 . With less changes it will be quite easier.

ElePT added 4 commits May 15, 2026 16:33
…at didn't really provide the functionality we needed. The new implementation updates the management command and supports both single and multi zone setups.
@ElePT ElePT force-pushed the refactor-ce-project branch from 40e5eff to 0081b73 Compare May 15, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants