Skip to content
Draft
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
40 changes: 35 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ dns-server = { path = "dns-server" }
dns-server-api = { path = "dns-server-api" }
dns-service-client = { path = "clients/dns-service-client" }
dpd-client = { git = "https://github.com/oxidecomputer/dendrite", rev = "f20f786e67c86388dfaaf0ef3aa9d2693dfe1da4" }
dropshot = { version = "0.16.6", features = [ "usdt-probes" ] }
dropshot = { git = "https://github.com/oxidecomputer/dropshot", rev = "d707f541", features = [ "usdt-probes" ] }
dropshot-api-manager = "0.5.2"
dropshot-api-manager-types = "0.5.2"
dyn-clone = "1.0.20"
Expand Down Expand Up @@ -1040,6 +1040,8 @@ opt-level = 3
# drift = { path = "../drift" }
# dropshot = { path = "../dropshot/dropshot" }
# dropshot_endpoint = { path = "../dropshot/dropshot_endpoint" }
dropshot = { git = "https://github.com/oxidecomputer/dropshot", rev = "d707f541" }
dropshot_endpoint = { git = "https://github.com/oxidecomputer/dropshot", rev = "d707f541" }
# dropshot-api-manager = { path = "../dropshot-api-manager/crates/dropshot-api-manager" }
# dropshot-api-manager-types = { path = "../dropshot-api-manager/crates/dropshot-api-manager-types" }
# progenitor = { path = "../progenitor/progenitor" }
Expand Down
2 changes: 1 addition & 1 deletion dns-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl TransientServer {
bind_address: "[::1]:0".parse().unwrap(),
default_request_body_max_bytes: 4 * 1024 * 1024,
default_handler_task_mode: dropshot::HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
},
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion dns-server/tests/basic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ fn test_config(
bind_address: "[::1]:0".to_string().parse().unwrap(),
default_request_body_max_bytes: 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
};

Ok((tmp_dir, config_storage, config_dropshot, logctx))
Expand Down
2 changes: 1 addition & 1 deletion dns-server/tests/cross_version_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn test_config(
bind_address: "[::1]:0".to_string().parse().unwrap(),
default_request_body_max_bytes: 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
};

Ok((tmp_dir, config_storage, config_dropshot, logctx))
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn start_dropshot_server(
bind_address: SocketAddr::V6(addr),
default_request_body_max_bytes,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
};

let http_server = dropshot::ServerBuilder::new(
Expand Down
2 changes: 1 addition & 1 deletion installinator-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ pub fn default_config(bind_address: std::net::SocketAddr) -> ConfigDropshot {
bind_address,
default_request_body_max_bytes: 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
}
}
2 changes: 1 addition & 1 deletion internal-dns/resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ mod test {
bind_address: "[::1]:0".parse().unwrap(),
default_request_body_max_bytes: 8 * 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
},
)
.await
Expand Down
1 change: 1 addition & 0 deletions nexus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ camino-tempfile.workspace = true
criterion.workspace = true
diesel.workspace = true
dns-server.workspace = true
flate2.workspace = true
expectorate.workspace = true
gateway-messages.workspace = true
gateway-test-utils.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/background/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ pub mod test {
bind_address: "[::1]:0".parse().unwrap(),
default_request_body_max_bytes: 8 * 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
},
)
.await
Expand Down
10 changes: 8 additions & 2 deletions nexus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,20 @@ impl Server {
// (but a different port) as the `internal` server. The latter is
// available for proxied connections via the tech port in the event the
// rack has lost connectivity (see RFD 431).
let external_dropshot_config = {
let mut c = config.deployment.dropshot_external.dropshot.clone();
c.compression = dropshot::CompressionConfig::Gzip;
c
};

let techport_server_bind_addr = {
let mut addr = http_server_internal.local_addr();
addr.set_port(config.deployment.techport_external_server_port);
addr
};
let techport_server_config = ConfigDropshot {
bind_address: techport_server_bind_addr,
..config.deployment.dropshot_external.dropshot.clone()
..external_dropshot_config.clone()
};

let http_server_external = {
Expand All @@ -230,7 +236,7 @@ impl Server {
apictx.for_external(),
log.new(o!("component" => "dropshot_external")),
)
.config(config.deployment.dropshot_external.dropshot.clone())
.config(external_dropshot_config.clone())
.version_policy(dropshot::VersionPolicy::Dynamic(Box::new(
dropshot::ClientSpecifiesVersionInHeader::new(
omicron_common::api::VERSION_HEADER,
Expand Down
2 changes: 2 additions & 0 deletions nexus/test-utils/src/http_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ impl<'a> RequestBuilder<'a> {
http::header::DATE,
http::header::LOCATION,
http::header::SET_COOKIE,
http::header::TRANSFER_ENCODING,
http::header::VARY,
http::header::HeaderName::from_static("x-request-id"),
]),
expected_response_headers: http::HeaderMap::default(),
Expand Down
53 changes: 53 additions & 0 deletions nexus/tests/integration_tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,56 @@ async fn test_ping(cptestctx: &ControlPlaneTestContext) {
.await;
assert_eq!(health.status, system::PingStatus::Ok);
}

/// Test that the external API returns gzip-compressed responses when the
/// client sends Accept-Encoding: gzip.
#[nexus_test]
async fn test_gzip_compression(cptestctx: &ControlPlaneTestContext) {
let client = &cptestctx.external_client;

// Create several projects so the response body exceeds the minimum
// compression threshold (512 bytes).
for i in 0..10 {
create_project(&client, &format!("project-{i}")).await;
}

// With Accept-Encoding: gzip, response should be compressed.
let response = NexusRequest::new(
RequestBuilder::new(client, Method::GET, "/v1/projects")
.header(http::header::ACCEPT_ENCODING, "gzip")
.expect_status(Some(StatusCode::OK)),
)
.authn_as(AuthnMode::PrivilegedUser)
.execute()
.await
.unwrap();

assert_eq!(
response.headers.get(http::header::CONTENT_ENCODING).unwrap(),
"gzip",
);

// Decompress and verify the body is valid JSON.
let compressed_len = response.body.len();
let mut decoder = flate2::read::GzDecoder::new(&response.body[..]);
let mut decompressed = String::new();
std::io::Read::read_to_string(&mut decoder, &mut decompressed).unwrap();
let page: dropshot::ResultsPage<Project> =
serde_json::from_str(&decompressed).unwrap();
assert_eq!(page.items.len(), 10);

// Without Accept-Encoding: gzip, response should not be compressed.
let response = NexusRequest::object_get(client, "/v1/projects")
.authn_as(AuthnMode::PrivilegedUser)
.execute()
.await
.unwrap();
assert!(response.headers.get(http::header::CONTENT_ENCODING).is_none());

let uncompressed_len = response.body.len();
assert!(
compressed_len < uncompressed_len,
"compressed body ({compressed_len} bytes) should be smaller \
than uncompressed body ({uncompressed_len} bytes)"
);
}
2 changes: 1 addition & 1 deletion oximeter/producer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl Server {
bind_address: server_info.address,
default_request_body_max_bytes,
default_handler_task_mode: dropshot::HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
};
let server = Self::build_dropshot_server(&log, &registry, &dropshot)?;

Expand Down
6 changes: 3 additions & 3 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2446,14 +2446,14 @@ impl ServiceManager {
default_request_body_max_bytes: 1048576,
default_handler_task_mode:
HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
},
},
dropshot_internal: dropshot::ConfigDropshot {
bind_address: (*internal_address).into(),
default_request_body_max_bytes: 1048576,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
},
dropshot_lockstep: dropshot::ConfigDropshot {
bind_address: SocketAddr::new(
Expand All @@ -2462,7 +2462,7 @@ impl ServiceManager {
),
default_request_body_max_bytes: 1048576,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
},
internal_dns: nexus_config::InternalDns::FromSubnet {
subnet: Ipv6Subnet::<RACK_PREFIX>::new(
Expand Down
2 changes: 1 addition & 1 deletion sled-agent/src/sim/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2316,7 +2316,7 @@ impl PantryServer {
// - bulk writes into disks
default_request_body_max_bytes: 8192 * 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
})
.start()
.expect("Could not initialize pantry server");
Expand Down
2 changes: 1 addition & 1 deletion wicketd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Server {
bind_address: SocketAddr::V6(args.address),
default_request_body_max_bytes: 8 * 1024 * 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
..Default::default()
};

let mgs_manager = MgsManager::new(&log, args.mgs_address);
Expand Down
Loading