Skip to content

Issue 182 - Error handling, propagation, etc. #187

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
db55f1b
Issue-182 - connect_to_app test fixes
huntharo Apr 23, 2024
4e0eb98
Issue-182 - LambdaRequest tests
huntharo Apr 23, 2024
7559161
Issue-182 - RouterChannel remove test comments
huntharo Apr 23, 2024
d96061d
Issue-182 - LambdaService error test
huntharo Apr 23, 2024
8b3e854
Issue-182 - Implement RouterUnreachable error
huntharo Apr 23, 2024
dd39bb8
Issue-182 - test_mock_router
huntharo Apr 24, 2024
6c044f4
Issue-182 - RouterChannel FIXME comments
huntharo Apr 24, 2024
ef9c076
Issue-182 - RouterChannel exit failing test
huntharo Apr 24, 2024
0d9729c
Issue-182 - RouterChannel response panics
huntharo Apr 24, 2024
508ff7a
Issue-182 - RouterChannel fix not exiting on goaway set
huntharo Apr 24, 2024
e3bfb19
Issue-182 - Simplify rps formatting
huntharo Apr 24, 2024
5032b0a
Issue-182 - RouterChannel error propagation
huntharo Apr 24, 2024
4461624
Issue-182 - Squelch log spew on healthcheck
huntharo Apr 24, 2024
2c23fd4
Issue-182 - Add exit reasons and error types
huntharo Apr 24, 2024
700b23d
Issue-182 - LambdaService catch invalid lambda payload
huntharo Apr 24, 2024
e71de92
Issue-182 - Add comment to main about how to reproduce a fatal error
huntharo Apr 24, 2024
5d3c559
Issue-182 - LambdaService add AppConnectionUnreachable fatal error test
huntharo Apr 24, 2024
bf6f894
Issue-182 - Improve test
huntharo Apr 24, 2024
dd002a2
Issue-182 - Remove println from tests
huntharo Apr 24, 2024
4bbb278
Issue-182 - Remove erroneous comment
huntharo Apr 25, 2024
e0c98f4
Issue-182 - Document large binary stress test command
huntharo Apr 25, 2024
8414890
Issue-182 - Relay Router status code errors
huntharo Apr 25, 2024
bf1ccb3
Issue-182 - Tests for non-200 status codes on router channels
huntharo Apr 25, 2024
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
5 changes: 5 additions & 0 deletions DEVELOPMENT-CURRENT-COMMANDS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# stress

curl -v http://localhost:5001/ping

TOKIO_WORKER_THREADS=1 oha -c 20 -z 60s http://127.0.0.1:5001/ping

TOKIO_WORKER_THREADS=1 oha -c 20 -z 60s -D target/release/extension -T application/octet-stream -m POST http://127.0.0.1:5001/echo

k6 run k6/ping-dispatch-local.js

curl -X POST -H "Content-Type: text/markdown" --data-binary @README.md http://localhost:5001/echo --compressed -o README2.md -v

# node
Expand Down
16 changes: 0 additions & 16 deletions extension/src/app_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ mod tests {
async move {
// Increment the request count
request_count.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
println!(
"Request count: {}",
request_count.load(std::sync::atomic::Ordering::SeqCst)
);

if request_count.load(std::sync::atomic::Ordering::SeqCst) == 1 {
let req =
Expand Down Expand Up @@ -235,10 +231,6 @@ mod tests {
async move {
// Increment the request count
request_count.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
println!(
"Request count: {}",
request_count.load(std::sync::atomic::Ordering::SeqCst)
);

if request_count.load(std::sync::atomic::Ordering::SeqCst) == 1 {
let req =
Expand Down Expand Up @@ -357,10 +349,6 @@ mod tests {
async move {
// Increment the request count
request_count.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
println!(
"Request count: {}",
request_count.load(std::sync::atomic::Ordering::SeqCst)
);

// Create a channel for the stream
let (mut tx, rx) = tokio::io::duplex(65_536);
Expand Down Expand Up @@ -485,10 +473,6 @@ mod tests {
async move {
// Increment the request count
request_count.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
println!(
"Request count: {}",
request_count.load(std::sync::atomic::Ordering::SeqCst)
);

// Create a channel for the stream
let (mut tx, rx) = tokio::io::duplex(65_536);
Expand Down
13 changes: 1 addition & 12 deletions extension/src/app_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,13 @@ async fn create_connection(
}
Ok(Err(err)) => {
// Connection error
log::error!(
"Health check - Contained App TcpStream::connect error: {}, endpoint: {}",
err,
healthcheck_addr
);
return Err(anyhow::anyhow!(
"Health check - TcpStream::connect error: {}",
err
));
}
Err(err) => {
// Timeout
log::error!(
"Health check - Contained App TcpStream::connect timed out: {}, endpoint: {}",
err,
healthcheck_addr
);
return Err(anyhow::anyhow!(
"Health check - TcpStream::connect timed out: {}",
err
Expand Down Expand Up @@ -144,8 +134,7 @@ pub async fn health_check_contained_app(
}
}));
}
Err(e) => {
log::error!("Failed to create connection: {}", e);
Err(_) => {
continue;
}
}
Expand Down
25 changes: 8 additions & 17 deletions extension/src/connect_to_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ pub async fn connect_to_app(
// }

// This task just keeps the connection from being dropped
// TODO: Let's return this and hold it elsewhere
tokio::task::spawn(async move {
if let Err(err) = connection.await {
log::error!(
Expand All @@ -179,6 +178,7 @@ mod tests {
use crate::endpoint::{Endpoint, Scheme};
use httpmock::{Method::GET, MockServer};
use std::sync::Arc;
use tokio_test::assert_err;

#[tokio::test]
async fn test_connect_to_app_dns_failure() {
Expand Down Expand Up @@ -225,15 +225,15 @@ mod tests {
#[tokio::test]
async fn test_connect_to_app_blackhole_timeout() {
// 192.0.2.0/24 (TEST-NET-1)
let router_endpoint = Endpoint::new(Scheme::Http, "192.0.2.0", 12345);
let app_endpoint = Endpoint::new(Scheme::Http, "192.0.2.0", 12345);
let pool_id = Arc::from("pool_id");
let lambda_id = Arc::from("lambda_id");
let channel_id = Arc::from("channel_id");

// Act
let start = std::time::Instant::now();
let sender = connect_to_app(
&router_endpoint,
&app_endpoint,
Arc::clone(&pool_id),
Arc::clone(&lambda_id),
Arc::clone(&channel_id),
Expand All @@ -242,13 +242,7 @@ mod tests {
let duration = std::time::Instant::now().duration_since(start);

// Assert
match sender {
Ok(_) => assert!(sender.is_err(), "Connection should not be established"),
Err(e) => assert_eq!(
e.to_string(),
"TcpStream::connect timed out: deadline has elapsed"
),
}
assert_err!(sender, "Connection should not be established");
assert!(
duration >= std::time::Duration::from_secs(5),
"Connection should take at least 5 seconds"
Expand All @@ -268,15 +262,15 @@ mod tests {
then.status(200).body("OK");
});

let router_endpoint = Endpoint::new(Scheme::Http, "localhost", app_server.port());
let app_endpoint = Endpoint::new(Scheme::Http, "localhost", app_server.port());
let pool_id = Arc::from("pool_id");
let lambda_id = Arc::from("lambda_id");
let channel_id = Arc::from("channel_id");

// Act
let start = std::time::Instant::now();
let sender = connect_to_app(
&router_endpoint,
let result = connect_to_app(
&app_endpoint,
Arc::clone(&pool_id),
Arc::clone(&lambda_id),
Arc::clone(&channel_id),
Expand All @@ -285,10 +279,7 @@ mod tests {
let duration = std::time::Instant::now().duration_since(start);

// Assert
match sender {
Ok(_) => assert!(sender.is_ok(), "Connection should be established"),
Err(e) => assert_eq!(e.to_string(), "Contained App ready check timed out"),
}
assert!(result.is_ok(), "Connection should be established");
assert!(
duration <= std::time::Duration::from_secs(2),
"Connection should take at most 2 seconds"
Expand Down
Loading