Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump http, hyper, tower-http, reqwest, and axum for meta dashboard #16129

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
387 changes: 312 additions & 75 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ hashbrown = { version = "0.14", features = ["ahash", "inline-more", "nightly"] }
criterion = { version = "0.5", features = ["async_futures"] }
tonic = { package = "madsim-tonic", version = "0.4.1" }
tonic-build = { package = "madsim-tonic-build", version = "0.4.2" }
otlp-embedded = { git = "https://github.com/risingwavelabs/otlp-embedded", rev = "58c1f003484449d7c6dd693b348bf19dd44889cb" }
otlp-embedded = { git = "https://github.com/risingwavelabs/otlp-embedded", rev = "492c244e0be91feb659c0cd48a624bbd96045a33" }
prost = { version = "0.12" }
icelake = { git = "https://github.com/icelake-io/icelake", rev = "54fd72fbd1dd8c592f05eeeb79223c8a6a33c297", features = [
"prometheus",
Expand Down
5 changes: 2 additions & 3 deletions src/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ prometheus = "0.13"
prometheus-http-query = "0.8"
prost = { workspace = true }
rand = "0.8"
reqwest = "0.11"
risingwave_backup = { workspace = true }
risingwave_common = { workspace = true }
risingwave_common_heap_profiling = { workspace = true }
Expand Down Expand Up @@ -86,8 +85,8 @@ url = "2"
uuid = { version = "1", features = ["v4"] }

[target.'cfg(not(madsim))'.dependencies]
axum = "0.6"
tower-http = { version = "0.4", features = [
axum = "=0.7.4" # TODO: 0.7.5+ does not work with current toolchain
tower-http = { version = "0.5", features = [
"add-extension",
"cors",
"fs",
Expand Down
6 changes: 3 additions & 3 deletions src/meta/dashboard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ repository = { workspace = true }

[dependencies]
anyhow = "1"
axum = "0.6"
axum = "=0.7.4" # TODO: 0.7.5+ does not work with current toolchain
bytes = "1"
hyper = "0.14"
hyper = "1"
mime_guess = "2"
reqwest = "0.11"
reqwest = "0.12.2"
rust-embed = { version = "8", features = ["interpolate-folder-path", "mime-guess"] }
thiserror-ext = { workspace = true }
tracing = "0.1"
Expand Down
4 changes: 2 additions & 2 deletions src/meta/dashboard/examples/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
// limitations under the License.

use risingwave_meta_dashboard::router;
use tokio::net::TcpListener;

#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();

axum::Server::bind(&"0.0.0.0:10188".parse().unwrap())
.serve(router().into_make_service())
axum::serve(TcpListener::bind("0.0.0.0:10188").await.unwrap(), router())
.await
.unwrap();
}
31 changes: 14 additions & 17 deletions src/meta/dashboard/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ use std::collections::HashMap;
use std::sync::{Arc, Mutex};

use anyhow::anyhow;
use axum::body::Body;
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use axum::Router;
use bytes::Bytes;
use hyper::header::CONTENT_TYPE;
use hyper::service::service_fn;
use hyper::{HeaderMap, Request};
use hyper::{HeaderMap, Uri};
use thiserror_ext::AsReport as _;
use url::Url;

Expand Down Expand Up @@ -63,10 +61,10 @@ impl IntoResponse for CachedResponse {
}

async fn proxy(
req: Request<Body>,
uri: Uri,
cache: Arc<Mutex<HashMap<String, CachedResponse>>>,
) -> anyhow::Result<Response> {
let mut path = req.uri().path().to_string();
let mut path = uri.path().to_string();
if path.ends_with('/') {
path += "index.html";
}
Expand Down Expand Up @@ -104,16 +102,15 @@ async fn proxy(
pub(crate) fn router() -> Router {
let cache = Arc::new(Mutex::new(HashMap::new()));

Router::new().fallback_service(service_fn(move |req: Request<Body>| {
let cache = cache.clone();
async move {
proxy(req, cache).await.or_else(|err| {
Ok((
StatusCode::INTERNAL_SERVER_ERROR,
err.context("Unhandled internal error").to_report_string(),
)
.into_response())
})
}
}))
let handler = |uri| async move {
proxy(uri, cache.clone()).await.unwrap_or_else(|err| {
(
StatusCode::INTERNAL_SERVER_ERROR,
err.context("Unhandled internal error").to_report_string(),
)
.into_response()
})
};

Router::new().fallback(handler)
}
15 changes: 9 additions & 6 deletions src/meta/src/dashboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use std::net::SocketAddr;
use std::path::Path as FilePath;
use std::sync::Arc;

use anyhow::{anyhow, Result};
use axum::body::boxed;
use anyhow::{anyhow, Context as _, Result};
use axum::extract::{Extension, Path};
use axum::http::{Method, StatusCode};
use axum::response::{IntoResponse, Response};
use axum::routing::get;
use axum::Router;
use risingwave_rpc_client::ComputeClientPool;
use tokio::net::TcpListener;
use tower::ServiceBuilder;
use tower_http::add_extension::AddExtensionLayer;
use tower_http::compression::CompressionLayer;
Expand Down Expand Up @@ -315,7 +315,7 @@ pub(super) mod handlers {
let response = Response::builder()
.header("Content-Type", "application/octet-stream")
.header("Content-Disposition", collapsed_file_name)
.body(boxed(collapsed_str));
.body(collapsed_str.into());

response.map_err(err)
}
Expand Down Expand Up @@ -412,10 +412,13 @@ impl DashboardService {
.nest("/trace", trace_ui_router)
.layer(CompressionLayer::new());

axum::Server::bind(&srv.dashboard_addr)
.serve(app.into_make_service())
let listener = TcpListener::bind(&srv.dashboard_addr)
.await
.map_err(|err| anyhow!(err))?;
.context("failed to bind dashboard address")?;
axum::serve(listener, app)
.await
.context("failed to serve dashboard service")?;

Ok(())
}
}
2 changes: 1 addition & 1 deletion src/workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ aws-sdk-s3 = { version = "1" }
aws-sigv4 = { version = "1", features = ["http0-compat", "sign-eventstream", "sigv4a"] }
aws-smithy-runtime = { version = "1", default-features = false, features = ["client", "rt-tokio", "tls-rustls"] }
aws-smithy-types = { version = "1", default-features = false, features = ["byte-stream-poll-next", "http-body-0-4-x", "hyper-0-14-x", "rt-tokio"] }
axum = { version = "0.6" }
base64 = { version = "0.21" }
bigdecimal = { version = "0.4" }
bit-vec = { version = "0.6" }
Expand Down Expand Up @@ -124,6 +123,7 @@ serde_with = { version = "3", features = ["json"] }
sha1 = { version = "0.10" }
sha2 = { version = "0.10", features = ["oid"] }
smallvec = { version = "1", default-features = false, features = ["const_new", "serde", "union", "write"] }
socket2 = { version = "0.5", default-features = false, features = ["all"] }
sqlx = { version = "0.7", default-features = false, features = ["bigdecimal", "chrono", "json", "mysql", "postgres", "runtime-tokio-native-tls", "rust_decimal", "sqlite", "time", "uuid"] }
sqlx-core = { version = "0.7", features = ["_rt-tokio", "_tls-native-tls", "bigdecimal", "chrono", "json", "migrate", "offline", "rust_decimal", "time", "uuid"] }
sqlx-mysql = { version = "0.7", default-features = false, features = ["bigdecimal", "chrono", "json", "rust_decimal", "time", "uuid"] }
Expand Down
Loading