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

Add service_port_delta config for livehandler #5435

Merged

Conversation

deborahbrouwer
Copy link
Contributor

Instead of hard-coding the service port delta for the livehandler, make the service port delta configurable while still defaulting to the expected value of 2. This allows cloud and/or containerized setups to access the web UI through a non-standard port while continuing to access the livehandler through a reverse proxy just by setting the service port delta to 0.

Issue: https://progress.opensuse.org/issues/153499

Copy link
Contributor

@Martchus Martchus left a comment

Choose a reason for hiding this comment

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

The change looks generally good but I think having to specify the port in the worker config should be avoided (as explained in an inline comment).

## For the developer mode panel: if not accessing the web UI via Apache/NGINX reverse
## proxy, then connect to the livehandler daemon at the <web UI port> + service_port_delta.
## The livehandler daemon is supposed to run under the <web UI port> + 2.
## If you want to keep using a reverse proxy while accessing the webUI through a custom port
Copy link
Contributor

Choose a reason for hiding this comment

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

For the sake of consistency:

Suggested change
## If you want to keep using a reverse proxy while accessing the webUI through a custom port
## If you want to keep using a reverse proxy while accessing the web UI through a custom port

## proxy, then connect to the livehandler daemon at the <web UI port> + service_port_delta.
## The livehandler daemon is supposed to run under the <web UI port> + 2.
## If you want to keep using a reverse proxy while accessing the webUI through a custom port
## (e.g. 8080) then just set the service_port_delta = 0.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## (e.g. 8080) then just set the service_port_delta = 0.
## (e.g. 8080) then just set `service_port_delta` to 0.
Suggested change
## (e.g. 8080) then just set the service_port_delta = 0.
## (e.g. 8080) then just set `service_port_delta = 0`.

@@ -964,9 +964,11 @@ sub post_upload_progress_to_liveviewhandler {
$self->{_progress_info} = \%new_progress_info;

my $job_id = $self->id;
my $global_settings = OpenQA::Worker::Settings->new->global_settings;
Copy link
Contributor

Choose a reason for hiding this comment

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

When I remember correctly, this would parse the INI file again. It would be more efficient to re-use the existing settings object:

Suggested change
my $global_settings = OpenQA::Worker::Settings->new->global_settings;
my $global_settings = $self->worker->settings->global_settings;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even better, we don't have to retrieve the worker settings at all once the web UI is telling the worker what the service port config is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Depends on where the worker will store that port. Probably you'd add another attribute on worker level for this so the code accessing it would become $self->worker->service_port_delta.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've add it as a attribute pretty much exactly the same as the worker_id that is also received from the web Ui when it registers a worker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Patch is coming as soon as i think it has a chance of passing the CI tests

Copy link
Member

Choose a reason for hiding this comment

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

About CI failures: The javascript style issues should be fixed when you rebase your branch onto current master where a fix was applied. The other test failures are certainly related, e.g.

    #   Failed test '"test" configuration'
    #   at t/config.t line 184.
    #     Structures begin differing at:
    #          $got->{global}{service_port_delta} = '2'
    #     $expected->{global}{service_port_delta} = Does not exist

Comment on lines 76 to 78
# Config for livehandler port; see service_port_delta in openqa.ini.
# SERVICE_PORT_DELTA = 2

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if that wasn't necessary. The web UI could tell the worker when the worker registers what the service port is. This way one would only have to configure this in one place and no mismatch was possible.

Copy link
Member

Choose a reason for hiding this comment

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

Could we put it in the JSON? Not sure if there's a better way to communicate state 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

That's what I meant. When the worker registers the JSON reply would contain the service port. (We still need a fallback to 2 so new workers still work when registering on an old web UI.)

Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

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

Hi @deborahbrouwer, welcome to this project 💯 🎆 🥳 and thank you for your contribution. Same as Martchus I agree that this change can be helpful just needs "CI fixes" and the part about not needing the port delta stated explicitly in each and every worker config when the webUI can communicate what it needs to the worker.

@Martchus
Copy link
Contributor

Martchus commented Jan 31, 2024

And please rebase against the latest master branch because otherwise the JavaScript test will keep failing. (It was only fixed recently.)
You probably also have to run make tidy locally for it to pass (but commit your changes before in case something goes wrong).

@deborahbrouwer deborahbrouwer force-pushed the developer-mode-service-port branch 2 times, most recently from 94403b2 to 20842c7 Compare February 1, 2024 17:31
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (34cd7cf) 98.37% compared to head (07543d2) 98.37%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5435   +/-   ##
=======================================
  Coverage   98.37%   98.37%           
=======================================
  Files         389      389           
  Lines       37744    37751    +7     
=======================================
+ Hits        37132    37139    +7     
  Misses        612      612           

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

Copy link
Contributor

@Martchus Martchus left a comment

Choose a reason for hiding this comment

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

Looks very good; I only have minor nitpicks (see inline comments).

lib/OpenQA/Worker/WebUIConnection.pm Outdated Show resolved Hide resolved
assets/javascripts/running.js Outdated Show resolved Hide resolved
Instead of hard-coding the service port delta for the livehandler, make
the service port delta configurable while still defaulting to the expected
value of 2. This allows cloud and/or containerized setups to access the
web UI through a non-standard port while continuing to access the
livehandler through a reverse proxy just by setting the service port
delta to 0.

Issue: https://progress.opensuse.org/issues/153499
Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

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

Very nice. This looks great!

EDIT: I approved the CI run. As soon as all checks pass then mergify will automatically merge this PR.

@mergify mergify bot merged commit 0d50a81 into os-autoinst:master Feb 2, 2024
41 checks passed
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.

4 participants