diff --git a/config/config.md b/config/config.md index 773fe30fa3f..cd1e52e9080 100644 --- a/config/config.md +++ b/config/config.md @@ -34,7 +34,7 @@ | `http.prom_validation_mode` | String | `strict` | Whether to enable validation for Prometheus remote write requests.
Available options:
- strict: deny invalid UTF-8 strings (default).
- lossy: allow invalid UTF-8 strings, replace invalid characters with REPLACEMENT_CHARACTER(U+FFFD).
- unchecked: do not valid strings. | | `http.experimental_enable_prometheus_native_histogram` | Bool | `false` | Experimental: enable Prometheus remote write v2 native histogram ingestion. | | `http.experimental_enable_explain_analyze_stream` | Bool | `true` | Experimental: enable POST /v1/sql/analyze/stream for streaming EXPLAIN ANALYZE VERBOSE metrics. | -| `http.api_server_enable` | Bool | `true` | Whether to start the dedicated public HTTP **API** server. This server serves
only the `v1` interfaces plus the dashboard, and shares every other `[http]`
option with the main server. It is enabled by default. | +| `http.api_server_enable` | Bool | `false` | Whether to start the dedicated public HTTP **API** server. This server serves
only the `v1` interfaces plus the dashboard, and shares every other `[http]`
option with the main server. It is disabled by default; set to `true` to enable. | | `http.api_server_host` | String | `127.0.0.1` | Host of the dedicated HTTP API server. Defaults to `127.0.0.1`. | | `http.api_server_port` | Integer | `4006` | Port of the dedicated HTTP API server. Defaults to `4006`. | | `grpc` | -- | -- | The gRPC server options. | @@ -258,7 +258,7 @@ | `http.prom_validation_mode` | String | `strict` | Whether to enable validation for Prometheus remote write requests.
Available options:
- strict: deny invalid UTF-8 strings (default).
- lossy: allow invalid UTF-8 strings, replace invalid characters with REPLACEMENT_CHARACTER(U+FFFD).
- unchecked: do not valid strings. | | `http.experimental_enable_prometheus_native_histogram` | Bool | `false` | Experimental: enable Prometheus remote write v2 native histogram ingestion. | | `http.experimental_enable_explain_analyze_stream` | Bool | `true` | Experimental: enable POST /v1/sql/analyze/stream for streaming EXPLAIN ANALYZE VERBOSE metrics. | -| `http.api_server_enable` | Bool | `true` | Whether to start the dedicated public HTTP **API** server. This server serves
only the `v1` interfaces plus the dashboard, and shares every other `[http]`
option with the main server. It is enabled by default. | +| `http.api_server_enable` | Bool | `false` | Whether to start the dedicated public HTTP **API** server. This server serves
only the `v1` interfaces plus the dashboard, and shares every other `[http]`
option with the main server. It is disabled by default; set to `true` to enable. | | `http.api_server_host` | String | `127.0.0.1` | Host of the dedicated HTTP API server. Defaults to `127.0.0.1`. | | `http.api_server_port` | Integer | `4006` | Port of the dedicated HTTP API server. Defaults to `4006`. | | `grpc` | -- | -- | The gRPC server options. | diff --git a/config/frontend.example.toml b/config/frontend.example.toml index 27f13f9b7f3..6cf29ff7466 100644 --- a/config/frontend.example.toml +++ b/config/frontend.example.toml @@ -72,8 +72,8 @@ experimental_enable_explain_analyze_stream = true ## Whether to start the dedicated public HTTP **API** server. This server serves ## only the `v1` interfaces plus the dashboard, and shares every other `[http]` -## option with the main server. It is enabled by default. -api_server_enable = true +## option with the main server. It is disabled by default; set to `true` to enable. +api_server_enable = false ## Host of the dedicated HTTP API server. Defaults to `127.0.0.1`. api_server_host = "127.0.0.1" ## Port of the dedicated HTTP API server. Defaults to `4006`. diff --git a/config/standalone.example.toml b/config/standalone.example.toml index d20d582ac05..da894e88db7 100644 --- a/config/standalone.example.toml +++ b/config/standalone.example.toml @@ -86,8 +86,8 @@ experimental_enable_explain_analyze_stream = true ## Whether to start the dedicated public HTTP **API** server. This server serves ## only the `v1` interfaces plus the dashboard, and shares every other `[http]` -## option with the main server. It is enabled by default. -api_server_enable = true +## option with the main server. It is disabled by default; set to `true` to enable. +api_server_enable = false ## Host of the dedicated HTTP API server. Defaults to `127.0.0.1`. api_server_host = "127.0.0.1" ## Port of the dedicated HTTP API server. Defaults to `4006`. diff --git a/src/frontend/src/frontend.rs b/src/frontend/src/frontend.rs index a3807ba7986..240b0b20287 100644 --- a/src/frontend/src/frontend.rs +++ b/src/frontend/src/frontend.rs @@ -200,10 +200,10 @@ mod tests { #[test] fn test_http_api_server_defaults_on_when_absent() { - // When `[http]` is not present in the config, the dedicated API server must - // still be enabled by default on port 4006. + // When `[http]` is not present in the config, the dedicated API server is + // disabled by default (its port/host defaults are still 4006 / 127.0.0.1). let parsed: FrontendOptions = toml::from_str("").unwrap(); - assert!(parsed.http.api_server_enable); + assert!(!parsed.http.api_server_enable); assert_eq!(parsed.http.api_server_port, 4006); assert_eq!(parsed.http.api_server_host, "127.0.0.1"); } diff --git a/src/servers/src/http.rs b/src/servers/src/http.rs index d12b9d28dd6..507481c80ed 100644 --- a/src/servers/src/http.rs +++ b/src/servers/src/http.rs @@ -219,7 +219,7 @@ impl Default for HttpOptions { prom_validation_mode: PromValidationMode::Strict, experimental_enable_prometheus_native_histogram: false, experimental_enable_explain_analyze_stream: true, - api_server_enable: true, + api_server_enable: false, api_server_host: "127.0.0.1".to_string(), api_server_port: DEFAULT_HTTP_API_ADDR_PORT, } @@ -1596,7 +1596,12 @@ mod test { fn make_split_builder() -> HttpServerBuilder { let (tx, _rx) = mpsc::channel(100); let instance = Arc::new(DummyInstance { _tx: tx }); - HttpServerBuilder::new(HttpOptions::default()) + // Enable the dedicated API server so the split behavior can be exercised. + let options = HttpOptions { + api_server_enable: true, + ..HttpOptions::default() + }; + HttpServerBuilder::new(options) .with_sql_handler(instance) .with_metrics_handler(MetricsHandler) .with_greptime_config_options("dummy = \"value\"".to_string()) @@ -1605,7 +1610,8 @@ mod test { #[tokio::test] pub async fn test_http_api_options_defaults() { let opts = HttpOptions::default(); - assert!(opts.api_server_enable); + // The API server is disabled by default. + assert!(!opts.api_server_enable); assert_eq!(opts.api_server_host, "127.0.0.1"); assert_eq!(opts.api_server_port, 4006); } @@ -1636,7 +1642,7 @@ mod test { // `build_servers` produces the internal/full server (everything) plus a // dedicated API server that only serves the v1 interfaces (and dashboard). let (internal, api) = make_split_builder().build_servers(); - let api = api.expect("API server is enabled by default"); + let api = api.expect("API server is explicitly enabled in make_split_builder"); assert_eq!(internal.name(), HTTP_SERVER); assert_eq!(api.name(), HTTP_API_SERVER); @@ -1679,10 +1685,11 @@ mod test { timeout: Duration::from_secs(42), body_limit: ReadableSize::mb(128), cors_allowed_origins: vec!["https://example.com".to_string()], + api_server_enable: true, ..HttpOptions::default() }; let (internal, api) = HttpServerBuilder::new(http_opts.clone()).build_servers(); - let api = api.expect("API server is enabled by default"); + let api = api.expect("API server is explicitly enabled"); // Only the bound address differs. assert_eq!(internal.options.addr, http_opts.addr); @@ -1697,13 +1704,10 @@ mod test { } #[test] - fn test_build_servers_can_disable_api_server() { - // When `api_server_enable` is false, no API server is built. - let opts = HttpOptions { - api_server_enable: false, - ..HttpOptions::default() - }; - let (_internal, api) = HttpServerBuilder::new(opts).build_servers(); + fn test_build_servers_api_disabled_by_default() { + // The API server is disabled by default, so `build_servers` returns no + // second server unless `api_server_enable` is set. + let (_internal, api) = HttpServerBuilder::new(HttpOptions::default()).build_servers(); assert!(api.is_none()); } diff --git a/tests-integration/tests/http.rs b/tests-integration/tests/http.rs index 40c1fc82488..fcb04c92b0c 100644 --- a/tests-integration/tests/http.rs +++ b/tests-integration/tests/http.rs @@ -2084,7 +2084,7 @@ experimental_enable_prometheus_native_histogram = false cors_allowed_origins = [] enable_cors = true experimental_enable_explain_analyze_stream = true -api_server_enable = true +api_server_enable = false api_server_host = "127.0.0.1" api_server_port = 4006