-
Notifications
You must be signed in to change notification settings - Fork 11
feat(config): migrate DogStatsD source to translated config #1898
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
Open
webern
wants to merge
8
commits into
m/scaffold
Choose a base branch
from
m/dsd-cutover
base: m/scaffold
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f994fb1
chore(config): dogstatsd config through the witness trait
webern e0d6471
chore(config): add configuration system lifecycle
webern 1d8bef2
chore(config): load configuration through the system
webern e0f758f
chore(config): drive dogstatsd source from typed config
webern cf768e4
feat(config): serve native config on /config/internal
webern 2718f4b
test(config): verify dogstatsd config on /config/internal
webern 75a3ca3
chore(config): create a replacement for config smoke tests
webern d101df5
reconcile elastic pool with SourceConfig cutover
webern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| //! Internal configuration API handler. | ||
| //! | ||
| //! Serves the ADP-native [`SalukiConfiguration`] as JSON on the privileged `/config/internal` | ||
| //! route. This is the observable surface used to verify translation end-to-end, and a secondary | ||
| //! operator-debugging aid alongside the source-shaped `/config` route. | ||
| //! | ||
| //! The handler holds the shared [`ConfigurationSystem`] and reads the translated master per request, | ||
| //! so it automatically reflects any later re-translation without changing this worker. The body is | ||
| //! served raw, without scrubbing, exactly like the existing privileged `/config` route; scrubbing | ||
| //! is a client-side display concern. | ||
| //! | ||
| //! [`SalukiConfiguration`]: agent-data-plane-config | ||
|
|
||
| use std::sync::Arc; | ||
|
|
||
| use agent_data_plane_config_system::ConfigurationSystem; | ||
| use async_trait::async_trait; | ||
| use http::StatusCode; | ||
| use saluki_api::{ | ||
| extract::State, | ||
| response::IntoResponse, | ||
| routing::{get, Router}, | ||
| APIHandler, DynamicRoute, EndpointType, | ||
| }; | ||
| use saluki_common::sync::shutdown::ShutdownHandle; | ||
| use saluki_core::runtime::{state::DataspaceRegistry, InitializationError, Supervisable, SupervisorFuture}; | ||
| use saluki_error::generic_error; | ||
|
|
||
| /// State for the internal configuration API handler. | ||
| #[derive(Clone)] | ||
| pub struct InternalConfigState { | ||
| system: Arc<ConfigurationSystem>, | ||
| } | ||
|
|
||
| /// An API handler for returning the ADP-native configuration. | ||
| /// | ||
| /// Exposes a single route -- `/config/internal` -- that serializes the translated | ||
| /// `SalukiConfiguration` to JSON. | ||
| pub struct InternalConfigAPIHandler { | ||
| state: InternalConfigState, | ||
| } | ||
|
|
||
| impl InternalConfigAPIHandler { | ||
| fn new(system: Arc<ConfigurationSystem>) -> Self { | ||
| Self { | ||
| state: InternalConfigState { system }, | ||
| } | ||
| } | ||
|
|
||
| async fn config_handler(State(state): State<InternalConfigState>) -> impl IntoResponse { | ||
| match serde_json::to_string(&state.system.saluki()) { | ||
| Ok(body) => (StatusCode::OK, body).into_response(), | ||
| Err(e) => ( | ||
| StatusCode::INTERNAL_SERVER_ERROR, | ||
| format!("Failed to serialize configuration: {}", e), | ||
| ) | ||
| .into_response(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl APIHandler for InternalConfigAPIHandler { | ||
| type State = InternalConfigState; | ||
|
|
||
| fn generate_initial_state(&self) -> Self::State { | ||
| self.state.clone() | ||
| } | ||
|
|
||
| fn generate_routes(&self) -> Router<Self::State> { | ||
| Router::new().route("/config/internal", get(Self::config_handler)) | ||
| } | ||
| } | ||
|
|
||
| /// A worker for exposing the ADP-native configuration. | ||
| /// | ||
| /// Asserts the `/config/internal` route on the privileged API endpoint. As the configuration may | ||
| /// contain sensitive data, the route is only present on the privileged endpoint. | ||
| pub struct InternalConfigWorker { | ||
| handler: InternalConfigAPIHandler, | ||
| } | ||
|
|
||
| impl InternalConfigWorker { | ||
| /// Creates a new [`InternalConfigWorker`] backed by the shared configuration system. | ||
| pub fn new(system: Arc<ConfigurationSystem>) -> Self { | ||
| Self { | ||
| handler: InternalConfigAPIHandler::new(system), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl Supervisable for InternalConfigWorker { | ||
| fn name(&self) -> &str { | ||
| "config-internal-api" | ||
| } | ||
|
|
||
| async fn initialize(&self, process_shutdown: ShutdownHandle) -> Result<SupervisorFuture, InitializationError> { | ||
| let config_route = DynamicRoute::http(EndpointType::Privileged, &self.handler); | ||
|
|
||
| Ok(Box::pin(async move { | ||
| DataspaceRegistry::try_current() | ||
| .ok_or_else(|| generic_error!("Dataspace not available."))? | ||
| .assert(config_route, "config-internal-api"); | ||
|
|
||
| process_shutdown.await; | ||
| Ok(()) | ||
| })) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In deployments that rely on
run_pathfor the default DogStatsD capture directory, this new construction path skips the oldfrom_configurationfixup that derivedrun_path/dsd_capturewhendogstatsd_capture_pathwas empty. The translator now leaves the default as an emptyPathBuf, andTrafficCapturerejects implicit captures with no configured path, soagent-data-plane dogstatsd capturewithout an explicit path regresses. Preserve therun_pathfallback in the translated/new path.Useful? React with 👍 / 👎.