From c99643475b028c7e8858b4ad5c333fac367db2e2 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Wed, 18 Jan 2023 11:06:17 -0800 Subject: [PATCH 1/2] dropshot update --- Cargo.lock | 12 +- Cargo.toml | 3 +- common/src/api/external/http_pagination.rs | 3 +- gateway/src/http_entrypoints.rs | 40 ++- .../src/http_entrypoints.rs | 4 +- internal-dns/src/dropshot_server.rs | 8 +- nexus/src/authn/external/cookies.rs | 12 +- nexus/src/authn/external/mod.rs | 21 +- nexus/src/authn/external/session_cookie.rs | 4 +- nexus/src/authn/external/spoof.rs | 2 +- nexus/src/authn/external/token.rs | 2 +- nexus/src/context.rs | 2 +- nexus/src/external_api/console_api.rs | 43 +-- nexus/src/external_api/device_auth.rs | 12 +- nexus/src/external_api/http_entrypoints.rs | 336 +++++++++--------- nexus/src/internal_api/http_entrypoints.rs | 22 +- nexus/tests/integration_tests/authn_http.rs | 5 +- nexus/tests/integration_tests/updates.rs | 3 +- oximeter/collector/src/lib.rs | 2 +- oximeter/instruments/src/http.rs | 29 +- oximeter/producer/src/lib.rs | 3 +- sled-agent/src/http_entrypoints.rs | 21 +- sled-agent/src/sim/http_entrypoints.rs | 18 +- .../src/sim/http_entrypoints_storage.rs | 18 +- wicketd/src/http_entrypoints.rs | 5 +- 25 files changed, 312 insertions(+), 318 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index faab9f432f..0214a36271 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1536,8 +1536,8 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dropshot" -version = "0.8.1-dev" -source = "git+https://github.com/oxidecomputer/dropshot?branch=main#120e168525018dca4c9c3bed47d398c55fdd4d6b" +version = "0.9.0-dev" +source = "git+https://github.com/oxidecomputer/dropshot?branch=remove-arc-rqctx#ed997871350de84cd3d645aa59f32385454e0963" dependencies = [ "async-stream", "async-trait", @@ -1577,8 +1577,8 @@ dependencies = [ [[package]] name = "dropshot_endpoint" -version = "0.8.1-dev" -source = "git+https://github.com/oxidecomputer/dropshot?branch=main#120e168525018dca4c9c3bed47d398c55fdd4d6b" +version = "0.9.0-dev" +source = "git+https://github.com/oxidecomputer/dropshot?branch=remove-arc-rqctx#ed997871350de84cd3d645aa59f32385454e0963" dependencies = [ "proc-macro2", "quote", @@ -5246,9 +5246,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.7" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", diff --git a/Cargo.toml b/Cargo.toml index 7785655a7c..fa5f9e7a4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,7 +115,8 @@ debug-ignore = "1.0.5" derive_more = "0.99.17" diesel = { version = "2.0.2" } diesel-dtrace = { git = "https://github.com/oxidecomputer/diesel-dtrace", rev = "18748d9f76c94e1f4400fbec0859b3e77a221a8d" } -dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "main", features = [ "usdt-probes" ] } +# XXX-dap update before landing to point back to main +dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "remove-arc-rqctx", features = [ "usdt-probes" ] } expectorate = "1.0.6" # TODO(luqman): Update once merged & new release is cut # https://github.com/rafalh/rust-fatfs/pull/76 diff --git a/common/src/api/external/http_pagination.rs b/common/src/api/external/http_pagination.rs index 601534db43..6471610aee 100644 --- a/common/src/api/external/http_pagination.rs +++ b/common/src/api/external/http_pagination.rs @@ -56,7 +56,6 @@ use serde::Deserialize; use serde::Serialize; use std::fmt::Debug; use std::num::NonZeroU32; -use std::sync::Arc; use uuid::Uuid; // General pagination infrastructure @@ -180,7 +179,7 @@ where /// Given a request and pagination parameters, return a [`DataPageParams`] /// describing the current page of results to return pub fn data_page_params_for<'a, S, C>( - rqctx: &'a Arc>, + rqctx: &'a RequestContext, pag_params: &'a PaginationParams>, ) -> Result, HttpError> where diff --git a/gateway/src/http_entrypoints.rs b/gateway/src/http_entrypoints.rs index 9cc8659a0b..d7a73dce20 100644 --- a/gateway/src/http_entrypoints.rs +++ b/gateway/src/http_entrypoints.rs @@ -17,6 +17,7 @@ use dropshot::HttpError; use dropshot::HttpResponseOk; use dropshot::HttpResponseUpdatedNoContent; use dropshot::Path; +use dropshot::RawRequest; use dropshot::RequestContext; use dropshot::TypedBody; use futures::stream::FuturesUnordered; @@ -357,7 +358,7 @@ struct PathSpComponent { path = "/sp", }] async fn sp_list( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result>, HttpError> { let apictx = rqctx.context(); let mgmt_switch = &apictx.mgmt_switch; @@ -451,7 +452,7 @@ async fn sp_list( path = "/sp/{type}/{slot}", }] async fn sp_get( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -484,7 +485,7 @@ async fn sp_get( path = "/sp/{type}/{slot}/component", }] async fn sp_component_list( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -508,7 +509,7 @@ async fn sp_component_list( path = "/sp/{type}/{slot}/component/{component}", }] async fn sp_component_get( - _rqctx: Arc>>, + _rqctx: RequestContext>, _path: Path, ) -> Result, HttpError> { todo!() @@ -521,14 +522,15 @@ async fn sp_component_get( path = "/sp/{type}/{slot}/component/{component}/serial-console/attach", }] async fn sp_component_serial_console_attach( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, + raw_request: RawRequest, ) -> Result, HttpError> { let apictx = rqctx.context(); let PathSpComponent { sp, component } = path.into_inner(); let component = component_from_str(&component)?; - let mut request = rqctx.request.lock().await; + let mut request = raw_request.into_inner(); let sp = sp.into(); Ok(crate::serial_console::attach( @@ -548,7 +550,7 @@ async fn sp_component_serial_console_attach( path = "/sp/{type}/{slot}/component/{component}/serial-console/detach", }] async fn sp_component_serial_console_detach( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result { let apictx = rqctx.context(); @@ -600,7 +602,7 @@ pub struct UpdateAbortBody { path = "/sp/{type}/{slot}/reset", }] async fn sp_reset( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result { let apictx = rqctx.context(); @@ -632,7 +634,7 @@ async fn sp_reset( path = "/sp/{type}/{slot}/component/{component}/update", }] async fn sp_component_update( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, body: TypedBody, ) -> Result { @@ -659,7 +661,7 @@ async fn sp_component_update( path = "/sp/{type}/{slot}/component/{component}/update-status", }] async fn sp_component_update_status( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -685,7 +687,7 @@ async fn sp_component_update_status( path = "/sp/{type}/{slot}/component/{component}/update-abort", }] async fn sp_component_update_abort( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, body: TypedBody, ) -> Result { @@ -709,7 +711,7 @@ async fn sp_component_update_abort( path = "/sp/{type}/{slot}/component/{component}/power-on", }] async fn sp_component_power_on( - _rqctx: Arc>>, + _rqctx: RequestContext>, _path: Path, // TODO do we need a timeout? ) -> Result { @@ -724,7 +726,7 @@ async fn sp_component_power_on( path = "/sp/{type}/{slot}/component/{component}/power-off", }] async fn sp_component_power_off( - _rqctx: Arc>>, + _rqctx: RequestContext>, _path: Path, // TODO do we need a timeout? ) -> Result { @@ -741,7 +743,7 @@ async fn sp_component_power_off( path = "/ignition", }] async fn ignition_list( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result>, HttpError> { let apictx = rqctx.context(); let mgmt_switch = &apictx.mgmt_switch; @@ -768,7 +770,7 @@ async fn ignition_list( path = "/ignition/{type}/{slot}", }] async fn ignition_get( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -795,7 +797,7 @@ async fn ignition_get( path = "/ignition/{type}/{slot}/power-on", }] async fn ignition_power_on( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result { let apictx = rqctx.context(); @@ -820,7 +822,7 @@ async fn ignition_power_on( path = "/ignition/{type}/{slot}/power-off", }] async fn ignition_power_off( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result { let apictx = rqctx.context(); @@ -846,7 +848,7 @@ async fn ignition_power_off( path = "/sp/{type}/{slot}/power-state", }] async fn sp_power_state_get( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -866,7 +868,7 @@ async fn sp_power_state_get( path = "/sp/{type}/{slot}/power-state", }] async fn sp_power_state_set( - rqctx: Arc>>, + rqctx: RequestContext>, path: Path, body: TypedBody, ) -> Result { diff --git a/installinator-artifactd/src/http_entrypoints.rs b/installinator-artifactd/src/http_entrypoints.rs index 7367bf749f..c331dc18b0 100644 --- a/installinator-artifactd/src/http_entrypoints.rs +++ b/installinator-artifactd/src/http_entrypoints.rs @@ -4,8 +4,6 @@ // Copyright 2022 Oxide Computer Company -use std::sync::Arc; - use dropshot::{ endpoint, ApiDescription, FreeformBody, HttpError, HttpResponseOk, Path, RequestContext, @@ -37,7 +35,7 @@ pub fn api() -> ArtifactServerApiDesc { path = "/artifacts/{name}/{version}" }] async fn get_artifact( - rqctx: Arc>, + rqctx: RequestContext, path: Path, ) -> Result, HttpError> { match rqctx.context().artifact_store.get_artifact(&path.into_inner()).await diff --git a/internal-dns/src/dropshot_server.rs b/internal-dns/src/dropshot_server.rs index 82cfbbf122..f12faa02f4 100644 --- a/internal-dns/src/dropshot_server.rs +++ b/internal-dns/src/dropshot_server.rs @@ -5,7 +5,7 @@ //! Dropshot server for configuring DNS namespace use crate::dns_data::{self, DnsKV, DnsRecordKey}; -use dropshot::endpoint; +use dropshot::{endpoint, RequestContext}; use std::sync::Arc; pub struct Context { @@ -32,7 +32,7 @@ pub fn api() -> dropshot::ApiDescription> { path = "/records", )] async fn dns_records_list( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result>, dropshot::HttpError> { let apictx = rqctx.context(); // XXX record key @@ -47,7 +47,7 @@ async fn dns_records_list( path = "/records", )] async fn dns_records_create( - rqctx: Arc>>, + rqctx: RequestContext>, rq: dropshot::TypedBody>, ) -> Result { let apictx = rqctx.context(); @@ -62,7 +62,7 @@ async fn dns_records_create( path = "/records", )] async fn dns_records_delete( - rqctx: Arc>>, + rqctx: RequestContext>, rq: dropshot::TypedBody>, ) -> Result { let apictx = rqctx.context(); diff --git a/nexus/src/authn/external/cookies.rs b/nexus/src/authn/external/cookies.rs index dcc4c88dca..e3ad2e3264 100644 --- a/nexus/src/authn/external/cookies.rs +++ b/nexus/src/authn/external/cookies.rs @@ -6,10 +6,9 @@ use anyhow::Context; use async_trait::async_trait; use cookie::{Cookie, CookieJar, ParseError}; use dropshot::{ - ApiEndpointBodyContentType, ExtensionMode, Extractor, ExtractorMetadata, - HttpError, RequestContext, ServerContext, + ApiEndpointBodyContentType, ExtensionMode, ExtractorMetadata, HttpError, + RequestContext, ServerContext, SharedExtractor, }; -use std::sync::Arc; pub fn parse_cookies( headers: &http::HeaderMap, @@ -35,12 +34,11 @@ NewtypeFrom! { () pub struct Cookies(pub CookieJar); } NewtypeDeref! { () pub struct Cookies(pub CookieJar); } #[async_trait] -impl Extractor for Cookies { +impl SharedExtractor for Cookies { async fn from_request( - rqctx: Arc>, + rqctx: &RequestContext, ) -> Result { - let request = &rqctx.request.lock().await; - let cookies = parse_cookies(request.headers()) + let cookies = parse_cookies(rqctx.request.headers()) .unwrap_or_else(|_| CookieJar::new()); Ok(cookies.into()) } diff --git a/nexus/src/authn/external/mod.rs b/nexus/src/authn/external/mod.rs index 299be2ff92..c474c29a93 100644 --- a/nexus/src/authn/external/mod.rs +++ b/nexus/src/authn/external/mod.rs @@ -44,9 +44,8 @@ where Q: Borrow + Send + Sync + 'static, { let log = &rqctx.log; - let request = &rqctx.request.lock().await; let ctx = rqctx.context().borrow(); - let result = self.authn_request_generic(ctx, log, request).await; + let result = self.authn_request_generic(ctx, log, &rqctx.request).await; trace!(log, "authn result: {:?}", result); result } @@ -56,7 +55,7 @@ where &self, ctx: &T, log: &slog::Logger, - request: &http::Request, + request: &dropshot::RequestInfo, ) -> Result { // For debuggability, keep track of the schemes that we've tried. let mut schemes_tried = Vec::with_capacity(self.allowed_schemes.len()); @@ -64,7 +63,7 @@ where let scheme_name = scheme_impl.name(); trace!(log, "authn: trying {:?}", scheme_name); schemes_tried.push(scheme_name); - let result = scheme_impl.authn(ctx, log, &request).await; + let result = scheme_impl.authn(ctx, log, request).await; match result { // TODO-security If the user explicitly failed one // authentication scheme (i.e., a signature that didn't match, @@ -101,7 +100,7 @@ where &self, ctx: &T, log: &slog::Logger, - request: &http::Request, + request: &dropshot::RequestInfo, ) -> SchemeResult; } @@ -164,7 +163,7 @@ mod test { &self, _ctx: &(), _log: &slog::Logger, - _request: &http::Request, + _request: &dropshot::RequestInfo, ) -> SchemeResult { self.nattempts.fetch_add(1, Ordering::SeqCst); match self.next.load(Ordering::SeqCst) { @@ -239,7 +238,7 @@ mod test { // requested. We should wind up with an unauthenticated context with // both grunts having been consulted. let ctx = authn - .authn_request_generic(&(), &log, &request) + .authn_request_generic(&(), &log, &(&request).into()) .await .expect("expected authn to succeed"); expected_count1 += 1; @@ -254,7 +253,7 @@ mod test { // not be consulted. flag1.store(OK, Ordering::SeqCst); let ctx = authn - .authn_request_generic(&(), &log, &request) + .authn_request_generic(&(), &log, &(&request).into()) .await .expect("expected authn to succeed"); expected_count1 += 1; @@ -267,7 +266,7 @@ mod test { // back an error. grunt2 should not be consulted. flag1.store(FAIL, Ordering::SeqCst); let error = authn - .authn_request_generic(&(), &log, &request) + .authn_request_generic(&(), &log, &(&request).into()) .await .expect_err("expected authn to fail"); expected_count1 += 1; @@ -284,7 +283,7 @@ mod test { flag1.store(SKIP, Ordering::SeqCst); flag2.store(OK, Ordering::SeqCst); let ctx = authn - .authn_request_generic(&(), &log, &request) + .authn_request_generic(&(), &log, &(&request).into()) .await .expect("expected authn to succeed"); expected_count1 += 1; @@ -299,7 +298,7 @@ mod test { expected_count1 += 1; expected_count2 += 1; let error = authn - .authn_request_generic(&(), &log, &request) + .authn_request_generic(&(), &log, &(&request).into()) .await .expect_err("expected authn to fail"); assert_eq!( diff --git a/nexus/src/authn/external/session_cookie.rs b/nexus/src/authn/external/session_cookie.rs index 116f4f4ca1..11fb50de16 100644 --- a/nexus/src/authn/external/session_cookie.rs +++ b/nexus/src/authn/external/session_cookie.rs @@ -91,7 +91,7 @@ where &self, ctx: &T, log: &slog::Logger, - request: &http::Request, + request: &dropshot::RequestInfo, ) -> SchemeResult { let token = match get_token_from_cookie(request.headers()) { Some(token) => token, @@ -267,7 +267,7 @@ mod test { let headers = request.headers_mut(); headers.insert(http::header::COOKIE, cookie.parse().unwrap()); } - scheme.authn(context, &log, &request).await + scheme.authn(context, &log, &request.into()).await } #[tokio::test] diff --git a/nexus/src/authn/external/spoof.rs b/nexus/src/authn/external/spoof.rs index 8a6f9674f9..0b5896a6f8 100644 --- a/nexus/src/authn/external/spoof.rs +++ b/nexus/src/authn/external/spoof.rs @@ -87,7 +87,7 @@ where &self, ctx: &T, log: &slog::Logger, - request: &http::Request, + request: &dropshot::RequestInfo, ) -> SchemeResult { let headers = request.headers(); match authn_spoof_parse_id(headers.typed_get().as_ref()) { diff --git a/nexus/src/authn/external/token.rs b/nexus/src/authn/external/token.rs index 9145583df2..94dfaa0490 100644 --- a/nexus/src/authn/external/token.rs +++ b/nexus/src/authn/external/token.rs @@ -57,7 +57,7 @@ where &self, ctx: &T, _log: &slog::Logger, - request: &http::Request, + request: &dropshot::RequestInfo, ) -> SchemeResult { let headers = request.headers(); match parse_token(headers.typed_get().as_ref()) { diff --git a/nexus/src/context.rs b/nexus/src/context.rs index 6f44504e6a..03e92ed5db 100644 --- a/nexus/src/context.rs +++ b/nexus/src/context.rs @@ -335,7 +335,7 @@ impl OpContext { rqctx: &dropshot::RequestContext, metadata: &mut BTreeMap, ) { - let request = rqctx.request.lock().await; + let request = &rqctx.request; metadata.insert(String::from("request_id"), rqctx.request_id.clone()); metadata .insert(String::from("http_method"), request.method().to_string()); diff --git a/nexus/src/external_api/console_api.rs b/nexus/src/external_api/console_api.rs index 34bfc75680..72cb24de50 100644 --- a/nexus/src/external_api/console_api.rs +++ b/nexus/src/external_api/console_api.rs @@ -61,7 +61,7 @@ pub struct SpoofLoginBody { tags = ["hidden"], }] pub async fn login_spoof( - rqctx: Arc>>, + rqctx: RequestContext>, params: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -258,14 +258,14 @@ impl RelayState { tags = ["login"], }] pub async fn login_saml_begin( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); let handler = async { let nexus = &apictx.nexus; let path_params = path_params.into_inner(); - let request = &rqctx.request.lock().await; + let request = &rqctx.request; // Use opctx_external_authn because this request will be // unauthenticated. @@ -335,7 +335,7 @@ pub async fn login_saml_begin( tags = ["login"], }] pub async fn login_saml( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, body_bytes: dropshot::UntypedBody, ) -> Result { @@ -405,7 +405,7 @@ pub struct LoginPathParam { tags = ["login"], }] pub async fn login_local( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, credentials: dropshot::TypedBody, ) -> Result { @@ -478,7 +478,7 @@ async fn login_finish( tags = ["hidden"], }] pub async fn logout( - rqctx: Arc>>, + rqctx: RequestContext>, cookies: Cookies, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -542,7 +542,7 @@ pub struct RestPathParam { unpublished = true, }] pub async fn login_spoof_begin( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result, HttpError> { serve_console_index(rqctx.context()).await } @@ -602,7 +602,7 @@ fn get_login_url(redirect_url: Option) -> String { unpublished = true, }] pub async fn login_begin( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result { let apictx = rqctx.context(); @@ -622,7 +622,7 @@ pub async fn login_begin( tags = ["hidden"], }] pub async fn session_me( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result, HttpError> { let apictx = rqctx.context(); let nexus = &apictx.nexus; @@ -644,7 +644,7 @@ pub async fn session_me( tags = ["hidden"], }] pub async fn session_me_groups( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -674,7 +674,7 @@ pub async fn session_me_groups( } pub async fn console_index_or_login_redirect( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result, HttpError> { let opctx = OpContext::for_external_api(&rqctx).await; @@ -692,13 +692,8 @@ pub async fn console_index_or_login_redirect( // using the spoof login page, which is hosted by Nexus. Once we start // sending users to a real external IdP login page, this will need to be a // full URL. - let redirect_url = rqctx - .request - .lock() - .await - .uri() - .path_and_query() - .map(|p| p.to_string()); + let redirect_url = + rqctx.request.uri().path_and_query().map(|p| p.to_string()); Ok(Response::builder() .status(StatusCode::FOUND) @@ -720,7 +715,7 @@ pub async fn console_index_or_login_redirect( unpublished = true, }] pub async fn console_page( - rqctx: Arc>>, + rqctx: RequestContext>, _path_params: Path, ) -> Result, HttpError> { console_index_or_login_redirect(rqctx).await @@ -732,7 +727,7 @@ pub async fn console_page( unpublished = true, }] pub async fn console_settings_page( - rqctx: Arc>>, + rqctx: RequestContext>, _path_params: Path, ) -> Result, HttpError> { console_index_or_login_redirect(rqctx).await @@ -744,7 +739,7 @@ pub async fn console_settings_page( unpublished = true, }] pub async fn console_system_page( - rqctx: Arc>>, + rqctx: RequestContext>, _path_params: Path, ) -> Result, HttpError> { console_index_or_login_redirect(rqctx).await @@ -756,7 +751,7 @@ pub async fn console_system_page( unpublished = true, }] pub async fn console_root( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result, HttpError> { console_index_or_login_redirect(rqctx).await } @@ -782,7 +777,7 @@ fn with_gz_ext(path: &PathBuf) -> PathBuf { unpublished = true, }] pub async fn asset( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -804,7 +799,7 @@ pub async fn asset( .ok_or_else(|| not_found("static_dir undefined"))? .join("assets"); - let request = &rqctx.request.lock().await; + let request = &rqctx.request; let accept_encoding = request.headers().get(http::header::ACCEPT_ENCODING); let accept_gz = accept_encoding.map_or(false, |val| { val.to_str().map_or(false, |s| s.contains("gzip")) diff --git a/nexus/src/external_api/device_auth.rs b/nexus/src/external_api/device_auth.rs index 3ac2fd6f1b..a8ec48da19 100644 --- a/nexus/src/external_api/device_auth.rs +++ b/nexus/src/external_api/device_auth.rs @@ -64,7 +64,7 @@ pub struct DeviceAuthRequest { tags = ["hidden"], // "token" }] pub async fn device_auth_request( - rqctx: Arc>>, + rqctx: RequestContext>, params: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -72,7 +72,7 @@ pub async fn device_auth_request( let params = params.into_inner(); let handler = async { let opctx = nexus.opctx_external_authn(); - let request = rqctx.request.lock().await; + let request = &rqctx.request; let host = if request.version() > hyper::Version::HTTP_11 { request.uri().authority().map(|a| a.as_str()) @@ -138,7 +138,7 @@ pub struct DeviceAuthVerify { unpublished = true, }] pub async fn device_auth_verify( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result, HttpError> { console_index_or_login_redirect(rqctx).await } @@ -149,7 +149,7 @@ pub async fn device_auth_verify( unpublished = true, }] pub async fn device_auth_success( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result, HttpError> { console_index_or_login_redirect(rqctx).await } @@ -165,7 +165,7 @@ pub async fn device_auth_success( tags = ["hidden"], // "token" }] pub async fn device_auth_confirm( - rqctx: Arc>>, + rqctx: RequestContext>, params: TypedBody, ) -> Result { let apictx = rqctx.context(); @@ -213,7 +213,7 @@ pub enum DeviceAccessTokenResponse { tags = ["hidden"], // "token" }] pub async fn device_access_token( - rqctx: Arc>>, + rqctx: RequestContext>, params: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); diff --git a/nexus/src/external_api/http_entrypoints.rs b/nexus/src/external_api/http_entrypoints.rs index 71f70d76be..828b2d6b2b 100644 --- a/nexus/src/external_api/http_entrypoints.rs +++ b/nexus/src/external_api/http_entrypoints.rs @@ -369,7 +369,7 @@ pub fn external_api() -> NexusApiDescription { tags = ["policy"], }] async fn system_policy_view( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result>, HttpError> { let apictx = rqctx.context(); let nexus = &apictx.nexus; @@ -395,7 +395,7 @@ struct ByIdPathParams { tags = ["policy"], }] async fn system_policy_update( - rqctx: Arc>>, + rqctx: RequestContext>, new_policy: TypedBody>, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -420,7 +420,7 @@ async fn system_policy_update( tags = ["silos"], }] pub async fn policy_view( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result>, HttpError> { let apictx = rqctx.context(); let nexus = &apictx.nexus; @@ -445,7 +445,7 @@ pub async fn policy_view( tags = ["silos"], }] async fn policy_update( - rqctx: Arc>>, + rqctx: RequestContext>, new_policy: TypedBody>, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -478,7 +478,7 @@ async fn policy_update( tags = ["system"], }] async fn silo_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -519,7 +519,7 @@ async fn silo_list( tags = ["system"], }] async fn silo_create( - rqctx: Arc>>, + rqctx: RequestContext>, new_silo_params: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -549,7 +549,7 @@ struct SiloPathParam { tags = ["system"], }] async fn silo_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -571,7 +571,7 @@ async fn silo_view( tags = ["system"] }] async fn silo_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -595,7 +595,7 @@ async fn silo_view_by_id( tags = ["system"], }] async fn silo_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -617,7 +617,7 @@ async fn silo_delete( tags = ["system"], }] async fn silo_policy_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -641,7 +641,7 @@ async fn silo_policy_view( tags = ["system"], }] async fn silo_policy_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_policy: TypedBody>, ) -> Result>, HttpError> { @@ -673,7 +673,7 @@ async fn silo_policy_update( tags = ["system"], }] async fn silo_users_list( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result>, HttpError> { @@ -715,7 +715,7 @@ struct UserPathParam { tags = ["system"], }] async fn silo_user_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -744,7 +744,7 @@ async fn silo_user_view( tags = ["system"], }] async fn silo_identity_provider_list( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result>, HttpError> { @@ -781,7 +781,7 @@ async fn silo_identity_provider_list( tags = ["system"], }] async fn saml_identity_provider_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_provider: TypedBody, ) -> Result, HttpError> { @@ -818,7 +818,7 @@ struct SiloSamlPathParam { tags = ["system"], }] async fn saml_identity_provider_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -856,7 +856,7 @@ async fn saml_identity_provider_view( tags = ["system"], }] async fn local_idp_user_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_user_params: TypedBody, ) -> Result, HttpError> { @@ -884,7 +884,7 @@ async fn local_idp_user_create( tags = ["system"], }] async fn local_idp_user_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -914,7 +914,7 @@ async fn local_idp_user_delete( tags = ["system"], }] async fn local_idp_user_set_password( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, update: TypedBody, ) -> Result { @@ -943,7 +943,7 @@ async fn local_idp_user_set_password( tags = ["organizations"] }] async fn organization_list_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -986,7 +986,7 @@ async fn organization_list_v1( deprecated = true }] async fn organization_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -1027,7 +1027,7 @@ async fn organization_list( tags = ["organizations"], }] async fn organization_create_v1( - rqctx: Arc>>, + rqctx: RequestContext>, new_organization: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -1051,7 +1051,7 @@ async fn organization_create_v1( deprecated = true }] async fn organization_create( - rqctx: Arc>>, + rqctx: RequestContext>, new_organization: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -1073,7 +1073,7 @@ async fn organization_create( tags = ["organizations"], }] async fn organization_view_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -1111,7 +1111,7 @@ struct OrganizationPathParam { deprecated = true }] async fn organization_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -1142,7 +1142,7 @@ async fn organization_view( deprecated = true }] async fn organization_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -1169,7 +1169,7 @@ async fn organization_view_by_id( tags = ["organizations"], }] async fn organization_delete_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -1196,7 +1196,7 @@ async fn organization_delete_v1( deprecated = true }] async fn organization_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -1222,7 +1222,7 @@ async fn organization_delete( tags = ["organizations"], }] async fn organization_update_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, updated_organization: TypedBody, ) -> Result, HttpError> { @@ -1261,7 +1261,7 @@ async fn organization_update_v1( deprecated = true }] async fn organization_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, updated_organization: TypedBody, ) -> Result, HttpError> { @@ -1294,7 +1294,7 @@ async fn organization_update( tags = ["organizations"], }] async fn organization_policy_view_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result>, HttpError> { @@ -1324,7 +1324,7 @@ async fn organization_policy_view_v1( deprecated = true }] async fn organization_policy_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result>, HttpError> { @@ -1354,7 +1354,7 @@ async fn organization_policy_view( tags = ["organizations"], }] async fn organization_policy_update_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_policy: TypedBody>, ) -> Result>, HttpError> @@ -1393,7 +1393,7 @@ async fn organization_policy_update_v1( deprecated = true }] async fn organization_policy_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_policy: TypedBody>, ) -> Result>, HttpError> @@ -1431,7 +1431,7 @@ async fn organization_policy_update( tags = ["projects"], }] async fn project_list_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query>, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -1485,7 +1485,7 @@ async fn project_list_v1( deprecated = true, }] async fn project_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -1540,7 +1540,7 @@ async fn project_list( tags = ["projects"], }] async fn project_create_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, new_project: TypedBody, ) -> Result, HttpError> { @@ -1574,7 +1574,7 @@ async fn project_create_v1( deprecated = true }] async fn project_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_project: TypedBody, ) -> Result, HttpError> { @@ -1607,7 +1607,7 @@ async fn project_create( tags = ["projects"], }] async fn project_view_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result, HttpError> { @@ -1646,7 +1646,7 @@ struct ProjectPathParam { deprecated = true }] async fn project_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -1674,7 +1674,7 @@ async fn project_view( deprecated = true }] async fn project_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -1698,7 +1698,7 @@ async fn project_view_by_id( tags = ["projects"], }] async fn project_delete_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result { @@ -1728,7 +1728,7 @@ async fn project_delete_v1( deprecated = true }] async fn project_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -1754,7 +1754,7 @@ async fn project_delete( tags = ["projects"], }] async fn project_update_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, updated_project: TypedBody, @@ -1793,7 +1793,7 @@ async fn project_update_v1( deprecated = true }] async fn project_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, updated_project: TypedBody, ) -> Result, HttpError> { @@ -1826,7 +1826,7 @@ async fn project_update( tags = ["projects"], }] async fn project_policy_view_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result>, HttpError> { @@ -1857,7 +1857,7 @@ async fn project_policy_view_v1( deprecated = true }] async fn project_policy_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -1884,7 +1884,7 @@ async fn project_policy_view( tags = ["projects"], }] async fn project_policy_update_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, new_policy: TypedBody>, @@ -1916,7 +1916,7 @@ async fn project_policy_update_v1( tags = ["projects"], }] async fn project_policy_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_policy: TypedBody>, ) -> Result>, HttpError> { @@ -1956,7 +1956,7 @@ pub struct IpPoolPathParam { tags = ["system"], }] async fn ip_pool_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -1997,7 +1997,7 @@ async fn ip_pool_list( tags = ["system"], }] async fn ip_pool_create( - rqctx: Arc>>, + rqctx: RequestContext>, pool_params: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -2018,7 +2018,7 @@ async fn ip_pool_create( tags = ["system"], }] async fn ip_pool_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -2040,7 +2040,7 @@ async fn ip_pool_view( tags = ["system"], }] async fn ip_pool_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -2062,7 +2062,7 @@ async fn ip_pool_view_by_id( tags = ["system"], }] async fn ip_pool_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -2084,7 +2084,7 @@ async fn ip_pool_delete( tags = ["system"], }] async fn ip_pool_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, updates: TypedBody, ) -> Result, HttpError> { @@ -2108,7 +2108,7 @@ async fn ip_pool_update( tags = ["system"], }] async fn ip_pool_service_view( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result, HttpError> { let apictx = rqctx.context(); let nexus = &apictx.nexus; @@ -2131,7 +2131,7 @@ type IpPoolRangePaginationParams = PaginationParams; tags = ["system"], }] async fn ip_pool_range_list( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result>, HttpError> { @@ -2175,7 +2175,7 @@ async fn ip_pool_range_list( tags = ["system"], }] async fn ip_pool_range_add( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, range_params: TypedBody, ) -> Result, HttpError> { @@ -2199,7 +2199,7 @@ async fn ip_pool_range_add( tags = ["system"], }] async fn ip_pool_range_remove( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, range_params: TypedBody, ) -> Result { @@ -2225,7 +2225,7 @@ async fn ip_pool_range_remove( tags = ["system"], }] async fn ip_pool_service_range_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -2266,7 +2266,7 @@ async fn ip_pool_service_range_list( tags = ["system"], }] async fn ip_pool_service_range_add( - rqctx: Arc>>, + rqctx: RequestContext>, range_params: TypedBody, ) -> Result, HttpError> { let apictx = &rqctx.context(); @@ -2287,7 +2287,7 @@ async fn ip_pool_service_range_add( tags = ["system"], }] async fn ip_pool_service_range_remove( - rqctx: Arc>>, + rqctx: RequestContext>, range_params: TypedBody, ) -> Result { let apictx = &rqctx.context(); @@ -2309,7 +2309,7 @@ async fn ip_pool_service_range_remove( tags = ["disks"], }] async fn disk_list_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query>, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -2361,7 +2361,7 @@ async fn disk_list_v1( deprecated = true }] async fn disk_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -2403,7 +2403,7 @@ async fn disk_list( tags = ["disks"] }] async fn disk_create_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, new_disk: TypedBody, ) -> Result, HttpError> { @@ -2430,7 +2430,7 @@ async fn disk_create_v1( deprecated = true }] async fn disk_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_disk: TypedBody, ) -> Result, HttpError> { @@ -2459,7 +2459,7 @@ async fn disk_create( tags = ["disks"] }] async fn disk_view_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result, HttpError> { @@ -2497,7 +2497,7 @@ struct DiskPathParam { deprecated = true }] async fn disk_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -2526,7 +2526,7 @@ async fn disk_view( deprecated = true }] async fn disk_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -2549,7 +2549,7 @@ async fn disk_view_by_id( tags = ["disks"], }] async fn disk_delete_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result { @@ -2578,7 +2578,7 @@ async fn disk_delete_v1( deprecated = true }] async fn disk_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -2617,7 +2617,7 @@ pub enum DiskMetricName { tags = ["disks"], }] async fn disk_metrics_list( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path>, query_params: Query< PaginationParams, @@ -2663,7 +2663,7 @@ async fn disk_metrics_list( tags = ["instances"], }] async fn instance_list_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query>, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -2713,7 +2713,7 @@ async fn instance_list_v1( tags = ["instances"], }] async fn instance_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -2755,7 +2755,7 @@ async fn instance_list( tags = ["instances"], }] async fn instance_create_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, new_instance: TypedBody, ) -> Result, HttpError> { @@ -2794,7 +2794,7 @@ async fn instance_create_v1( deprecated = true, }] async fn instance_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_instance: TypedBody, ) -> Result, HttpError> { @@ -2828,7 +2828,7 @@ async fn instance_create( tags = ["instances"], }] async fn instance_view_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result, HttpError> { @@ -2867,7 +2867,7 @@ struct InstancePathParam { deprecated = true, }] async fn instance_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -2895,7 +2895,7 @@ async fn instance_view( tags = ["instances"], }] async fn instance_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -2922,7 +2922,7 @@ async fn instance_view_by_id( tags = ["instances"], }] async fn instance_delete_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result { @@ -2952,7 +2952,7 @@ async fn instance_delete_v1( deprecated = true, }] async fn instance_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -2981,7 +2981,7 @@ async fn instance_delete( tags = ["instances"], }] async fn instance_migrate_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, migrate_params: TypedBody, @@ -3021,7 +3021,7 @@ async fn instance_migrate_v1( deprecated = true, }] async fn instance_migrate( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, migrate_params: TypedBody, ) -> Result, HttpError> { @@ -3057,7 +3057,7 @@ async fn instance_migrate( tags = ["instances"], }] async fn instance_reboot_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result, HttpError> { @@ -3088,7 +3088,7 @@ async fn instance_reboot_v1( deprecated = true, }] async fn instance_reboot( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -3116,7 +3116,7 @@ async fn instance_reboot( tags = ["instances"], }] async fn instance_start_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result, HttpError> { @@ -3147,7 +3147,7 @@ async fn instance_start_v1( deprecated = true, }] async fn instance_start( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -3175,7 +3175,7 @@ async fn instance_start( tags = ["instances"], }] async fn instance_stop_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result, HttpError> { @@ -3206,7 +3206,7 @@ async fn instance_stop_v1( deprecated = true, }] async fn instance_stop( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -3234,7 +3234,7 @@ async fn instance_stop( tags = ["instances"], }] async fn instance_serial_console_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, selector_params: Query, @@ -3269,7 +3269,7 @@ async fn instance_serial_console_v1( deprecated = true, }] async fn instance_serial_console( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, ) -> Result, HttpError> { @@ -3303,10 +3303,10 @@ async fn instance_serial_console( tags = ["instances"], }] async fn instance_serial_console_stream_v1( - rqctx: Arc>>, - conn: WebsocketConnection, + rqctx: RequestContext>, path_params: Path, query_params: Query, + conn: WebsocketConnection, ) -> WebsocketChannelResult { let apictx = rqctx.context(); let nexus = &apictx.nexus; @@ -3331,9 +3331,9 @@ async fn instance_serial_console_stream_v1( deprecated = true, }] async fn instance_serial_console_stream( - rqctx: Arc>>, - conn: WebsocketConnection, + rqctx: RequestContext>, path_params: Path, + conn: WebsocketConnection, ) -> WebsocketChannelResult { let apictx = rqctx.context(); let nexus = &apictx.nexus; @@ -3355,7 +3355,7 @@ async fn instance_serial_console_stream( tags = ["instances"], }] async fn instance_disk_list_v1( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query>, path_params: Path, ) -> Result>, HttpError> { @@ -3419,7 +3419,7 @@ async fn instance_disk_list_v1( deprecated = true }] async fn instance_disk_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -3462,7 +3462,7 @@ async fn instance_disk_list( tags = ["instances"], }] async fn instance_disk_attach_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, disk_to_attach: TypedBody, @@ -3496,7 +3496,7 @@ async fn instance_disk_attach_v1( deprecated = true }] async fn instance_disk_attach( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, disk_to_attach: TypedBody, ) -> Result, HttpError> { @@ -3527,7 +3527,7 @@ async fn instance_disk_attach( tags = ["instances"], }] async fn instance_disk_detach_v1( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query_params: Query, disk_to_detach: TypedBody, @@ -3561,7 +3561,7 @@ async fn instance_disk_detach_v1( deprecated = true }] async fn instance_disk_detach( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, disk_to_detach: TypedBody, ) -> Result, HttpError> { @@ -3598,7 +3598,7 @@ async fn instance_disk_detach( tags = ["system"], }] async fn system_image_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -3635,7 +3635,7 @@ async fn system_image_list( tags = ["system"] }] async fn system_image_create( - rqctx: Arc>>, + rqctx: RequestContext>, new_image: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -3664,7 +3664,7 @@ struct GlobalImagePathParam { tags = ["system"], }] async fn system_image_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -3686,7 +3686,7 @@ async fn system_image_view( tags = ["system"], }] async fn system_image_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -3712,7 +3712,7 @@ async fn system_image_view_by_id( tags = ["system"], }] async fn system_image_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -3737,7 +3737,7 @@ async fn system_image_delete( tags = ["images"], }] async fn image_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -3779,7 +3779,7 @@ async fn image_list( tags = ["images"] }] async fn image_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_image: TypedBody, ) -> Result, HttpError> { @@ -3821,7 +3821,7 @@ struct ImagePathParam { tags = ["images"], }] async fn image_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -3852,7 +3852,7 @@ async fn image_view( tags = ["images"], }] async fn image_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -3878,7 +3878,7 @@ async fn image_view_by_id( tags = ["images"], }] async fn image_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -3913,7 +3913,7 @@ async fn image_delete( tags = ["instances"], }] async fn instance_network_interface_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -3955,7 +3955,7 @@ async fn instance_network_interface_list( tags = ["instances"], }] async fn instance_network_interface_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, interface_params: TypedBody, ) -> Result, HttpError> { @@ -4001,7 +4001,7 @@ pub struct NetworkInterfacePathParam { tags = ["instances"], }] async fn instance_network_interface_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -4034,7 +4034,7 @@ async fn instance_network_interface_delete( tags = ["instances"], }] async fn instance_network_interface_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4067,7 +4067,7 @@ async fn instance_network_interface_view( tags = ["instances"], }] async fn instance_network_interface_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4090,7 +4090,7 @@ async fn instance_network_interface_view_by_id( tags = ["instances"], }] async fn instance_network_interface_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, updated_iface: TypedBody, ) -> Result, HttpError> { @@ -4128,7 +4128,7 @@ async fn instance_network_interface_update( tags = ["instances"], }] async fn instance_external_ip_list( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -4161,7 +4161,7 @@ async fn instance_external_ip_list( tags = ["snapshots"], }] async fn snapshot_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -4203,7 +4203,7 @@ async fn snapshot_list( tags = ["snapshots"], }] async fn snapshot_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_snapshot: TypedBody, ) -> Result, HttpError> { @@ -4243,7 +4243,7 @@ struct SnapshotPathParam { tags = ["snapshots"], }] async fn snapshot_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4274,7 +4274,7 @@ async fn snapshot_view( tags = ["snapshots"], }] async fn snapshot_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4296,7 +4296,7 @@ async fn snapshot_view_by_id( tags = ["snapshots"], }] async fn snapshot_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -4329,7 +4329,7 @@ async fn snapshot_delete( tags = ["vpcs"], }] async fn vpc_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -4378,7 +4378,7 @@ struct VpcPathParam { tags = ["vpcs"], }] async fn vpc_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4404,7 +4404,7 @@ async fn vpc_view( tags = ["vpcs"], }] async fn vpc_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4426,7 +4426,7 @@ async fn vpc_view_by_id( tags = ["vpcs"], }] async fn vpc_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_vpc: TypedBody, ) -> Result, HttpError> { @@ -4456,7 +4456,7 @@ async fn vpc_create( tags = ["vpcs"], }] async fn vpc_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, updated_vpc: TypedBody, ) -> Result, HttpError> { @@ -4486,7 +4486,7 @@ async fn vpc_update( tags = ["vpcs"], }] async fn vpc_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -4517,7 +4517,7 @@ async fn vpc_delete( tags = ["vpcs"], }] async fn vpc_subnet_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -4565,7 +4565,7 @@ struct VpcSubnetPathParam { tags = ["vpcs"], }] async fn vpc_subnet_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4594,7 +4594,7 @@ async fn vpc_subnet_view( tags = ["vpcs"], }] async fn vpc_subnet_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4616,7 +4616,7 @@ async fn vpc_subnet_view_by_id( tags = ["vpcs"], }] async fn vpc_subnet_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, create_params: TypedBody, ) -> Result, HttpError> { @@ -4646,7 +4646,7 @@ async fn vpc_subnet_create( tags = ["vpcs"], }] async fn vpc_subnet_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -4675,7 +4675,7 @@ async fn vpc_subnet_delete( tags = ["vpcs"], }] async fn vpc_subnet_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, subnet_params: TypedBody, ) -> Result, HttpError> { @@ -4706,7 +4706,7 @@ async fn vpc_subnet_update( tags = ["vpcs"], }] async fn vpc_subnet_list_network_interfaces( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -4749,7 +4749,7 @@ async fn vpc_subnet_list_network_interfaces( tags = ["vpcs"], }] async fn vpc_firewall_rules_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { // TODO: Check If-Match and fail if the ETag doesn't match anymore. @@ -4782,7 +4782,7 @@ async fn vpc_firewall_rules_view( tags = ["vpcs"], }] async fn vpc_firewall_rules_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, router_params: TypedBody, ) -> Result, HttpError> { @@ -4818,7 +4818,7 @@ async fn vpc_firewall_rules_update( tags = ["vpcs"], }] async fn vpc_router_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -4866,7 +4866,7 @@ struct VpcRouterPathParam { tags = ["vpcs"], }] async fn vpc_router_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4895,7 +4895,7 @@ async fn vpc_router_view( tags = ["vpcs"], }] async fn vpc_router_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -4917,7 +4917,7 @@ async fn vpc_router_view_by_id( tags = ["vpcs"], }] async fn vpc_router_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, create_params: TypedBody, ) -> Result, HttpError> { @@ -4948,7 +4948,7 @@ async fn vpc_router_create( tags = ["vpcs"], }] async fn vpc_router_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -4977,7 +4977,7 @@ async fn vpc_router_delete( tags = ["vpcs"], }] async fn vpc_router_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, router_params: TypedBody, ) -> Result, HttpError> { @@ -5012,7 +5012,7 @@ async fn vpc_router_update( tags = ["vpcs"], }] async fn vpc_router_route_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, path_params: Path, ) -> Result>, HttpError> { @@ -5062,7 +5062,7 @@ struct RouterRoutePathParam { tags = ["vpcs"], }] async fn vpc_router_route_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5092,7 +5092,7 @@ async fn vpc_router_route_view( tags = ["vpcs"] }] async fn vpc_router_route_view_by_id( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5114,7 +5114,7 @@ async fn vpc_router_route_view_by_id( tags = ["vpcs"], }] async fn vpc_router_route_create( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, create_params: TypedBody, ) -> Result, HttpError> { @@ -5146,7 +5146,7 @@ async fn vpc_router_route_create( tags = ["vpcs"], }] async fn vpc_router_route_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -5176,7 +5176,7 @@ async fn vpc_router_route_delete( tags = ["vpcs"], }] async fn vpc_router_route_update( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, router_params: TypedBody, ) -> Result, HttpError> { @@ -5210,7 +5210,7 @@ async fn vpc_router_route_update( tags = ["system"], }] async fn rack_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -5247,7 +5247,7 @@ struct RackPathParam { tags = ["system"], }] async fn rack_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5270,7 +5270,7 @@ async fn rack_view( tags = ["system"], }] async fn sled_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -5307,7 +5307,7 @@ struct SledPathParam { tags = ["system"], }] async fn sled_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5330,7 +5330,7 @@ async fn sled_view( tags = ["system"], }] async fn updates_refresh( - rqctx: Arc>>, + rqctx: RequestContext>, ) -> Result { let apictx = rqctx.context(); let nexus = &apictx.nexus; @@ -5351,7 +5351,7 @@ async fn updates_refresh( tags = ["system"], }] async fn saga_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -5384,7 +5384,7 @@ struct SagaPathParam { tags = ["system"], }] async fn saga_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5407,7 +5407,7 @@ async fn saga_view( tags = ["silos"], }] async fn user_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -5440,7 +5440,7 @@ async fn user_list( tags = ["silos"], }] async fn group_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -5473,7 +5473,7 @@ async fn group_list( tags = ["system"], }] async fn system_user_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -5512,7 +5512,7 @@ struct BuiltinUserPathParam { tags = ["system"], }] async fn system_user_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5534,7 +5534,7 @@ async fn system_user_view( tags = ["metrics"], }] async fn timeseries_schema_get( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { @@ -5566,7 +5566,7 @@ struct RolePage { tags = ["roles"], }] async fn role_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query>, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -5620,7 +5620,7 @@ struct RolePathParam { tags = ["roles"], }] async fn role_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5646,7 +5646,7 @@ async fn role_view( tags = ["session"], }] async fn session_sshkey_list( - rqctx: Arc>>, + rqctx: RequestContext>, query_params: Query, ) -> Result>, HttpError> { let apictx = rqctx.context(); @@ -5684,7 +5684,7 @@ async fn session_sshkey_list( tags = ["session"], }] async fn session_sshkey_create( - rqctx: Arc>>, + rqctx: RequestContext>, new_key: TypedBody, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5718,7 +5718,7 @@ struct SshKeyPathParams { tags = ["session"], }] async fn session_sshkey_view( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result, HttpError> { let apictx = rqctx.context(); @@ -5747,7 +5747,7 @@ async fn session_sshkey_view( tags = ["session"], }] async fn session_sshkey_delete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); diff --git a/nexus/src/internal_api/http_entrypoints.rs b/nexus/src/internal_api/http_entrypoints.rs index f5c2cae8e5..0054d95a59 100644 --- a/nexus/src/internal_api/http_entrypoints.rs +++ b/nexus/src/internal_api/http_entrypoints.rs @@ -69,7 +69,7 @@ struct SledAgentPathParam { path = "/sled-agents/{sled_id}", }] async fn sled_agent_put( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, sled_info: TypedBody, ) -> Result { @@ -99,7 +99,7 @@ struct RackPathParam { path = "/racks/{rack_id}/initialization-complete", }] async fn rack_initialization_complete( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, info: TypedBody, ) -> Result { @@ -127,7 +127,7 @@ struct ZpoolPathParam { path = "/sled-agents/{sled_id}/zpools/{zpool_id}", }] async fn zpool_put( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, pool_info: TypedBody, ) -> Result, HttpError> { @@ -151,7 +151,7 @@ struct InstancePathParam { path = "/instances/{instance_id}", }] async fn cpapi_instances_put( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_runtime_state: TypedBody, ) -> Result { @@ -178,7 +178,7 @@ struct DiskPathParam { path = "/disks/{disk_id}", }] async fn cpapi_disks_put( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, new_runtime_state: TypedBody, ) -> Result { @@ -213,7 +213,7 @@ struct VolumePathParam { path = "/volume/{volume_id}/remove-read-only-parent", }] async fn cpapi_volume_remove_read_only_parent( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -237,7 +237,7 @@ async fn cpapi_volume_remove_read_only_parent( path = "/disk/{disk_id}/remove-read-only-parent", }] async fn cpapi_disk_remove_read_only_parent( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let apictx = rqctx.context(); @@ -258,7 +258,7 @@ async fn cpapi_disk_remove_read_only_parent( path = "/metrics/producers", }] async fn cpapi_producers_post( - request_context: Arc>>, + request_context: RequestContext>, producer_info: TypedBody, ) -> Result { let context = request_context.context(); @@ -280,7 +280,7 @@ async fn cpapi_producers_post( path = "/metrics/collectors", }] async fn cpapi_collectors_post( - request_context: Arc>>, + request_context: RequestContext>, oximeter_info: TypedBody, ) -> Result { let context = request_context.context(); @@ -302,7 +302,7 @@ async fn cpapi_collectors_post( path = "/metrics/collect/{producer_id}", }] async fn cpapi_metrics_collect( - request_context: Arc>>, + request_context: RequestContext>, path_params: Path, ) -> Result, HttpError> { let context = request_context.context(); @@ -321,7 +321,7 @@ async fn cpapi_metrics_collect( path = "/artifacts/{kind}/{name}/{version}", }] async fn cpapi_artifact_download( - request_context: Arc>>, + request_context: RequestContext>, path_params: Path, ) -> Result, HttpError> { let context = request_context.context(); diff --git a/nexus/tests/integration_tests/authn_http.rs b/nexus/tests/integration_tests/authn_http.rs index a79fd1f56d..b5b57ffaf0 100644 --- a/nexus/tests/integration_tests/authn_http.rs +++ b/nexus/tests/integration_tests/authn_http.rs @@ -16,6 +16,7 @@ use dropshot::test_util::LogContext; use dropshot::test_util::TestContext; use dropshot::ApiDescription; use dropshot::HttpErrorResponseBody; +use dropshot::RequestContext; use headers::authorization::Credentials; use http::header::HeaderValue; use omicron_nexus::authn::external::session_cookie; @@ -26,7 +27,7 @@ use omicron_nexus::authn::external::HttpAuthnScheme; use omicron_nexus::authn::external::SiloUserSilo; use omicron_nexus::db::fixed_data::silo::SILO_ID; use std::collections::HashMap; -use std::sync::{Arc, Mutex}; +use std::sync::Mutex; use uuid::Uuid; /// Tests authn::external::Authenticator with the "spoof" scheme allowed @@ -399,7 +400,7 @@ struct WhoamiResponse { path = "/whoami", }] async fn whoami_get( - rqctx: Arc>, + rqctx: RequestContext, ) -> Result, dropshot::HttpError> { let whoami_state = rqctx.context(); let authn = whoami_state.authn.authn_request(&rqctx).await?; diff --git a/nexus/tests/integration_tests/updates.rs b/nexus/tests/integration_tests/updates.rs index 5206831d8d..dc7ed68d77 100644 --- a/nexus/tests/integration_tests/updates.rs +++ b/nexus/tests/integration_tests/updates.rs @@ -32,7 +32,6 @@ use std::fs::File; use std::io::Write; use std::num::NonZeroU64; use std::path::PathBuf; -use std::sync::Arc; use tempfile::{NamedTempFile, TempDir}; use tough::editor::signed::{PathExists, SignedRole}; use tough::editor::RepositoryEditor; @@ -118,7 +117,7 @@ struct AllPath { #[endpoint(method = GET, path = "/{path:.*}", unpublished = true)] async fn static_content( - rqctx: Arc>, + rqctx: RequestContext, path: Path, ) -> Result, HttpError> { // NOTE: this is a particularly brief and bad implementation of this to keep the test shorter. diff --git a/oximeter/collector/src/lib.rs b/oximeter/collector/src/lib.rs index a6f3b551b5..d448fb30fd 100644 --- a/oximeter/collector/src/lib.rs +++ b/oximeter/collector/src/lib.rs @@ -539,7 +539,7 @@ pub fn oximeter_api() -> ApiDescription> { path = "/producers", }] async fn producers_post( - request_context: Arc>>, + request_context: RequestContext>, body: TypedBody, ) -> Result { let agent = request_context.context(); diff --git a/oximeter/instruments/src/http.rs b/oximeter/instruments/src/http.rs index cf3a5b838b..eff546c732 100644 --- a/oximeter/instruments/src/http.rs +++ b/oximeter/instruments/src/http.rs @@ -6,9 +6,11 @@ // Copyright 2021 Oxide Computer Company -use dropshot::{HttpError, HttpResponse, RequestContext, ServerContext}; +use dropshot::{ + HttpError, HttpResponse, RequestContext, RequestInfo, ServerContext, +}; use futures::Future; -use http::{Request, StatusCode}; +use http::StatusCode; use oximeter::histogram::Histogram; use oximeter::{Metric, MetricsError, Producer, Sample, Target}; use std::collections::BTreeMap; @@ -38,8 +40,8 @@ impl RequestLatencyHistogram { /// Build a new `RequestLatencyHistogram` with a specified histogram. /// /// Latencies are expressed in seconds. - pub fn new( - request: &Request, + pub fn new( + request: &RequestInfo, status_code: StatusCode, histogram: Histogram, ) -> Self { @@ -59,8 +61,8 @@ impl RequestLatencyHistogram { /// [`Histogram::span_decades`] method for more details. /// /// Latencies are expressed as seconds. - pub fn with_latency_decades( - request: &Request, + pub fn with_latency_decades( + request: &RequestInfo, status_code: StatusCode, start_decade: i8, end_decade: i8, @@ -72,7 +74,7 @@ impl RequestLatencyHistogram { )) } - fn key_for(request: &Request, status_code: StatusCode) -> String { + fn key_for(request: &RequestInfo, status_code: StatusCode) -> String { format!( "{}:{}:{}", request.uri().path(), @@ -128,9 +130,9 @@ impl LatencyTracker { /// /// This method adds the given `latency` to the internal histogram for tracking the timeseries /// to which the other arguments belong. (One is created if it does not exist.) - pub fn update( + pub fn update( &self, - request: &Request, + request: &RequestInfo, status_code: StatusCode, latency: Duration, ) -> Result<(), MetricsError> { @@ -171,8 +173,7 @@ impl LatencyTracker { Ok(_) => R::response_metadata().success.unwrap(), Err(ref e) => e.status_code, }; - let request = context.request.lock().await; - self.update(&request, status_code, latency).map_err(|e| { + self.update(&context.request, status_code, latency).map_err(|e| { HttpError::for_internal_error(format!( "error instrumenting dropshot request handler: {}", e @@ -225,7 +226,11 @@ mod tests { .unwrap(); let status_code = StatusCode::OK; tracker - .update(&request, status_code, Duration::from_secs_f64(0.5)) + .update( + &(request.into()), + status_code, + Duration::from_secs_f64(0.5), + ) .unwrap(); let key = "/some/uri:GET:200"; diff --git a/oximeter/producer/src/lib.rs b/oximeter/producer/src/lib.rs index f7cb59e16f..65eaa6c962 100644 --- a/oximeter/producer/src/lib.rs +++ b/oximeter/producer/src/lib.rs @@ -17,7 +17,6 @@ use serde::{Deserialize, Serialize}; use slog::Drain; use slog::{debug, error, info, o}; use std::net::SocketAddr; -use std::sync::Arc; use thiserror::Error; use uuid::Uuid; @@ -157,7 +156,7 @@ pub struct ProducerIdPathParams { path = "/collect/{producer_id}", }] async fn collect_endpoint( - request_context: Arc>, + request_context: RequestContext, path_params: Path, ) -> Result, HttpError> { let registry = request_context.context(); diff --git a/sled-agent/src/http_entrypoints.rs b/sled-agent/src/http_entrypoints.rs index ddaf9be7b3..f3376dae3f 100644 --- a/sled-agent/src/http_entrypoints.rs +++ b/sled-agent/src/http_entrypoints.rs @@ -20,7 +20,6 @@ use omicron_common::api::internal::nexus::InstanceRuntimeState; use omicron_common::api::internal::nexus::UpdateArtifact; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::sync::Arc; use uuid::Uuid; use super::sled_agent::SledAgent; @@ -58,7 +57,7 @@ pub fn api() -> SledApiDescription { path = "/services", }] async fn services_put( - rqctx: Arc>, + rqctx: RequestContext, body: TypedBody, ) -> Result { let sa = rqctx.context(); @@ -72,7 +71,7 @@ async fn services_put( path = "/zpools", }] async fn zpools_get( - rqctx: Arc>, + rqctx: RequestContext, ) -> Result>, HttpError> { let sa = rqctx.context(); Ok(HttpResponseOk(sa.zpools_get().await.map_err(|e| Error::from(e))?)) @@ -83,7 +82,7 @@ async fn zpools_get( path = "/filesystem", }] async fn filesystem_put( - rqctx: Arc>, + rqctx: RequestContext, body: TypedBody, ) -> Result { let sa = rqctx.context(); @@ -109,7 +108,7 @@ struct InstancePathParam { path = "/instances/{instance_id}", }] async fn instance_put( - rqctx: Arc>, + rqctx: RequestContext, path_params: Path, body: TypedBody, ) -> Result, HttpError> { @@ -139,7 +138,7 @@ struct DiskPathParam { path = "/disks/{disk_id}", }] async fn disk_put( - rqctx: Arc>, + rqctx: RequestContext, path_params: Path, body: TypedBody, ) -> Result, HttpError> { @@ -162,7 +161,7 @@ async fn disk_put( path = "/update" }] async fn update_artifact( - rqctx: Arc>, + rqctx: RequestContext, artifact: TypedBody, ) -> Result { let sa = rqctx.context(); @@ -175,7 +174,7 @@ async fn update_artifact( path = "/instances/{instance_id}/serial", }] async fn instance_serial_get( - rqctx: Arc>, + rqctx: RequestContext, path_params: Path, query: Query, ) -> Result, HttpError> { @@ -239,7 +238,7 @@ pub struct InstanceIssueDiskSnapshotRequestResponse { path = "/instances/{instance_id}/disks/{disk_id}/snapshot", }] async fn instance_issue_disk_snapshot_request( - rqctx: Arc>, + rqctx: RequestContext, path_params: Path, body: TypedBody, ) -> Result, HttpError> @@ -285,7 +284,7 @@ pub struct DiskSnapshotRequestResponse { path = "/disks/{disk_id}/snapshot", }] async fn issue_disk_snapshot_request( - rqctx: Arc>, + rqctx: RequestContext, path_params: Path, body: TypedBody, ) -> Result, HttpError> { @@ -316,7 +315,7 @@ struct VpcPathParam { path = "/vpc/{vpc_id}/firewall/rules", }] async fn vpc_firewall_rules_put( - rqctx: Arc>, + rqctx: RequestContext, path_params: Path, body: TypedBody, ) -> Result { diff --git a/sled-agent/src/sim/http_entrypoints.rs b/sled-agent/src/sim/http_entrypoints.rs index 0297f83804..073ff7fcc3 100644 --- a/sled-agent/src/sim/http_entrypoints.rs +++ b/sled-agent/src/sim/http_entrypoints.rs @@ -66,7 +66,7 @@ struct InstancePathParam { path = "/instances/{instance_id}", }] async fn instance_put( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, body: TypedBody, ) -> Result, HttpError> { @@ -84,7 +84,7 @@ async fn instance_put( path = "/instances/{instance_id}/poke", }] async fn instance_poke_post( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let sa = rqctx.context(); @@ -104,7 +104,7 @@ struct DiskPathParam { path = "/disks/{disk_id}", }] async fn disk_put( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, body: TypedBody, ) -> Result, HttpError> { @@ -126,7 +126,7 @@ async fn disk_put( path = "/disks/{disk_id}/poke", }] async fn disk_poke_post( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, ) -> Result { let sa = rqctx.context(); @@ -140,7 +140,7 @@ async fn disk_poke_post( path = "/update" }] async fn update_artifact( - rqctx: Arc>>, + rqctx: RequestContext>, artifact: TypedBody, ) -> Result { crate::updates::download_artifact( @@ -157,7 +157,7 @@ async fn update_artifact( path = "/instances/{instance_id}/serial", }] async fn instance_serial_get( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, query: Query, ) -> Result, HttpError> { @@ -219,7 +219,7 @@ pub struct InstanceIssueDiskSnapshotRequestResponse { path = "/instances/{instance_id}/disks/{disk_id}/snapshot", }] async fn instance_issue_disk_snapshot_request( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, body: TypedBody, ) -> Result, HttpError> @@ -266,7 +266,7 @@ pub struct DiskSnapshotRequestResponse { path = "/disks/{disk_id}/snapshot", }] async fn issue_disk_snapshot_request( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, body: TypedBody, ) -> Result, HttpError> { @@ -297,7 +297,7 @@ struct VpcPathParam { path = "/vpc/{vpc_id}/firewall/rules", }] async fn vpc_firewall_rules_put( - rqctx: Arc>>, + rqctx: RequestContext>, path_params: Path, body: TypedBody, ) -> Result { diff --git a/sled-agent/src/sim/http_entrypoints_storage.rs b/sled-agent/src/sim/http_entrypoints_storage.rs index fcdd19be70..831e96f80e 100644 --- a/sled-agent/src/sim/http_entrypoints_storage.rs +++ b/sled-agent/src/sim/http_entrypoints_storage.rs @@ -59,7 +59,7 @@ struct RegionPath { path = "/crucible/0/regions", }] async fn region_list( - rc: Arc>>, + rc: RequestContext>, ) -> Result>, HttpError> { let crucible = rc.context(); Ok(HttpResponseOk(crucible.list().await)) @@ -70,7 +70,7 @@ async fn region_list( path = "/crucible/0/regions", }] async fn region_create( - rc: Arc>>, + rc: RequestContext>, body: TypedBody, ) -> Result, HttpError> { let params = body.into_inner(); @@ -84,7 +84,7 @@ async fn region_create( path = "/crucible/0/regions/{id}", }] async fn region_get( - rc: Arc>>, + rc: RequestContext>, path: TypedPath, ) -> Result, HttpError> { let id = path.into_inner().id; @@ -103,7 +103,7 @@ async fn region_get( path = "/crucible/0/regions/{id}", }] async fn region_delete( - rc: Arc>>, + rc: RequestContext>, path: TypedPath, ) -> Result { let id = path.into_inner().id; @@ -126,7 +126,7 @@ async fn region_delete( path = "/crucible/0/regions/{id}/snapshots", }] async fn region_get_snapshots( - rc: Arc>>, + rc: RequestContext>, path: TypedPath, ) -> Result, HttpError> { let id = path.into_inner().id; @@ -158,7 +158,7 @@ struct GetSnapshotPath { path = "/crucible/0/regions/{id}/snapshots/{name}", }] async fn region_get_snapshot( - rc: Arc>>, + rc: RequestContext>, path: TypedPath, ) -> Result, HttpError> { let p = path.into_inner(); @@ -194,7 +194,7 @@ struct DeleteSnapshotPath { path = "/crucible/0/regions/{id}/snapshots/{name}", }] async fn region_delete_snapshot( - rc: Arc>>, + rc: RequestContext>, path: TypedPath, ) -> Result { let p = path.into_inner(); @@ -226,7 +226,7 @@ struct RunSnapshotPath { path = "/crucible/0/regions/{id}/snapshots/{name}/run", }] async fn region_run_snapshot( - rc: Arc>>, + rc: RequestContext>, path: TypedPath, ) -> Result, HttpError> { let p = path.into_inner(); @@ -266,7 +266,7 @@ async fn region_run_snapshot( path = "/crucible/0/regions/{id}/snapshots/{name}/run", }] async fn region_delete_running_snapshot( - rc: Arc>>, + rc: RequestContext>, path: TypedPath, ) -> Result { let p = path.into_inner(); diff --git a/wicketd/src/http_entrypoints.rs b/wicketd/src/http_entrypoints.rs index 22ab084ddb..56140c39b2 100644 --- a/wicketd/src/http_entrypoints.rs +++ b/wicketd/src/http_entrypoints.rs @@ -15,7 +15,6 @@ use dropshot::Path; use dropshot::RequestContext; use dropshot::UntypedBody; use installinator_artifactd::ArtifactId; -use std::sync::Arc; use crate::ServerContext; @@ -50,7 +49,7 @@ pub fn api() -> WicketdApiDescription { path = "/inventory" }] async fn get_inventory( - rqctx: Arc>, + rqctx: RequestContext, ) -> Result, HttpError> { match rqctx.context().mgs_handle.get_inventory().await { Ok(inventory) => Ok(HttpResponseOk(inventory)), @@ -66,7 +65,7 @@ async fn get_inventory( path = "/artifacts/{name}/{version}", }] async fn put_artifact( - rqctx: Arc>, + rqctx: RequestContext, path: Path, body: UntypedBody, ) -> Result { From 8398f55e4ad5630eb4a608ef2d38d7a1d7e193d2 Mon Sep 17 00:00:00 2001 From: David Pacheco Date: Wed, 18 Jan 2023 19:23:59 -0800 Subject: [PATCH 2/2] switch back to dropshot "main" --- Cargo.lock | 10 +++++----- Cargo.toml | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0214a36271..074a8a112e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1537,7 +1537,7 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dropshot" version = "0.9.0-dev" -source = "git+https://github.com/oxidecomputer/dropshot?branch=remove-arc-rqctx#ed997871350de84cd3d645aa59f32385454e0963" +source = "git+https://github.com/oxidecomputer/dropshot?branch=main#af0f37c96b304dd255fbd4d6ab857021577f5f68" dependencies = [ "async-stream", "async-trait", @@ -1578,7 +1578,7 @@ dependencies = [ [[package]] name = "dropshot_endpoint" version = "0.9.0-dev" -source = "git+https://github.com/oxidecomputer/dropshot?branch=remove-arc-rqctx#ed997871350de84cd3d645aa59f32385454e0963" +source = "git+https://github.com/oxidecomputer/dropshot?branch=main#af0f37c96b304dd255fbd4d6ab857021577f5f68" dependencies = [ "proc-macro2", "quote", @@ -5258,11 +5258,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index fa5f9e7a4c..7785655a7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,8 +115,7 @@ debug-ignore = "1.0.5" derive_more = "0.99.17" diesel = { version = "2.0.2" } diesel-dtrace = { git = "https://github.com/oxidecomputer/diesel-dtrace", rev = "18748d9f76c94e1f4400fbec0859b3e77a221a8d" } -# XXX-dap update before landing to point back to main -dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "remove-arc-rqctx", features = [ "usdt-probes" ] } +dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "main", features = [ "usdt-probes" ] } expectorate = "1.0.6" # TODO(luqman): Update once merged & new release is cut # https://github.com/rafalh/rust-fatfs/pull/76