Skip to content

Commit

Permalink
WIP: update to hyper v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ahl committed Aug 21, 2024
1 parent 64350cd commit 575e66a
Show file tree
Hide file tree
Showing 12 changed files with 331 additions and 143 deletions.
425 changes: 305 additions & 120 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ clap = "4.2"
const_format = "0.2"
crossbeam-channel = "0.5"
ctrlc = "3.2"
dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "main" }
# dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "main" }
dropshot = { git = "https://github.com/seanmonstar/dropshot", branch = "hyper-v1-2.4-own-body" }
erased-serde = "0.4"
errno = "0.2.8"
escargot = "0.5.8"
Expand All @@ -116,8 +117,8 @@ futures = "0.3"
futures-util = "0.3.21"
flate2 = "1.0.28"
hex = "0.4.3"
http = "0.2.9"
hyper = "0.14"
http = "1.1.0"
hyper = "1.0"
indicatif = "0.17.3"
inventory = "0.3.0"
kstat-rs = "0.2.3"
Expand Down
4 changes: 2 additions & 2 deletions bin/mock-server/src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,15 @@ mod serial {
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;

use dropshot::WebsocketConnectionRaw;
use futures::StreamExt;
use hyper::upgrade::Upgraded;
use tokio::sync::{mpsc, Notify};
use tokio_tungstenite::tungstenite::protocol::{
frame::coding::CloseCode, CloseFrame,
};
use tokio_tungstenite::WebSocketStream;

type WsConn = WebSocketStream<Upgraded>;
type WsConn = WebSocketStream<WebsocketConnectionRaw>;

const DEFAULT_MAX_LEN: usize = 1024;

Expand Down
1 change: 0 additions & 1 deletion bin/propolis-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ crucible-client-types.workspace = true
dropshot = { workspace = true, features = ["usdt-probes"] }
erased-serde.workspace = true
futures.workspace = true
http.workspace = true
hyper.workspace = true
internal-dns.workspace = true
kstat-rs.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion bin/propolis-server/src/lib/migrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) trait MigrateConn:
}

impl MigrateConn for tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream> {}
impl MigrateConn for hyper::upgrade::Upgraded {}
impl MigrateConn for dropshot::WebsocketConnectionRaw {}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum MigrateRole {
Expand Down
13 changes: 8 additions & 5 deletions bin/propolis-server/src/lib/serial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ use std::sync::Arc;
use std::time::Duration;

use crate::serial::history_buffer::{HistoryBuffer, SerialHistoryOffset};
use dropshot::WebsocketConnectionRaw;
use futures::future::Fuse;
use futures::stream::SplitSink;
use futures::{FutureExt, SinkExt, StreamExt};
use hyper::upgrade::Upgraded;
use propolis::chardev::{pollers, Sink, Source};
use propolis_api_types::InstanceSerialConsoleControlMessage;
use slog::{info, warn, Logger};
Expand Down Expand Up @@ -78,11 +78,14 @@ pub struct SerialTask {
/// clients of a migration
pub control_ch: mpsc::Sender<SerialTaskControlMessage>,
/// Channel used to send new client connections to the streaming task
pub websocks_ch: mpsc::Sender<WebSocketStream<Upgraded>>,
pub websocks_ch:
mpsc::Sender<WebSocketStream<dropshot::WebsocketConnectionRaw>>,
}

pub async fn instance_serial_task<Device: Sink + Source>(
mut websocks_recv: mpsc::Receiver<WebSocketStream<Upgraded>>,
mut websocks_recv: mpsc::Receiver<
WebSocketStream<dropshot::WebsocketConnectionRaw>,
>,
mut control_recv: mpsc::Receiver<SerialTaskControlMessage>,
serial: Arc<Serial<Device>>,
log: Logger,
Expand All @@ -94,11 +97,11 @@ pub async fn instance_serial_task<Device: Sink + Source>(

let mut ws_sinks: HashMap<
usize,
SplitSink<WebSocketStream<Upgraded>, Message>,
SplitSink<WebSocketStream<dropshot::WebsocketConnectionRaw>, Message>,
> = HashMap::new();
let mut ws_streams: HashMap<
usize,
futures::stream::SplitStream<WebSocketStream<Upgraded>>,
futures::stream::SplitStream<WebSocketStream<WebsocketConnectionRaw>>,
> = HashMap::new();

let (send_ch, mut recv_ch) = mpsc::channel(4);
Expand Down
10 changes: 5 additions & 5 deletions bin/propolis-server/src/lib/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ async fn instance_ensure_common(
| VmError::AlreadyInitialized
| VmError::RundownInProgress => HttpError::for_client_error(
Some(api::ErrorCode::AlreadyInitialized.to_string()),
http::StatusCode::CONFLICT,
hyper::StatusCode::CONFLICT,
"instance already initialized".to_string(),
),
VmError::InitializationFailed(e) => HttpError::for_internal_error(
Expand Down Expand Up @@ -390,7 +390,7 @@ async fn instance_state_monitor(
state_watcher.changed().await.map_err(|_| {
HttpError::for_client_error(
Some(api::ErrorCode::NoInstance.to_string()),
http::status::StatusCode::GONE,
hyper::StatusCode::GONE,
format!(
"No instance present; will never reach generation {}",
gen
Expand Down Expand Up @@ -420,7 +420,7 @@ async fn instance_state_put(
}
VmError::ForbiddenStateChange(reason) => HttpError::for_status(
Some(format!("instance state change not allowed: {}", reason)),
http::status::StatusCode::FORBIDDEN,
hyper::StatusCode::FORBIDDEN,
),
_ => HttpError::for_internal_error(format!(
"unexpected error from VM controller: {e}"
Expand Down Expand Up @@ -674,7 +674,7 @@ async fn instance_issue_crucible_vcr_request(
.map_err(|e| match e {
VmError::ForbiddenStateChange(reason) => HttpError::for_status(
Some(format!("instance state change not allowed: {}", reason)),
http::status::StatusCode::FORBIDDEN,
hyper::StatusCode::FORBIDDEN,
),
_ => HttpError::for_internal_error(format!(
"unexpected error from VM controller: {e}"
Expand Down Expand Up @@ -730,7 +730,7 @@ pub fn api() -> ApiDescription<Arc<DropshotEndpointContext>> {
fn not_created_error() -> HttpError {
HttpError::for_client_error(
Some(api::ErrorCode::NoInstance.to_string()),
http::StatusCode::FAILED_DEPENDENCY,
hyper::StatusCode::FAILED_DEPENDENCY,
"Server not initialized (no instance)".to_string(),
)
}
Expand Down
2 changes: 1 addition & 1 deletion bin/propolis-server/src/lib/vm/request_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ impl Drop for ExternalRequestQueue {
"VM destroyed before request could be handled"
.to_string(),
),
http::StatusCode::GONE,
hyper::StatusCode::GONE,
)));
}

Expand Down
1 change: 0 additions & 1 deletion phd-tests/framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fatfs.workspace = true
futures.workspace = true
flate2.workspace = true
hex.workspace = true
http.workspace = true
libc.workspace = true
newtype_derive.workspace = true
propolis-client.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion phd-tests/framework/src/test_vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ async fn try_ensure_vm_destroyed(client: &Client) {
// nothing else that *can* be done, but the error is unusual and should
// be logged.
match error.status() {
Some(http::status::StatusCode::FAILED_DEPENDENCY) => {}
Some(reqwest::StatusCode::FAILED_DEPENDENCY) => {}
_ => {
error!(
%error,
Expand Down
1 change: 1 addition & 0 deletions phd-tests/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ futures.workspace = true
http.workspace = true
propolis-client.workspace = true
phd-testcase.workspace = true
reqwest.workspace = true
tracing.workspace = true
uuid.workspace = true
6 changes: 3 additions & 3 deletions phd-tests/tests/src/server_state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ async fn instance_stop_causes_destroy_test(ctx: &Framework) {

assert!(matches!(
vm.run().await.unwrap_err().status().unwrap(),
http::status::StatusCode::FAILED_DEPENDENCY
reqwest::StatusCode::FAILED_DEPENDENCY
));
assert!(matches!(
vm.stop().await.unwrap_err().status().unwrap(),
http::status::StatusCode::FAILED_DEPENDENCY
reqwest::StatusCode::FAILED_DEPENDENCY
));
assert!(matches!(
vm.reset().await.unwrap_err().status().unwrap(),
http::status::StatusCode::FAILED_DEPENDENCY
reqwest::StatusCode::FAILED_DEPENDENCY
));
}

Expand Down

0 comments on commit 575e66a

Please sign in to comment.