From 4503c3eb0f5c31cc8b9fc39477ac47eadd74576d Mon Sep 17 00:00:00 2001 From: maco Date: Mon, 20 May 2024 14:40:04 +0800 Subject: [PATCH] fix: revert by suggestion --- src/cmd/src/datanode.rs | 13 ------------- src/datanode/src/config.rs | 3 --- src/datanode/src/error.rs | 9 --------- src/datanode/src/service.rs | 22 ++++++++++------------ 4 files changed, 10 insertions(+), 37 deletions(-) diff --git a/src/cmd/src/datanode.rs b/src/cmd/src/datanode.rs index 083aa6c4a012..c21e03499973 100644 --- a/src/cmd/src/datanode.rs +++ b/src/cmd/src/datanode.rs @@ -26,7 +26,6 @@ use datanode::config::DatanodeOptions; use datanode::datanode::{Datanode, DatanodeBuilder}; use datanode::service::DatanodeServiceBuilder; use meta_client::MetaClientOptions; -use servers::tls::{TlsMode, TlsOption}; use servers::Mode; use snafu::{OptionExt, ResultExt}; @@ -133,12 +132,6 @@ struct StartCommand { http_timeout: Option, #[clap(long, default_value = "GREPTIMEDB_DATANODE")] env_prefix: String, - #[clap(long)] - tls_mode: Option, - #[clap(long)] - tls_cert_path: Option, - #[clap(long)] - tls_key_path: Option, } impl StartCommand { @@ -227,11 +220,6 @@ impl StartCommand { opts.http.timeout = Duration::from_secs(http_timeout) } - opts.tls = TlsOption::new( - self.tls_mode.clone(), - self.tls_cert_path.clone(), - self.tls_key_path.clone(), - ); // Disable dashboard in datanode. opts.http.disable_dashboard = true; @@ -271,7 +259,6 @@ impl StartCommand { let services = DatanodeServiceBuilder::new(&opts) .with_default_grpc_server(&datanode.region_server()) - .context(StartDatanodeSnafu)? .enable_http_service() .build() .await diff --git a/src/datanode/src/config.rs b/src/datanode/src/config.rs index b13fb70a0d74..ec278d3c4247 100644 --- a/src/datanode/src/config.rs +++ b/src/datanode/src/config.rs @@ -30,7 +30,6 @@ use serde::{Deserialize, Serialize}; use servers::export_metrics::ExportMetricsOption; use servers::heartbeat_options::HeartbeatOptions; use servers::http::HttpOptions; -use servers::tls::TlsOption; use servers::Mode; pub const DEFAULT_OBJECT_STORE_CACHE_SIZE: ReadableSize = ReadableSize::mb(256); @@ -237,7 +236,6 @@ pub struct DatanodeOptions { pub enable_telemetry: bool, pub export_metrics: ExportMetricsOption, pub tracing: TracingOptions, - pub tls: TlsOption, } impl Default for DatanodeOptions { @@ -265,7 +263,6 @@ impl Default for DatanodeOptions { enable_telemetry: true, export_metrics: ExportMetricsOption::default(), tracing: TracingOptions::default(), - tls: TlsOption::default(), } } } diff --git a/src/datanode/src/error.rs b/src/datanode/src/error.rs index 070ace3652ad..ec3bccceeb41 100644 --- a/src/datanode/src/error.rs +++ b/src/datanode/src/error.rs @@ -367,14 +367,6 @@ pub enum Error { #[snafu(source(from(common_config::error::Error, Box::new)))] source: Box, }, - - #[snafu(display("Invalid tls config"))] - InvalidTlsConfig { - #[snafu(source)] - error: common_grpc::error::Error, - #[snafu(implicit)] - location: Location, - }, } pub type Result = std::result::Result; @@ -409,7 +401,6 @@ impl ErrorExt for Error { | MissingWalDirConfig { .. } | MissingKvBackend { .. } | TomlFormat { .. } => StatusCode::InvalidArguments, - InvalidTlsConfig { .. } => StatusCode::InvalidArguments, PayloadNotExist { .. } | Unexpected { .. } | WatchAsyncTaskChange { .. } => { StatusCode::Unexpected diff --git a/src/datanode/src/service.rs b/src/datanode/src/service.rs index 82fbe359bc28..7ad90d034062 100644 --- a/src/datanode/src/service.rs +++ b/src/datanode/src/service.rs @@ -21,10 +21,11 @@ use servers::grpc::{GrpcServer, GrpcServerConfig}; use servers::http::HttpServerBuilder; use servers::metrics_handler::MetricsHandler; use servers::server::{ServerHandler, ServerHandlers}; +use servers::tls::TlsOption; use snafu::ResultExt; use crate::config::DatanodeOptions; -use crate::error::{InvalidTlsConfigSnafu, ParseAddrSnafu, Result, TomlFormatSnafu}; +use crate::error::{ParseAddrSnafu, Result, TomlFormatSnafu}; use crate::region_server::RegionServer; pub struct DatanodeServiceBuilder<'a> { @@ -49,10 +50,10 @@ impl<'a> DatanodeServiceBuilder<'a> { } } - pub fn with_default_grpc_server(mut self, region_server: &RegionServer) -> Result { - let grpc_server_build = Self::grpc_server_builder(self.opts, region_server)?; - self.grpc_server = Some(grpc_server_build.build()); - Ok(self) + pub fn with_default_grpc_server(mut self, region_server: &RegionServer) -> Self { + let grpc_serve = Self::grpc_server_builder(self.opts, region_server).build(); + self.grpc_server = Some(grpc_serve); + self } pub fn enable_http_service(self) -> Self { @@ -91,18 +92,15 @@ impl<'a> DatanodeServiceBuilder<'a> { pub fn grpc_server_builder( opts: &DatanodeOptions, region_server: &RegionServer, - ) -> Result { + ) -> GrpcServerBuilder { let config = GrpcServerConfig { max_recv_message_size: opts.rpc_max_recv_message_size.as_bytes() as usize, max_send_message_size: opts.rpc_max_send_message_size.as_bytes() as usize, - tls: opts.tls.clone(), + tls: TlsOption::default(), }; - let build = GrpcServerBuilder::new(config, region_server.runtime()) - .with_tls_config(opts.tls.clone()) - .context(InvalidTlsConfigSnafu)? + GrpcServerBuilder::new(config, region_server.runtime()) .flight_handler(Arc::new(region_server.clone())) - .region_server_handler(Arc::new(region_server.clone())); - Ok(build) + .region_server_handler(Arc::new(region_server.clone())) } }