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

Add process-compose driver in osrdyne #8573

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

leovalais
Copy link
Contributor

@leovalais leovalais commented Aug 23, 2024

Required to dev on editoast for macs (no Docker host networking available).

//! A driver to manage workers using [process-compose](https://github.com/F1bonacc1/process-compose) REST API.
//!
//! This driver is especially useful for backend development on systems where Docker host networking is not available (👀 macOS).
//!
//! This driver is primarily intended for development purposes. It is not recommended to use it in production.
//! Multiple process-compose instances are not supported.
//!
//! # Implementation details
//!
//! ## Spawning workers
//!
//! `process-compose` configuration is read at startup and cannot be modified while `process-compose` is running.
//! This has several unfortunate consequences on how the driver works, especially on the scaling part. Indeed,
//! we cant just edit the YAML in the driver as there's no way to reload the configuration.
//!
//! process-compose allows a process to be scaled (`sh$ process-compose process scale <process> <count>`). However,
//! we cannot set the configuration of a replicated process. Each one of them has to follow the configuration defined
//! in `process-compose.yaml`. **Including environment variables**. This is particularly problematic for the driver
//! which has to set a different WORKER_{ID,KEY,AMQP_URI} for each process.
//!
//! We overcome this by reading the values of the WORKER_* variables from tmp files when the process start. These files
//! are written by the driver just before a process starts.
//!
//! ## Identifying workers
//!
//! Unlike Docker or Kube, process-compose doesn't let us tag each process individually. We have to store in the driver
//! a mapping {PID => (Key, Uuid)} to keep track of which process is assigned to which worker key.
//!
//! ## Dealing with `process-compose process scale` behaviour
//!
//! process-compose scaling may rename the process being scale. For example, if when starting PC whe have:
//!
//! ```
//! core
//! editoast
//! front
//! # ...
//! ```
//!
//! and we scale `core` to 3 (`process-compose process scale core 3`), we will have:
//!
//! ```
//! core-0
//! core-1
//! core-2
//! editoast
//! front
//! ```
//!
//! Note how the original `core` process is now named `core-0`.
//! Now, if we want to scale even more, `process-compose process scale core 5`, we will fail since `core` doesn't exist anymore.
//! We have to run `process-compose process scale core-0 5` instead.
//!
//! The reverse applies when scaling down: `process-compose process scale core-0 1` will rename `core-0` to `core`.
//!
//! # Known limitations
//!
//! * Restarting the osrdyne process but not the other will spawn new workers for each message queue (the driver lost
//! its internal mapping).
//! * The driver doesn't cleanup disabled or errored workers.

@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 227 lines in your changes missing coverage. Please review.

Project coverage is 36.93%. Comparing base (3eecd56) to head (e77107d).
Report is 127 commits behind head on dev.

Files with missing lines Patch % Lines
osrdyne/src/drivers/process_compose.rs 0.00% 219 Missing ⚠️
osrdyne/src/drivers/docker.rs 0.00% 2 Missing ⚠️
osrdyne/src/drivers/kubernetes.rs 0.00% 2 Missing ⚠️
osrdyne/src/drivers/noop.rs 0.00% 2 Missing ⚠️
osrdyne/src/drivers/worker_driver.rs 0.00% 1 Missing ⚠️
osrdyne/src/pool.rs 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #8573      +/-   ##
============================================
+ Coverage     36.84%   36.93%   +0.08%     
- Complexity     2175     2212      +37     
============================================
  Files          1279     1257      -22     
  Lines        118794   114293    -4501     
  Branches       3188     3188              
============================================
- Hits          43775    42213    -1562     
+ Misses        73134    70184    -2950     
- Partials       1885     1896      +11     
Flag Coverage Δ
core 74.79% <ø> (-0.08%) ⬇️
editoast 72.13% <ø> (+6.03%) ⬆️
front 14.96% <ø> (-0.89%) ⬇️
gateway 2.20% <ø> (ø)
osrdyne 2.60% <0.00%> (-0.11%) ⬇️
railjson_generator 87.49% <ø> (ø)
tests 86.37% <ø> (+13.44%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leovalais leovalais marked this pull request as ready for review September 9, 2024 11:57
@leovalais leovalais requested a review from a team as a code owner September 9, 2024 11:57
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.

3 participants