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: 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"
index = "index.html"
[admin_api]
bind_addr = "0.0.0.0:$((9900+$count))"
[admin]
api_bind_addr = "0.0.0.0:$((9900+$count))"
EOF
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);
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)?;
}
@ -70,7 +70,7 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
info!("Configure and run admin web server...");
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

View File

@ -66,8 +66,8 @@ bind_addr = "127.0.0.1:{web_port}"
root_domain = ".web.garage"
index = "index.html"
[admin_api]
bind_addr = "127.0.0.1:{admin_port}"
[admin]
api_bind_addr = "127.0.0.1:{admin_port}"
"#,
path = path.display(),
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("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);
// Build future for each request
@ -300,9 +317,8 @@ impl RpcHelper {
.collect::<Vec<_>>();
// Sort requests by (priorize ourself, priorize same zone, priorize low latency)
requests.sort_by_key(|(diffnode, diffzone, ping, _to, _fut)| {
(*diffnode, *diffzone, *ping)
});
requests
.sort_by_key(|(diffnode, diffzone, ping, _to, _fut)| (*diffnode, *diffzone, *ping));
// Make an iterator to take requests in their sorted order
let mut requests = requests.into_iter();
@ -317,6 +333,7 @@ impl RpcHelper {
// reach quorum, start some new requests.
while successes.len() + resp_stream.len() < quorum {
if let Some((_, _, _, req_to, fut)) = requests.next() {
let tracer = opentelemetry::global::tracer("garage");
let span = tracer.start(format!("RPC to {:?}", req_to));
resp_stream.push(tokio::spawn(
fut.with_context(Context::current_with_span(span)),
@ -385,7 +402,4 @@ impl RpcHelper {
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,
/// Configuration for the admin API endpoint
pub admin_api: AdminConfig,
pub admin: AdminConfig,
}
/// Configuration for S3 api
@ -103,9 +103,9 @@ pub struct WebConfig {
#[derive(Deserialize, Debug, Clone)]
pub struct AdminConfig {
/// 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
pub otlp_export_traces_to: Option<String>,
pub trace_sink: Option<String>,
}
fn default_sled_cache_capacity() -> u64 {