Refactoring: rename config files, make modifications less invasive

This commit is contained in:
Alex 2022-02-22 15:25:13 +01:00
parent d9a35359bf
commit dc8d0496cc
Signed by untrusted user: lx
GPG key ID: 0E496D15096376BE
5 changed files with 155 additions and 141 deletions

View file

@ -45,8 +45,8 @@ bind_addr = "0.0.0.0:$((3920+$count))"
root_domain = ".web.garage.localhost" root_domain = ".web.garage.localhost"
index = "index.html" index = "index.html"
[admin_api] [admin]
bind_addr = "0.0.0.0:$((9900+$count))" api_bind_addr = "0.0.0.0:$((9900+$count))"
EOF EOF
echo -en "$LABEL configuration written to $CONF_PATH\n" echo -en "$LABEL configuration written to $CONF_PATH\n"

View file

@ -47,7 +47,7 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
let garage = Garage::new(config.clone(), db, background); let garage = Garage::new(config.clone(), db, background);
info!("Initialize tracing..."); info!("Initialize tracing...");
if let Some(export_to) = config.admin_api.otlp_export_traces_to { if let Some(export_to) = config.admin.trace_sink {
init_tracing(&export_to, garage.system.id)?; init_tracing(&export_to, garage.system.id)?;
} }
@ -70,7 +70,7 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
info!("Configure and run admin web server..."); info!("Configure and run admin web server...");
let admin_server = tokio::spawn( let admin_server = tokio::spawn(
admin_server_init.run(config.admin_api.bind_addr, wait_from(watch_cancel.clone())), admin_server_init.run(config.admin.api_bind_addr, wait_from(watch_cancel.clone())),
); );
// Stuff runs // Stuff runs

View file

@ -66,8 +66,8 @@ bind_addr = "127.0.0.1:{web_port}"
root_domain = ".web.garage" root_domain = ".web.garage"
index = "index.html" index = "index.html"
[admin_api] [admin]
bind_addr = "127.0.0.1:{admin_port}" api_bind_addr = "127.0.0.1:{admin_port}"
"#, "#,
path = path.display(), path = path.display(),
secret = GARAGE_TEST_SECRET, secret = GARAGE_TEST_SECRET,

View file

@ -238,7 +238,24 @@ impl RpcHelper {
span.set_attribute(KeyValue::new("to", format!("{:?}", to))); span.set_attribute(KeyValue::new("to", format!("{:?}", to)));
span.set_attribute(KeyValue::new("quorum", quorum as i64)); span.set_attribute(KeyValue::new("quorum", quorum as i64));
async { self.try_call_many_internal(endpoint, to, msg, strategy, quorum)
.with_context(Context::current_with_span(span))
.await
}
async fn try_call_many_internal<M, H, S>(
&self,
endpoint: &Arc<Endpoint<M, H>>,
to: &[Uuid],
msg: M,
strategy: RequestStrategy,
quorum: usize,
) -> Result<Vec<S>, Error>
where
M: Rpc<Response = Result<S, Error>> + 'static,
H: EndpointHandler<M> + 'static,
S: Send + 'static,
{
let msg = Arc::new(msg); let msg = Arc::new(msg);
// Build future for each request // Build future for each request
@ -300,9 +317,8 @@ impl RpcHelper {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
// Sort requests by (priorize ourself, priorize same zone, priorize low latency) // Sort requests by (priorize ourself, priorize same zone, priorize low latency)
requests.sort_by_key(|(diffnode, diffzone, ping, _to, _fut)| { requests
(*diffnode, *diffzone, *ping) .sort_by_key(|(diffnode, diffzone, ping, _to, _fut)| (*diffnode, *diffzone, *ping));
});
// Make an iterator to take requests in their sorted order // Make an iterator to take requests in their sorted order
let mut requests = requests.into_iter(); let mut requests = requests.into_iter();
@ -317,6 +333,7 @@ impl RpcHelper {
// reach quorum, start some new requests. // reach quorum, start some new requests.
while successes.len() + resp_stream.len() < quorum { while successes.len() + resp_stream.len() < quorum {
if let Some((_, _, _, req_to, fut)) = requests.next() { if let Some((_, _, _, req_to, fut)) = requests.next() {
let tracer = opentelemetry::global::tracer("garage");
let span = tracer.start(format!("RPC to {:?}", req_to)); let span = tracer.start(format!("RPC to {:?}", req_to));
resp_stream.push(tokio::spawn( resp_stream.push(tokio::spawn(
fut.with_context(Context::current_with_span(span)), fut.with_context(Context::current_with_span(span)),
@ -385,7 +402,4 @@ impl RpcHelper {
Err(Error::Quorum(quorum, successes.len(), to.len(), errors)) Err(Error::Quorum(quorum, successes.len(), to.len(), errors))
} }
} }
.with_context(Context::current_with_span(span))
.await
}
} }

View file

@ -75,7 +75,7 @@ pub struct Config {
pub s3_web: WebConfig, pub s3_web: WebConfig,
/// Configuration for the admin API endpoint /// Configuration for the admin API endpoint
pub admin_api: AdminConfig, pub admin: AdminConfig,
} }
/// Configuration for S3 api /// Configuration for S3 api
@ -103,9 +103,9 @@ pub struct WebConfig {
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
pub struct AdminConfig { pub struct AdminConfig {
/// Address and port to bind for admin API serving /// Address and port to bind for admin API serving
pub bind_addr: SocketAddr, pub api_bind_addr: SocketAddr,
/// OTLP server to where to export traces /// OTLP server to where to export traces
pub otlp_export_traces_to: Option<String>, pub trace_sink: Option<String>,
} }
fn default_sled_cache_capacity() -> u64 { fn default_sled_cache_capacity() -> u64 {