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: make serving config compatible with numaflow-core configs #2291

Merged
merged 7 commits into from
Dec 19, 2024

Conversation

BulkBeing
Copy link
Contributor

@BulkBeing BulkBeing commented Dec 17, 2024

Closes #2280

  • Removes files in serving/config/ and moved the values to corresponding struct's Default trait implementation
  • Removes usage of global static configuration. Instead, parse the config in the starting of the application and pass it around.

Tested by running the pipeline https://github.com/numaproj/numaproj-demo/blob/main/serving-demo/README.md

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 81.58348% with 107 lines in your changes missing coverage. Please review.

Project coverage is 65.76%. Comparing base (10b4978) to head (bf0c330).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
rust/numaflow-core/src/config/components.rs 0.00% 36 Missing ⚠️
rust/numaflow/src/main.rs 0.00% 22 Missing ⚠️
rust/serving/src/lib.rs 0.00% 17 Missing ⚠️
rust/serving/src/config.rs 90.30% 16 Missing ⚠️
rust/serving/src/app.rs 92.45% 8 Missing ⚠️
rust/serving/src/app/callback.rs 86.11% 5 Missing ⚠️
rust/serving/src/app/jetstream_proxy.rs 97.33% 2 Missing ⚠️
rust/numaflow-core/src/shared/create_components.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2291      +/-   ##
==========================================
+ Coverage   65.49%   65.76%   +0.27%     
==========================================
  Files         346      346              
  Lines       42394    42767     +373     
==========================================
+ Hits        27764    28127     +363     
- Misses      13560    13562       +2     
- Partials     1070     1078       +8     

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

@vigith vigith changed the title Make serving config compatible with numaflow-core configs chore: make serving config compatible with numaflow-core configs Dec 17, 2024
env::var(ENV_NUMAFLOW_SERVING_JETSTREAM_PASSWORD),
) {
(Ok(user), Ok(password)) => {
let js_client = match js_config.auth.as_ref() {
Copy link
Member

Choose a reason for hiding this comment

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

this will go away eventually right? we will directly write to ISB via the pipeline framework.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, for now I'm trying to get it to a working state with minimal changes.

@BulkBeing BulkBeing marked this pull request as ready for review December 18, 2024 08:10
@BulkBeing BulkBeing requested a review from whynowy as a code owner December 18, 2024 08:10
@BulkBeing BulkBeing requested review from yhl25 and vigith December 18, 2024 08:17
if let Some(ttl) = cfg.store.ttl {
if ttl.is_negative() {
return Err(Error::Config(format!(
"TTL value for Redis store can not be negative. Provided value = {ttl:?}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"TTL value for Redis store can not be negative. Provided value = {ttl:?}"
"TTL value for the store can not be negative. Provided value = {ttl:?}"

removed the word Redis because DDB night come too.

const NUMAFLOW_RESP_ARRAY_LEN: &str = "Numaflow-Array-Len";
const NUMAFLOW_RESP_ARRAY_IDX_LEN: &str = "Numaflow-Array-Index-Len";

#[derive(Clone)]
struct ProxyState<T> {
Copy link
Member

Choose a reason for hiding this comment

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

don't the state need to be Clone anymore? make sure it is a cheap clone if there is a need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The router now takes Arc<ProxyState> as the state.


if let Err(e) = publish_to_jetstream(
proxy_state.stream,
proxy_state.stream.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

is this clone too much for every request? we know that String is a const since it is stream name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, a lot of clones are happening for Router states. I will work on a separate PR to avoid those. Need to figure out whether to use Arc of the struct or Arc of individual fields, some handlers only need part of the application state. Since config lives for the duration of the application, we could make all strings to &'static str with Box::leak to avoid all cloning or use Arc<str> instead of String for cheaper cloning.

Copy link
Member

Choose a reason for hiding this comment

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

please do as a follow up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

)
.await
{
// Deregister the ID in the callback proxy state if writing to Jetstream fails
let _ = proxy_state.callback.deregister(&id).await;
let _ = proxy_state.callback.clone().deregister(&id).await;
Copy link
Member

Choose a reason for hiding this comment

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

same for callback.clone

Comment on lines +17 to +21
const ENV_NUMAFLOW_SERVING_HOST_IP: &str = "NUMAFLOW_SERVING_HOST_IP";
const ENV_NUMAFLOW_SERVING_APP_PORT: &str = "NUMAFLOW_SERVING_APP_LISTEN_PORT";
const ENV_NUMAFLOW_SERVING_JETSTREAM_USER: &str = "NUMAFLOW_ISBSVC_JETSTREAM_USER";
const ENV_NUMAFLOW_SERVING_JETSTREAM_PASSWORD: &str = "NUMAFLOW_ISBSVC_JETSTREAM_PASSWORD";
const ENV_NUMAFLOW_SERVING_AUTH_TOKEN: &str = "NUMAFLOW_SERVING_AUTH_TOKEN";
Copy link
Member

Choose a reason for hiding this comment

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

create a mod called serving and move serving items there? config is getting bloated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the serving::config module. As of now, it not that big. I think single module is fine for now.

Copy link
Member

Choose a reason for hiding this comment

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

coverage is getting low

@BulkBeing BulkBeing merged commit f41e6ff into main Dec 19, 2024
28 checks passed
@BulkBeing BulkBeing deleted the serving-source-config branch December 19, 2024 05:00
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.

Config management for serving to merge it with numaflow core
3 participants