Skip to content

apollo_config_manager: add sender channel to the config manager runner#13477

Open
ArniStarkware wants to merge 1 commit intomainfrom
arni/config_manager/add_sender_channel_to_config_manager_runnner
Open

apollo_config_manager: add sender channel to the config manager runner#13477
ArniStarkware wants to merge 1 commit intomainfrom
arni/config_manager/add_sender_channel_to_config_manager_runnner

Conversation

@ArniStarkware
Copy link
Copy Markdown
Contributor

@ArniStarkware ArniStarkware commented Mar 25, 2026

Note

Medium Risk
Touches live config reload/update flow by switching change detection to a tokio::sync::watch channel, which could affect when/if dynamic config updates propagate. Still calls the existing config_manager_client update path, but now only after channel state changes.

Overview
ConfigManagerRunner now owns a tokio::sync::watch sender/receiver pair and uses it as the source of truth for the latest NodeDynamicConfig, replacing the prior internal latest_node_dynamic_config field.

update_config now returns Result<()>, computes diffs against the channel’s current value via send_if_modified, logs per-key changes through a new free log_config_diff helper, and only pushes updates (and calls set_node_dynamic_config) when the config actually changes. Node component wiring and runner tests are updated to create/pass the watch channel and validate updates by reading from it.

Reviewed by Cursor Bugbot for commit 0c934fc. Bugbot is set up for automated code reviews on this repo. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

ArniStarkware commented Mar 25, 2026

@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 28fcbd5 to b4eb1e5 Compare March 29, 2026 16:47
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from b4eb1e5 to 65e2e26 Compare March 29, 2026 18:19
@ArniStarkware ArniStarkware changed the base branch from main to graphite-base/13477 March 30, 2026 09:11
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 65e2e26 to 4973804 Compare March 30, 2026 09:11
@ArniStarkware ArniStarkware changed the base branch from graphite-base/13477 to arni/infra/component_client_client_as_enum March 30, 2026 09:11
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 4973804 to f157278 Compare March 30, 2026 11:08
@ArniStarkware ArniStarkware force-pushed the arni/infra/component_client_client_as_enum branch from 7d39183 to 8868d60 Compare March 30, 2026 11:08
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from f157278 to 1a4208c Compare March 30, 2026 11:20
@ArniStarkware ArniStarkware force-pushed the arni/infra/component_client_client_as_enum branch from 8868d60 to 00e3f97 Compare March 30, 2026 11:20
Copy link
Copy Markdown
Collaborator

@nadin-Starkware nadin-Starkware left a comment

Choose a reason for hiding this comment

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

@nadin-Starkware reviewed 3 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on ArniStarkware).


crates/apollo_config_manager/src/config_manager_runner.rs line 150 at r1 (raw file):

            // block.
            match self.dynamic_config_tx.send(node_dynamic_config.clone()) {
                Ok(()) => info!("Successfully sent node dynamic config to the channel"),

Please change it to debug

Code quote:

info

crates/apollo_config_manager/src/config_manager_runner.rs line 158 at r1 (raw file):

            match self
                .config_manager_client
                .set_node_dynamic_config(node_dynamic_config.clone())

Please remove

Code quote:

clone()

crates/apollo_node/src/components.rs line 164 at r1 (raw file):

                    .expect("Config Manager config should be set");
                // TODO(Arni): remove the config_manager.
                let config_manger =

Please fix the typo

Suggestion:

config_manager

@ArniStarkware ArniStarkware changed the base branch from arni/infra/component_client_client_as_enum to graphite-base/13477 March 30, 2026 16:33
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 1a4208c to 259f73a Compare March 30, 2026 17:20
@ArniStarkware ArniStarkware changed the base branch from graphite-base/13477 to arni/infra/component_client_client_as_enum March 30, 2026 17:20
Copy link
Copy Markdown
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

@ArniStarkware made 3 comments.
Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on nadin-Starkware).


crates/apollo_config_manager/src/config_manager_runner.rs line 150 at r1 (raw file):

Previously, nadin-Starkware (Nadin Jbara) wrote…

Please change it to debug

Done.


crates/apollo_config_manager/src/config_manager_runner.rs line 158 at r1 (raw file):

Previously, nadin-Starkware (Nadin Jbara) wrote…

Please remove

Done. Note, this changes the return type of this function. Luckily, the return value of this function was never used.


crates/apollo_node/src/components.rs line 164 at r1 (raw file):

Previously, nadin-Starkware (Nadin Jbara) wrote…

Please fix the typo

Done.

@ArniStarkware ArniStarkware force-pushed the arni/infra/component_client_client_as_enum branch from 3be4b39 to 5046eba Compare March 30, 2026 17:26
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 259f73a to ac8af19 Compare March 30, 2026 17:26
Copy link
Copy Markdown
Collaborator

@nadin-Starkware nadin-Starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@nadin-Starkware reviewed 3 files and all commit messages, made 1 comment, and resolved 3 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArniStarkware).

@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from ac8af19 to 65bfb02 Compare March 31, 2026 13:46
@ArniStarkware ArniStarkware force-pushed the arni/infra/component_client_client_as_enum branch from 5046eba to 2b86e25 Compare March 31, 2026 13:46
@ArniStarkware ArniStarkware marked this pull request as ready for review March 31, 2026 15:04
@ArniStarkware ArniStarkware force-pushed the arni/infra/component_client_client_as_enum branch from 1cfe58b to a93365a Compare April 5, 2026 10:25
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from dac3698 to 27d4ea6 Compare April 5, 2026 12:02
Copy link
Copy Markdown
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

@Itay-Tsabary-Starkware made 2 comments.

send_if_modified — done, switched to send_if_modified.

Test comment — the comment is still relevant at this PR level. set_node_dynamic_config exists here and is called by the runner. It's only removed in the downstream remove_client_from_runner PR. The note warns that we don't validate the correct config is passed — that validation would require .withf() on the mock, which isn't worth adding since the method is removed shortly downstream.

Copy link
Copy Markdown
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

@ArniStarkware made 3 comments.
Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on Itay-Tsabary-Starkware and nadin-Starkware).


crates/apollo_config_manager/src/config_manager_runner.rs line 37 at r3 (raw file):

Previously, nadin-Starkware (Nadin Jbara) wrote…

Please rename to _dynamic_config_rx

Done.


crates/apollo_config_manager/src/config_manager_runner.rs line 137 at r3 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

This entire logic can be very-much simplified by using https://docs.rs/tokio/latest/tokio/sync/watch/struct.Sender.html#method.send_if_modified

Done.


crates/apollo_config_manager/src/config_manager_runner_tests.rs line 128 at r3 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Still relevant? Isn't that method removed?

The method set_node_dynamic_config has been removed upstream. This is why the comment states: "This method is soon to be replaced."

@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 27d4ea6 to 71aaca7 Compare April 5, 2026 14:30
@ArniStarkware ArniStarkware changed the base branch from arni/infra/component_client_client_as_enum to graphite-base/13477 April 6, 2026 07:17
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 71aaca7 to 97319e3 Compare April 6, 2026 07:51
@ArniStarkware ArniStarkware changed the base branch from graphite-base/13477 to main April 6, 2026 07:51
@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 97319e3 to 717f753 Compare April 6, 2026 08:50
Copy link
Copy Markdown
Collaborator

@nadin-Starkware nadin-Starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@nadin-Starkware made 1 comment and resolved 1 discussion.
Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on Itay-Tsabary-Starkware).

Copy link
Copy Markdown
Collaborator

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

@Itay-Tsabary-Starkware made 3 comments and resolved 2 discussions.
Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on ArniStarkware and nadin-Starkware).


crates/apollo_config_manager/src/config_manager_runner.rs line 142 at r7 (raw file):

        let changed = self.dynamic_config_tx.send_if_modified(|current| {
            if *current == node_dynamic_config {

Does it make sense to compare the references here? That is,
current == &node_dynamic_config

Code quote:

if *current == node_dynamic_config

crates/apollo_config_manager/src/config_manager_runner.rs line 146 at r7 (raw file):

            }
            Self::log_config_diff(current, &node_dynamic_config);
            *current = node_dynamic_config.clone();

Please add a todo to remove this clone, I suspect it is currently required only due to the about-to-be-removed block at the end.

Code quote:

.clone();

crates/apollo_config_manager/src/config_manager_runner.rs line 182 at r7 (raw file):

                info!("ConfigManagerRunner: {key} changed from {old_value} to {new_value}");
            }
        }

Is there a reason for this function to be a part of the struct's impl block?

Code quote:

    fn log_config_diff(old_config: &NodeDynamicConfig, new_config: &NodeDynamicConfig) {
        let old_config = get_config_presentation(old_config, false).unwrap();
        let new_config = get_config_presentation(new_config, false).unwrap();
        let all_keys: BTreeSet<_> = old_config
            .as_object()
            .unwrap()
            .keys()
            .chain(new_config.as_object().unwrap().keys())
            .collect();

        for key in all_keys {
            let old_value = old_config.as_object().unwrap().get(key).unwrap_or(&Value::Null);
            let new_value = new_config.as_object().unwrap().get(key).unwrap_or(&Value::Null);

            if old_value != new_value {
                info!("ConfigManagerRunner: {key} changed from {old_value} to {new_value}");
            }
        }

@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch 2 times, most recently from 4c2a99f to 0c934fc Compare April 6, 2026 11:43
Copy link
Copy Markdown
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

@ArniStarkware made 3 comments.
Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on Itay-Tsabary-Starkware and nadin-Starkware).


crates/apollo_config_manager/src/config_manager_runner.rs line 142 at r7 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Does it make sense to compare the references here? That is,
current == &node_dynamic_config

Done.


crates/apollo_config_manager/src/config_manager_runner.rs line 146 at r7 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Please add a todo to remove this clone, I suspect it is currently required only due to the about-to-be-removed block at the end.

Done.


crates/apollo_config_manager/src/config_manager_runner.rs line 182 at r7 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Is there a reason for this function to be a part of the struct's impl block?

Done.

Copy link
Copy Markdown
Collaborator

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@Itay-Tsabary-Starkware reviewed 3 files and all commit messages, made 1 comment, and resolved 3 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on nadin-Starkware).

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 12, 2026

PR Summary

Medium Risk
Config update propagation is refactored to use a tokio::sync::watch channel with change detection, which can affect when/if downstream components observe updates and introduces new concurrency/lifecycle considerations.

Overview
ConfigManagerRunner now publishes NodeDynamicConfig updates through a tokio::sync::watch channel instead of storing latest_node_dynamic_config internally and returning the config from update_config.

update_config sends only when the config actually changes (logging diffs), adds a debug log on successful send, and temporarily keeps the existing config_manager_client.set_node_dynamic_config call behind a TODO for later removal. Node startup wiring (apollo_node components.rs) and runner tests are updated to create/pass the watch Sender/Receiver and to assert updates by reading from the channel; log_config_diff is extracted to a free function.

Reviewed by Cursor Bugbot for commit 2d54569. Bugbot is set up for automated code reviews on this repo. Configure here.

@ArniStarkware ArniStarkware force-pushed the arni/config_manager/add_sender_channel_to_config_manager_runnner branch from 35c4ba3 to 2d54569 Compare April 12, 2026 15:22
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.

4 participants