From 1ac6da8c7e0e0da93917f7a1da7dab3cb7ebee33 Mon Sep 17 00:00:00 2001 From: lmatz Date: Tue, 31 Jan 2023 19:08:57 +0800 Subject: [PATCH] fix(meta): backward compatible with host when running in mem meta backend (#7628) See #7616, the previous pr only changes the etcd backend. It fails when running mem backend. Now both etcd backend and mem backend run with the same `meta-endpoint` when `meta-endpoint` is not provided, i.e. `format!("{}:{}", meta_addr, listen_addr.port())` Approved-By: arkbriar --- src/meta/src/lib.rs | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/meta/src/lib.rs b/src/meta/src/lib.rs index da40623e9c34a..429c52e95e159 100644 --- a/src/meta/src/lib.rs +++ b/src/meta/src/lib.rs @@ -141,27 +141,22 @@ pub fn start(opts: MetaNodeOpts) -> Pin + Send>> { let meta_addr = opts.host.unwrap_or_else(|| opts.listen_addr.clone()); let dashboard_addr = opts.dashboard_host.map(|x| x.parse().unwrap()); let prometheus_addr = opts.prometheus_host.map(|x| x.parse().unwrap()); - let (meta_endpoint, backend) = match opts.backend { - Backend::Etcd => ( - opts.meta_endpoint - .unwrap_or_else(|| format!("{}:{}", meta_addr, listen_addr.port())), - MetaStoreBackend::Etcd { - endpoints: opts - .etcd_endpoints - .split(',') - .map(|x| x.to_string()) - .collect(), - credentials: match opts.etcd_auth { - true => Some((opts.etcd_username, opts.etcd_password)), - false => None, - }, + let meta_endpoint = opts + .meta_endpoint + .unwrap_or_else(|| format!("{}:{}", meta_addr, listen_addr.port())); + let backend = match opts.backend { + Backend::Etcd => MetaStoreBackend::Etcd { + endpoints: opts + .etcd_endpoints + .split(',') + .map(|x| x.to_string()) + .collect(), + credentials: match opts.etcd_auth { + true => Some((opts.etcd_username, opts.etcd_password)), + false => None, }, - ), - Backend::Mem => ( - opts.meta_endpoint - .unwrap_or_else(|| opts.listen_addr.clone()), - MetaStoreBackend::Mem, - ), + }, + Backend::Mem => MetaStoreBackend::Mem, }; let max_heartbeat_interval =