summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-11-15 11:45:13 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-11-15 11:46:32 +0100
commite703284a2afa1ff9b9115e8101b462a5f1accd2a (patch)
tree9343b93eebdeafbc1643104535d9bedd835f694f /src
parent771f957d4202bfa15820dc004b9cb874a32b7746 (diff)
Add URI reporting
This patch adds the URI to the container error error-message. The URI is required, of course, to connect to the remote docker container if there was an error. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/endpoint/configured.rs7
-rw-r--r--src/endpoint/error.rs13
2 files changed, 14 insertions, 6 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index cb57ea8..2dadb0d 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -38,6 +38,9 @@ pub struct Endpoint {
#[getset(get_copy = "pub")]
num_max_jobs: usize,
+
+ #[getset(get = "pub")]
+ uri: String,
}
impl Debug for Endpoint {
@@ -79,6 +82,7 @@ impl Endpoint {
.map(|docker| {
Endpoint::builder()
.name(ep.name().clone())
+ .uri(ep.uri().clone())
.docker(docker)
.speed(ep.speed())
.num_max_jobs(ep.maxjobs())
@@ -90,6 +94,7 @@ impl Endpoint {
Ok({
Endpoint::builder()
.name(ep.name().clone())
+ .uri(ep.uri().clone())
.speed(ep.speed())
.num_max_jobs(ep.maxjobs())
.docker(shiplift::Docker::unix(ep.uri()))
@@ -352,7 +357,7 @@ impl Endpoint {
let script: Script = job.script().clone();
match exited_successfully {
- Some(false) => Err(ContainerError::container_error(ContainerHash::from(container_id))),
+ Some(false) => Err(ContainerError::container_error(ContainerHash::from(container_id), self.uri().clone())),
Some(true) | None => {
container.stop(Some(std::time::Duration::new(1, 0)))
.await
diff --git a/src/endpoint/error.rs b/src/endpoint/error.rs
index a6a6d7b..e04ee51 100644
--- a/src/endpoint/error.rs
+++ b/src/endpoint/error.rs
@@ -9,6 +9,7 @@ pub enum ContainerError {
#[error("Error during container run: {container_id}")]
ContainerError {
container_id: ContainerHash,
+ uri: String,
},
#[error("{0}")]
@@ -16,21 +17,23 @@ pub enum ContainerError {
}
impl ContainerError {
- pub fn container_error(container_id: ContainerHash) -> Self {
- ContainerError::ContainerError { container_id }
+ pub fn container_error(container_id: ContainerHash, uri: String) -> Self {
+ ContainerError::ContainerError { container_id, uri }
}
pub fn explain_container_error(&self) -> Option<String> {
match self {
- ContainerError::ContainerError { container_id } => Some({
+ ContainerError::ContainerError { container_id, uri } => Some({
indoc::formatdoc!(r#"
Container did not exit successfully: {container_id}
+ It was not stopped because of this.
+
Use
- docker exec -it {container_id} /bin/bash
+ docker --host {uri} exec -it {container_id} /bin/bash
to access and debug.
- "#, container_id = container_id)
+ "#, uri = uri, container_id = container_id)
}),
_ => None,
}