Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: improve deployer 404 messages #796

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ echo "api_key = '<jwt>'" > ~/.config/shuttle/config.toml
> Note: The JWT will expire in 15 minutes, at which point you need to run the commands again.
> If you have [`jq`](https://github.com/stedolan/jq/wiki/Installation) installed you can combine
> the two above commands into the following:
> ```bash
> curl -s -H "Authorization: Bearer test-key" localhost:8008/auth/key \
> | jq -r '.token' \
> | read token; echo "api_key='$token'" > ~/.config/shuttle/config.toml
> ```
```bash
curl -s -H "Authorization: Bearer test-key" localhost:8008/auth/key \
| jq -r '.token' \
| read token; echo "api_key='$token'" > ~/.config/shuttle/config.toml
```

Finally we need to comment out the admin layer in the deployer handlers. So in `deployer/handlers/mod.rs`,
in the `make_router` function comment out this line: `.layer(AdminSecretLayer::new(admin_secret))`.
Expand Down
6 changes: 3 additions & 3 deletions deployer/src/handlers/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub enum Error {
to: String,
message: String,
},
#[error("record could not be found")]
NotFound,
#[error("{0}, try running `cargo shuttle deploy`")]
NotFound(String),
#[error("Custom error: {0}")]
Custom(#[from] anyhow::Error),
}
Expand All @@ -44,7 +44,7 @@ impl IntoResponse for Error {
error!(error = &self as &dyn std::error::Error, "request error");

let code = match self {
Error::NotFound => StatusCode::NOT_FOUND,
Error::NotFound(_) => StatusCode::NOT_FOUND,
_ => StatusCode::INTERNAL_SERVER_ERROR,
};

Expand Down
18 changes: 9 additions & 9 deletions deployer/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async fn get_service(

Ok(Json(response))
} else {
Err(Error::NotFound)
Err(Error::NotFound("service not found".to_string()))
}
}

Expand All @@ -166,7 +166,7 @@ async fn get_service_resources(

Ok(Json(resources))
} else {
Err(Error::NotFound)
Err(Error::NotFound("service not found".to_string()))
}
}

Expand Down Expand Up @@ -229,7 +229,7 @@ async fn stop_service(
if let Some(ref deployment) = running_deployment {
deployment_manager.kill(deployment.id).await;
} else {
return Err(Error::NotFound);
return Err(Error::NotFound("no running deployment found".to_string()));
}

let response = shuttle_common::models::service::Summary {
Expand All @@ -240,7 +240,7 @@ async fn stop_service(

Ok(Json(response))
} else {
Err(Error::NotFound)
Err(Error::NotFound("service not found".to_string()))
}
}

Expand All @@ -259,7 +259,7 @@ async fn get_deployments(

Ok(Json(deployments))
} else {
Err(Error::NotFound)
Err(Error::NotFound("service not found".to_string()))
}
}

Expand All @@ -271,7 +271,7 @@ async fn get_deployment(
if let Some(deployment) = persistence.get_deployment(&deployment_id).await? {
Ok(Json(deployment.into()))
} else {
Err(Error::NotFound)
Err(Error::NotFound("deployment not found".to_string()))
}
}

Expand All @@ -286,7 +286,7 @@ async fn delete_deployment(

Ok(Json(deployment.into()))
} else {
Err(Error::NotFound)
Err(Error::NotFound("deployment not found".to_string()))
}
}

Expand All @@ -305,7 +305,7 @@ async fn get_logs(
.collect(),
))
} else {
Err(Error::NotFound)
Err(Error::NotFound("deployment not found".to_string()))
}
}

Expand Down Expand Up @@ -385,7 +385,7 @@ async fn get_secrets(

Ok(Json(keys))
} else {
Err(Error::NotFound)
Err(Error::NotFound("service not found".to_string()))
}
}

Expand Down