Skip to content

Tracker Checker: Improve errors. More concrete errors #676

New issue

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

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

Already on GitHub? # to your account

Closed
Tracked by #669 ...
josecelano opened this issue Feb 2, 2024 · 1 comment
Closed
Tracked by #669 ...

Tracker Checker: Improve errors. More concrete errors #676

josecelano opened this issue Feb 2, 2024 · 1 comment
Assignees
Labels
- Admin - Enjoyable to Install and Setup our Software - Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat Easy Good for Newcomers Enhancement / Feature Request Something New good first issue Good for newcomers Low Priority Not our Focus Now Testing Checking Torrust
Milestone

Comments

@josecelano
Copy link
Member

josecelano commented Feb 2, 2024

Parent issue: #669
Relates to:

Currently, you can run the Tracker Checker with this input:

TORRUST_CHECKER_CONFIG='{
    "udp_trackers": ["144.126.245.19:6969"],
    "http_trackers": ["https://tracker.torrust-demo.com"],
    "health_checks": ["https://tracker.torrust-demo.com/health_check"]
}' cargo run --bin tracker_checker

When something is wrong you only get three types of errors or the application panics.

For example:

TORRUST_CHECKER_CONFIG='{
    "udp_trackers": [],
    "http_trackers": [],
    "health_checks": ["https://localhost:1515"]
}' cargo run --bin tracker_checker

Output:

Running checks for trackers ...
UDP trackers ...
HTTP trackers ...
Health checks ...
✗ - Health API at https://localhost:1515/ is failing: reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("localhost")), port: Some(1515), path: "/", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })) }

Errors are defined with this enum:

#[derive(Debug)]
pub enum CheckError {
    UdpError { socket_addr: SocketAddr },
    HttpError { url: Url },
    HealthCheckError { url: Url },
}

But depending on the service there could be different reasons. For example:

For the Health Check:

  • The connection can be refused.
  • The response status code could not be 200.
  • Etcetera.

For the UDP tracker:

  • You could not bind the client to a local port.
  • You could not send a packet to the remote server.
  • Etcetera.

We should introduce a second level of types for errors. For example:

#[derive(Debug)]
pub enum CheckError {
    Udp { error: UdpError },
    Http { error: HttpError },
    HealthCheck { error: HealthCheckError },
}

#[derive(Debug)]
pub enum HealthCheckError {
    ConnectionRefused { url: Url },
    NotOkResponse { url: Url, status: StatusCode },
    HealthCheck { error: HealthCheckError },
}

// ...

This issue should be implemented after implementing other issues related to timeout errors. Because those issues might introduce new errors.

@josecelano josecelano added Enhancement / Feature Request Something New Easy Good for Newcomers Code Cleanup / Refactoring Tidying and Making Neat - Developer - Torrust Improvement Experience - Admin - Enjoyable to Install and Setup our Software Low Priority Not our Focus Now Testing Checking Torrust good first issue Good for newcomers labels Feb 2, 2024
@josecelano josecelano added this to the v3.1.0 milestone Feb 2, 2024
@josecelano josecelano mentioned this issue Feb 2, 2024
22 tasks
@da2ce7 da2ce7 self-assigned this Mar 28, 2024
@josecelano
Copy link
Member Author

josecelano commented Sep 11, 2024

Implemented by @da2ce7. I guess in c202db7.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
- Admin - Enjoyable to Install and Setup our Software - Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat Easy Good for Newcomers Enhancement / Feature Request Something New good first issue Good for newcomers Low Priority Not our Focus Now Testing Checking Torrust
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants