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

Display the correct failing host on worker boot #5352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

josegomezr
Copy link
Contributor

When a worker cannot establish a websocket connection the log line reports the URL of the REST API, and not the websocket endpoint where the connection failed.

Old output:

[info] Registering with openQA 127.0.0.1:9526
[info] Establishing ws connection via ws://127.0.0.1:9526/api/v1/ws/1
[warn] Unable to upgrade to ws connection via http://127.0.0.1:9526/api/v1/ws/1 - trying again in 10 seconds

New output:

[info] Registering with openQA 127.0.0.1:9526
[info] Establishing ws connection via ws://127.0.0.1:9526/api/v1/ws/1
[warn] Unable to upgrade to ws connection via http://127.0.0.1:9526/api/v1/ws/1, Connection refused in http://localhost:9527/ws/1 - trying again in 10 seconds

Notice the addition of the network error & the final request url where the failre happened.

When a worker cannot establish a websocket connection the log line
reports the URL of the REST API, and not the websocket endpoint
where the connection failed.
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.31%. Comparing base (f8f5bc4) to head (cc479f6).
Report is 1334 commits behind head on master.

Files with missing lines Patch % Lines
lib/OpenQA/Worker/WebUIConnection.pm 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5352      +/-   ##
==========================================
- Coverage   98.32%   98.31%   -0.01%     
==========================================
  Files         389      389              
  Lines       37319    37321       +2     
==========================================
  Hits        36693    36693              
- Misses        626      628       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@okurz
Copy link
Member

okurz commented Oct 28, 2023

So the next learning opportunity for you: Extend the tests to make the coverage check https://github.com/os-autoinst/openQA/pull/5352/checks?check_run_id=18141921282 happy :)

@josegomezr
Copy link
Contributor Author

So the next learning opportunity for you: Extend the tests to make the coverage check https://github.com/os-autoinst/openQA/pull/5352/checks?check_run_id=18141921282 happy :)

I tried but got stuck on getting connection refused and not the problem at hand 😅

@@ -157,6 +157,11 @@ sub _setup_websocket_connection ($self, $websocket_url = undef) {

my $error = $tx->error;
my $error_message = "Unable to upgrade to ws connection via $websocket_url";

if ($tx->res->error && $tx->res->error->{message}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the post-if to be consistent with other lines

Comment on lines +161 to 165
if ($tx->res->error && $tx->res->error->{message}) {
$error_message .= sprintf(", %s in %s", $tx->res->error->{message}, $tx->req->url);
}

$error_message .= ", code $error->{code}" if ($error && $error->{code});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use $error for simplicity and there should always be a message:

Suggested change
if ($tx->res->error && $tx->res->error->{message}) {
$error_message .= sprintf(", %s in %s", $tx->res->error->{message}, $tx->req->url);
}
$error_message .= ", code $error->{code}" if ($error && $error->{code});
if ($error) {
$error_message .= ", $error->{message}";
$error_message .= ", code $error->{code}" if $error->{code};
}

I have also removed the URL because it is already part of the error message and I would just change that other part. However, if you disagree and want the original URL still being logged that's fine as well.

@@ -157,6 +157,11 @@ sub _setup_websocket_connection ($self, $websocket_url = undef) {

my $error = $tx->error;
my $error_message = "Unable to upgrade to ws connection via $websocket_url";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just alter the URL here:

Suggested change
my $error_message = "Unable to upgrade to ws connection via $websocket_url";
my $error_message = 'Unable to upgrade to ws connection via ' . $tx->req->url;

The original URL is still logged in the "Establishing …" line so there's nothing lost in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants