-
Notifications
You must be signed in to change notification settings - Fork 95
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
Endpoint metadata support from static config #160
Conversation
Parses generic yaml key values into a json value and in order to use as the endpoint's metadata. Values under the `quilkin.dev` key is reserved for quilkin usage. Extracts token into the endpoint object since we don't want to traverse the json value on each lookup. Removes name and connection ID from the static Endpoint config struct. Work on #10 Fixes #152
@@ -31,6 +32,7 @@ pub(crate) mod cluster_manager { | |||
#[derive(Clone, Debug, Eq, PartialEq)] | |||
pub struct Endpoint { | |||
pub address: SocketAddr, | |||
pub tokens: HashSet<Vec<u8>>, |
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.
Should we be capturing tokens at all here, since this seems like it's all handled by the Filters?
If you can define metadata on an Endpoint in the static section - is that not enough? Especially since the key for the token lookup or storage is configurable in (Edit: got this confused with dynamic metadata)TokenRouter
?
Should the Filter define which metadata value has all the tokens in it. so it is configurable? Rather than have it be hard-coded? (with a standard default as well)
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.
The main reason was to pre-process it so that tokens are simple and efficient to query. If we treat it as other metadata then the token router or any other filter that needs the info would need to traverse the json structure and scan a list each time.
Re pulling it out of the metadata, we can consider these as special cases since its primarily quilkin that needs them, compared to other metadata that the control plane might pass to a user's custom filter for example.
Should the Filter define which metadata value has all the tokens in it. so it is configurable? Rather than have it be hard-coded? (with a standard default as well)
I'm not following the advantage of having it configurable? if e.g a user filter needs the tokens accessible on a particular field they can still put them under the desired key in the metadata without affecting any quilkin use case but I can't see why one would want it to be configurable if its already present in the endpoint itself?
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.
The main reason was to pre-process it so that tokens are simple and efficient to query.
That makes sense - it's a performance concern. We will need to document how we use xDS really well, and include this 👍
I'm not following the advantage of having it configurable?
That's a fair point. I am wondering if at some point someone might want it to be configurable at the config.yaml file level - basically as a system wide configuration parameter -- but we could also cross that bridge when we come to it.
@@ -31,6 +32,7 @@ pub(crate) mod cluster_manager { | |||
#[derive(Clone, Debug, Eq, PartialEq)] | |||
pub struct Endpoint { | |||
pub address: SocketAddr, | |||
pub tokens: HashSet<Vec<u8>>, |
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.
Just a mental note for me "tokens" as a name totally makes sense, since we have a TokenRouter
👍
src/config/endpoints.rs
Outdated
@@ -14,7 +14,11 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
use crate::config::EndPoint; | |||
pub const ENDPOINT_METADATA_KEY_PREFIX: &str = "quilkin.dev"; | |||
pub const ENDPOINT_METADATA_TOKEN_KEY: &str = "endpoint.tokens"; |
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.
pub const ENDPOINT_METADATA_TOKEN_KEY: &str = "endpoint.tokens"; | |
pub const ENDPOINT_METADATA_TOKEN_KEY: &str = "tokens"; |
Is "endpoint" redundant? The metadata is on the Endpoint already?
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.
Indeed, fixed!
@@ -28,7 +32,7 @@ pub struct IndexOutOfRangeError; | |||
|
|||
/// Endpoints represents the set of all known upstream endpoints. | |||
#[derive(Clone, Debug, PartialEq)] | |||
pub struct Endpoints(Arc<Vec<EndPoint>>); | |||
pub struct Endpoints(Arc<Vec<Endpoint>>); |
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.
That a nice naming.
src/config/endpoints.rs
Outdated
@@ -14,7 +14,11 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
use crate::config::EndPoint; | |||
pub const ENDPOINT_METADATA_KEY_PREFIX: &str = "quilkin.dev"; |
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.
I feel like we have "quilkin.dev" as a prefix in quite a few places around -- do we want to find somewhere central for this? Some kind of centrally located "KEY_PREFIX" const?
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.
The issue preventing reusing currently is const values must be assigned literals in rust so we can't it easily unfortunately, the only other usage today is capturedbytes' quilkin.dev/captured_bytes
and we can't concatenate the prefix since that's a const :P not currently sure if there's a workaround atm
address: addr, | ||
connection_ids: vec![], | ||
}; | ||
let endpoint = Endpoint::from_address(addr); |
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.
Sooo much cleaner 👍
src/extensions/filters/debug.rs
Outdated
@@ -103,7 +103,7 @@ impl Filter for Debug { | |||
} | |||
|
|||
fn on_upstream_receive(&self, ctx: UpstreamContext) -> Option<UpstreamResponse> { | |||
info!(self.log, "received endpoint packet"; "endpoint" => ctx.endpoint.name.clone(), | |||
info!(self.log, "received endpoint packet"; |
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.
Should we output the endpoint address and port here? Since that would be the unique identifier? Otherwise, we don't know where the information is coming from.
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.
Added socket addres to log message
src/proxy/server/error.rs
Outdated
@@ -35,6 +36,7 @@ impl Display for Error { | |||
Error::Initialize(reason) => write!(f, "failed to startup properly: {}", reason), | |||
Error::Session(inner) => write!(f, "session error: {}", inner), | |||
Error::Bind(inner) => write!(f, "failed to bind to port: {}", inner), | |||
Error::InvalidEndpointConfig(reason) => write!(f, "{}", reason), |
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.
Error::InvalidEndpointConfig(reason) => write!(f, "{}", reason), | |
Error::InvalidEndpointConfig(reason) => write!(f, "invalid endpoint configuration: {}", reason), |
🤷 ?
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.
Done!
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.
LGTM!
Parses generic yaml key values into a json value and in order to
use as the endpoint's metadata.
Values under the
quilkin.dev
key is reserved for quilkin usage.Extracts token into the endpoint object since we don't want to traverse
the json value on each lookup.
Removes name and connection ID from the static Endpoint config struct.
Work on #10
Fixes #152
Bulk of the changes are updates to old references and using the new one, most of the relevant changes are around server/mod.rs, config/ and xds/