Skip to content

Add connection status always online - #3373

Open
samuelwei wants to merge 13 commits into
developfrom
add-connection_status_always_online
Open

Add connection status always online#3373
samuelwei wants to merge 13 commits into
developfrom
add-connection_status_always_online

Conversation

@samuelwei

@samuelwei samuelwei commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3317

Type

  • Bugfix
  • Feature
  • Documentation
  • Refactoring (e.g. Style updates, Test implementation, etc.)
  • Other (please describe):

Checklist

  • Code updated to current develop branch head
  • Passes CI checks
  • Is a part of an issue
  • Tests added for the bugfix or newly implemented feature, describe below why if not
  • Changelog is updated
  • Documentation of code and features exists

Changes

  • Added option to set connection status of servers to always online
  • (Internal) Rename server health to server connection status
  • Prometheus metric label pilos_servers_total{status="unhealthy"} to pilos_servers_total{status="faulty"}
  • Connection status terminology in log messages (unhealthy to faulty; healthy to online; old_health to old_connection_status)

Summary by CodeRabbit

  • New Features
    • Added an option to keep servers appearing online and available for new meetings despite connection issues.
    • Server details and APIs now report Online, Offline, or Faulty connection statuses.
  • Improvements
    • Updated administration screens, metrics, dashboards, and translations with connection-status terminology.
    • Improved server failure, recovery, offline handling, and load balancing.
  • Documentation
    • Updated the unreleased changelog with connection-status changes and issue references.

Copilot AI review requested due to automatic review settings August 3, 2026 13:03
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The server health model is renamed to connection status, with FAULTY and OFFLINE states. A configurable always-online option is added across storage, APIs, runtime handling, administration UI, metrics, translations, and automated tests.

Changes

Server connection status

Layer / File(s) Summary
Status contracts and API wiring
app/Enums/*, app/Models/Server.php, app/Http/..., database/...
The server enum, model methods, API validation, resource fields, migration, factory, and create/update flows now use connection-status terminology and support connection_status_always_online.
Runtime status processing
app/Services/*, app/Observers/*, app/Prometheus/..., docs/static/..., CHANGELOG.md
Runtime handling skips status updates for always-online servers. Transition logging, Prometheus labels, dashboard queries, and changelog terminology use offline, faulty, and online status names.
Administration status controls
resources/js/views/*, lang/en/admin.php
The administration views expose connection status and add the always-online server toggle with its translations and state synchronization.
Backend status and configuration coverage
tests/Backend/...
Backend tests validate status transitions, API fields, always-online behavior, polling, meeting detachment, server pools, room failures, and metrics.
Frontend status and form coverage
tests/Frontend/...
Cypress tests and fixtures use connection-status fields and cover the always-online control, payloads, validation, reloads, server actions, pagination, and status displays.

Estimated code review effort: 4 (Complex) | ~45 minutes

Mergeability Score: 🔵 Low · up to f35b6

This change adds an always-online server connection option and renames connection-status terminology across the product. Merge-readiness risk is low and limited to type annotations and pagination test metadata consistency; it is mergeable with owner awareness and normal checks.

Suggested labels: UI

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes an unrelated ServerPool docblock typo fix that is not required by issue [#3317]. Remove the unrelated ServerPool docblock change, or explain why it is required for this feature.
Docstring Coverage ⚠️ Warning Docstring coverage is 48.65% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main feature: configuring a server connection status as always online.
Description check ✅ Passed The description includes the issue, feature type, completed checklist, and four bullets that summarize the implementation.
Linked Issues check ✅ Passed The implementation adds the always-online option and keeps configured servers eligible despite health counters while preserving default behavior [#3317].
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-connection_status_always_online

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.87879% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.04%. Comparing base (2fbae3a) to head (54a0871).
⚠️ Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
resources/js/views/AdminServersView.vue 85.18% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             develop    #3373       +/-   ##
==============================================
- Coverage      97.03%   85.04%   -11.99%     
==============================================
  Files            486      198      -288     
  Lines          16779     9963     -6816     
  Branches        2444     2449        +5     
==============================================
- Hits           16281     8473     -7808     
- Misses           498     1490      +992     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new connection_status_always_online flag for BBB servers and renames the existing “health” concept to “connection status” (ONLINE / FAULTY / OFFLINE) across backend, frontend, API resources, metrics, and tests.

Changes:

  • Add servers.connection_status_always_online (DB + factory + API validation + resource serialization) and expose it in the admin UI.
  • Rename healthconnection_status and unhealthyfaulty across Vue views, Cypress tests, backend tests, and Prometheus/Grafana.
  • Update server status calculation/accessors and operational behavior so counters aren’t updated when “always online” is enabled.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Frontend/fixtures/servers.json Update fixtures to include connection_status_always_online and rename healthconnection_status.
tests/Frontend/fixtures/server.json Update single-server fixture for new/renamed fields.
tests/Frontend/e2e/AdminServersViewServerActions.cy.js Update selectors and fixture fields for renamed connection status UI/response fields.
tests/Frontend/e2e/AdminServersView.cy.js Update assertions/selectors for connectionStatus and “faulty”.
tests/Frontend/e2e/AdminServersNew.cy.js Update create-flow expectations to include connection_status_always_online.
tests/Frontend/e2e/AdminServersIndex.cy.js Update index-page status label expectation to “faulty”.
tests/Frontend/e2e/AdminServersEdit.cy.js Update edit-page selectors for connection status input id.
tests/Backend/Unit/ServerTest.php Rename health tests to connection status and add “always online” behavior test.
tests/Backend/Unit/ServerServiceTest.php Update service tests for new enum/status naming and add always-online counter behavior tests.
tests/Backend/Unit/ServerPoolTest.php Rename unhealthy variable → faulty in pool balancing test.
tests/Backend/Unit/Console/PollServerTest.php Update poll-server test expectations to FAULTY/OFFLINE connection status.
tests/Backend/Feature/MetricsTest.php Update metrics expectations for faulty label.
tests/Backend/Feature/api/v1/ServerTest.php Update API contract expectations (fields + enum values) and validation to include connection_status_always_online.
tests/Backend/Feature/api/v1/Room/RoomTest.php Update room tests to assert connection status enum usage.
resources/js/views/AdminServersView.vue Add “always online” toggle and rename health UI/logic to connection status.
resources/js/views/AdminServersIndex.vue Update server list UI to read connection_status and label FAULTY.
lang/en/admin.php Add new translation keys and rename “unhealthy” → “faulty” (EN only).
docs/static/grafana-dashboard.json Update Grafana queries/labels from unhealthyfaulty.
database/migrations/migrate-to-v4/2024_03_06_152142_add_health_counters_to_servers_table.php Update migration comments/naming around status → connection status counters.
database/migrations/2026_07_17_000000_add_health_check_enabled_to_servers_table.php Add connection_status_always_online column (migration name currently mismatched to purpose).
database/factories/ServerFactory.php Add default connection_status_always_online: false.
app/Services/ServerService.php Skip counter updates when always-online is enabled; rename health checks to connection status.
app/Prometheus/Collectors/ServerCollector.php Rename metric label from unhealthyfaulty.
app/Observers/ServerObserver.php Rename logging/transition detection from health → connection status.
app/Models/Server.php Add boolean cast + connection_status accessor + calculateConnectionStatus helper; force ONLINE when always-online enabled.
app/Http/Resources/ServerResource.php Expose connection_status_always_online and connection_status in API responses.
app/Http/Requests/ServerRequest.php Validate connection_status_always_online as required boolean.
app/Http/Controllers/api/v1/ServerController.php Persist always-online flag and skip initial usage check when enabled.
app/Enums/ServerStatus.php Remove incorrect enum docblock.
app/Enums/ServerConnectionStatus.php Rename enum and values (UNHEALTHY → FAULTY).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Backend/Unit/ServerTest.php Outdated
Comment thread lang/en/admin.php
Comment thread resources/js/views/AdminServersView.vue
Copilot AI review requested due to automatic review settings August 3, 2026 13:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

Suppressed comments (9)

database/migrations/2026_07_17_000000_add_health_check_enabled_to_servers_table.php:18

  • Migration filename suggests it adds a health_check_enabled column, but it actually adds connection_status_always_online. This mismatch makes it harder to track schema history and can confuse future migrations.
        Schema::table('servers', function (Blueprint $table) {
            $table->boolean('connection_status_always_online')->default(false)->after('strength');
        });

database/migrations/migrate-to-v4/2024_03_06_152142_add_health_counters_to_servers_table.php:43

  • The comment in the "Online" branch says "Server is faulty", but the code sets recover_count to the online threshold (which makes the server evaluate to ONLINE). This is misleading when reading the migration.
                case 1:
                    // Server is faulty
                    $server->recover_count = config('bigbluebutton.server_online_threshold');
                    $server->error_count = 0;
                    $server->status = ServerStatus::ENABLED;

tests/Frontend/e2e/AdminServersView.cy.js:313

  • Disabled servers return connection_status: null, so the UI should display admin.servers.unknown here (not admin.servers.faulty).
        cy.get("#connectionStatus")
          .should("have.value", "admin.servers.faulty")
          .and("be.disabled");

tests/Backend/Unit/ServerTest.php:82

  • Docblock says the connection status returns null when connection_status_always_online is true, but the test asserts it returns ONLINE. The comment should match the actual behavior under test.
    /**
     * Test that connection status returns null when connection_status_always_online is true
     */

app/Prometheus/Collectors/ServerCollector.php:33

  • Prometheus status metrics ignore connection_status_always_online. A server marked always-online can still be counted as faulty (and excluded from online) because the queries only look at counters, which makes metrics/dashboards inaccurate.
            ->set(Server::where('status', ServerStatus::ENABLED)
                ->where('recover_count', '>=', config('bigbluebutton.server_online_threshold'))
                ->count(), ['online'])
            ->set(Server::where('status', ServerStatus::ENABLED)
                ->where('error_count', '>=', config('bigbluebutton.server_offline_threshold'))
                ->count(), ['offline'])
            ->set(Server::where('status', ServerStatus::ENABLED)
                ->where('recover_count', '<', config('bigbluebutton.server_online_threshold'))
                ->where('error_count', '<', config('bigbluebutton.server_offline_threshold'))
                ->count(), ['faulty']);

app/Observers/ServerObserver.php:60

  • Connection-status-change logs are computed only from counters via Server::calculateConnectionStatus(), so they can disagree with the effective connection_status accessor (e.g. when connection_status_always_online is enabled or when the server is disabled). This can produce misleading "changed to offline/faulty/online" log entries.
        // Check if server connection status changed
        $newConnectionStatus = Server::calculateConnectionStatus($server->recover_count, $server->error_count);
        $previousConnectionStatus = Server::calculateConnectionStatus($server->getOriginal('recover_count'), $server->getOriginal('error_count'));
        if ($newConnectionStatus != $previousConnectionStatus) {

tests/Frontend/e2e/AdminServersView.cy.js:273

  • For a disabled server, the API returns connection_status: null (see Server::getConnectionStatusAttribute()), but this test forces connection_status = 0, which doesn't reflect real responses.

This issue also appears on line 311 of the same file.

    cy.fixture("server.json").then((server) => {
      server.data.status = -1;
      server.data.connection_status = 0;

tests/Frontend/fixtures/servers.json:46

  • Fixture sets connection_status to -1 for a disabled server (status: -1). The backend Server::getConnectionStatusAttribute() returns null when disabled, so this fixture does not match real API responses and can make UI tests misleading.
    app/Http/Requests/ServerRequest.php:23
  • Making connection_status_always_online a required field turns this into a breaking API change for any existing clients that POST/PUT servers without that field (they will start failing validation). Consider making it optional with a default of false (and only updating the model value when the key is present).
            'secret' => ['required', 'string', 'max:255'],
            'strength' => ['required', 'integer', 'min:1', 'max:10'],
            'status' => ['required', Rule::enum(ServerStatus::class)],
            'connection_status_always_online' => ['required', 'boolean'],
        ];

@cypress

cypress Bot commented Aug 3, 2026

Copy link
Copy Markdown

PILOS    Run #3260

Run Properties:  status check failed Failed #3260  •  git commit 54a087178a: Add connection status always online
Project PILOS
Branch Review add-connection_status_always_online
Run status status check failed Failed #3260
Run duration 08m 00s
Commit git commit 54a087178a: Add connection status always online
Committer Samuel Weirich
View all properties for this run ↗︎

Test results
Tests that failed  Failures 5
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 633
View all changes introduced in this branch ↗︎

Tests for review

Failed  e2e/RoomsJoinWithLobby.cy.js • 1 failed test • System tests

View Output

Test Artifacts
Room Join with lobby settings > Lobby enabled Test Replay Screenshots
Failed  tests/Frontend/e2e/AdminServerPoolsNew.cy.js • 1 failed test • Frontend tests

View Output

Test Artifacts
Admin server pools new > add new server pool with 1 server Test Replay Screenshots
Failed  tests/Frontend/e2e/AdminServersIndexServerActions.cy.js • 3 failed tests • Frontend tests

View Output

Test Artifacts
Admin servers index server actions > delete server Test Replay Screenshots
Admin servers index server actions > delete server errors Test Replay Screenshots
Admin servers index server actions > reload servers Test Replay Screenshots

Copilot AI review requested due to automatic review settings August 3, 2026 13:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.

Suppressed comments (6)

lang/en/admin.php:226

  • New translation keys (servers.faulty, servers.connection_status_always_online, servers.connection_status_always_online_description) are added only to lang/en/admin.php. Other locales in this repo (e.g. lang/de/admin.php, lang/fr/admin.php, etc.) still have servers.unhealthy and do not define these new keys, which will cause missing translations for non-English users.
        'faulty' => 'Faulty',
        'flash' => [
            'panic' => [

tests/Backend/Unit/ServerTest.php:82

  • Docblock says the connection status returns null when connection_status_always_online is true, but the test asserts it is ONLINE. Update the comment to match the intended behavior.
    /**
     * Test that connection status returns null when connection_status_always_online is true
     */

database/migrations/migrate-to-v4/2024_03_06_152142_add_health_counters_to_servers_table.php:42

  • In the migration's case 1 (online), the comment says "Server is faulty" but the code sets recover_count to the online threshold and error_count to 0 (i.e. ONLINE). This comment is misleading.
                    // Online
                case 1:
                    // Server is faulty
                    $server->recover_count = config('bigbluebutton.server_online_threshold');
                    $server->error_count = 0;

database/migrations/2026_07_17_000000_add_health_check_enabled_to_servers_table.php:18

  • Migration filename (add_health_check_enabled_to_servers_table) does not match the actual column being added (connection_status_always_online). This makes it harder to understand schema history and locate migrations later.
        Schema::table('servers', function (Blueprint $table) {
            $table->boolean('connection_status_always_online')->default(false)->after('strength');
        });

app/Http/Requests/ServerRequest.php:22

  • Making connection_status_always_online required is a breaking API change for existing clients that POST/PUT servers without this new field. Since the DB default is false and the controller already uses $request->boolean(...) (which evaluates to false when missing), consider making this field optional in validation.
            'strength' => ['required', 'integer', 'min:1', 'max:10'],
            'status' => ['required', Rule::enum(ServerStatus::class)],
            'connection_status_always_online' => ['required', 'boolean'],
        ];

app/Prometheus/Collectors/ServerCollector.php:33

  • faulty (and the other status buckets) are derived only from counter thresholds. Servers with connection_status_always_online=true can still be counted as offline/faulty if their counters are stale, even though the model/UI treats them as ONLINE. Consider excluding connection_status_always_online servers from offline/faulty and including them in online to keep metrics consistent with the new feature.
            ->set(Server::where('status', ServerStatus::ENABLED)
                ->where('recover_count', '<', config('bigbluebutton.server_online_threshold'))
                ->where('error_count', '<', config('bigbluebutton.server_offline_threshold'))
                ->count(), ['faulty']);

Comment thread app/Services/ServerService.php Outdated
@samuelwei
samuelwei force-pushed the add-connection_status_always_online branch from a7b2fb9 to 420fce8 Compare August 3, 2026 14:35
Copilot AI review requested due to automatic review settings August 3, 2026 14:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

Suppressed comments (3)

lang/en/admin.php:256

  • The new connection_status_always_online labels/descriptions were added only in English. Other locales don’t define these keys yet, so non-English users will see missing translation fallbacks. Add these keys to the other lang/*/admin.php files.
        'strength_description' => 'Load balancing factor; the higher the factor, the more participants and meetings the server can handle',
        'connection_status_always_online' => 'Connection always online',
        'connection_status_always_online_description' => 'The server is always considered online and available for new meetings; connection issues are ignored',

lang/en/admin.php:225

  • New UI code now references admin.servers.faulty, but other locales still only define the older admin.servers.unhealthy key. This will cause missing translation fallbacks for non-English locales. Add the new 'faulty' key (and/or keep an alias 'unhealthy' => same value) in all other lang/*/admin.php files to keep i18n consistent.
        'enabled' => 'Enabled',
        'faulty' => 'Faulty',
        'flash' => [

app/Http/Requests/ServerRequest.php:23

  • connection_status_always_online is validated as required|boolean. The issue description suggests this flag should default to false when omitted; making it required forces all API clients to be updated in lockstep and is a backwards-incompatible change. Consider making the field optional with a default (e.g. boolean + default false), and for updates only change the value when the key is present to avoid unintentionally turning it off.
        $rules = [
            'name' => ['required', 'string', 'max:255', Rule::unique('servers', 'name')],
            'description' => ['nullable', 'string', 'max:255'],
            'base_url' => ['required', 'url', 'string', 'max:255', Rule::unique('servers', 'base_url')],
            'secret' => ['required', 'string', 'max:255'],
            'strength' => ['required', 'integer', 'min:1', 'max:10'],
            'status' => ['required', Rule::enum(ServerStatus::class)],
            'connection_status_always_online' => ['required', 'boolean'],
        ];

Copilot AI review requested due to automatic review settings August 3, 2026 14:47
@samuelwei
samuelwei force-pushed the add-connection_status_always_online branch from 420fce8 to 9d001ff Compare August 3, 2026 14:47
@samuelwei
samuelwei marked this pull request as ready for review August 3, 2026 14:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/Backend/Unit/ServerServiceTest.php (1)

260-348: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add explicit void return types to changed test methods.

The changed method declarations omit : void.

  • tests/Backend/Unit/ServerServiceTest.php#L260-L348: Add : void to the three connection-status test methods.
  • tests/Backend/Unit/ServerServiceTest.php#L720-L759: Add : void to both always-online test methods.
  • tests/Backend/Unit/ServerTest.php#L50-L50: Add : void to test_server_connection_status.

As per coding guidelines, **/*.php: “Use explicit return type declarations and type hints for all method parameters.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Backend/Unit/ServerServiceTest.php` around lines 260 - 348, Add
explicit : void return types to the three connection-status test methods in
tests/Backend/Unit/ServerServiceTest.php lines 260-348, the two always-online
test methods in tests/Backend/Unit/ServerServiceTest.php lines 720-759, and
test_server_connection_status in tests/Backend/Unit/ServerTest.php line 50; no
other behavior changes are needed.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Http/Requests/ServerRequest.php`:
- Line 22: The connection_status_always_online rule in ServerRequest must not
require the field during server updates; apply required validation only on
creation or make the field nullable while preserving its existing value when
omitted. In ServerResource, remove any external health response alias if
present, as no health alias should remain.

In `@app/Models/Server.php`:
- Around line 82-100: Honor connection_status_always_online in
Server::getConnectionStatusAttribute after the disabled-server check by
returning ONLINE before evaluating counters. In
app/Prometheus/Collectors/ServerCollector.php lines 24-33, count enabled
always-online servers as online and exclude them from the offline and faulty
queries.

In `@app/Services/ServerService.php`:
- Around line 110-112: Update the always-online handling in the server health
flow so it skips only health-counter updates, not the successful-call cleanup.
Remove or narrow the early return around the always-online guard while
preserving execution of endDetachedMeetings() and the DRAINING transition logic
for every successful call.

In `@tests/Frontend/e2e/AdminServersEdit.cy.js`:
- Line 465: Update the toggle interaction in the AdminServersEdit test to click
the nested input with id connection-status-always-online instead of the
connection-status-always-online-field container, then assert that the input is
checked.

---

Outside diff comments:
In `@tests/Backend/Unit/ServerServiceTest.php`:
- Around line 260-348: Add explicit : void return types to the three
connection-status test methods in tests/Backend/Unit/ServerServiceTest.php lines
260-348, the two always-online test methods in
tests/Backend/Unit/ServerServiceTest.php lines 720-759, and
test_server_connection_status in tests/Backend/Unit/ServerTest.php line 50; no
other behavior changes are needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a7757fde-f6d7-4617-8d8c-2ed6d73baf9a

📥 Commits

Reviewing files that changed from the base of the PR and between 40b6c27 and 9d001ff.

📒 Files selected for processing (31)
  • CHANGELOG.md
  • app/Enums/ServerConnectionStatus.php
  • app/Enums/ServerStatus.php
  • app/Http/Controllers/api/v1/ServerController.php
  • app/Http/Requests/ServerRequest.php
  • app/Http/Resources/ServerResource.php
  • app/Models/Server.php
  • app/Observers/ServerObserver.php
  • app/Prometheus/Collectors/ServerCollector.php
  • app/Services/ServerService.php
  • database/factories/ServerFactory.php
  • database/migrations/2026_07_17_000000_add_connection_status_always_online_to_servers_table.php
  • database/migrations/migrate-to-v4/2024_03_06_152142_add_health_counters_to_servers_table.php
  • docs/static/grafana-dashboard.json
  • lang/en/admin.php
  • resources/js/views/AdminServersIndex.vue
  • resources/js/views/AdminServersView.vue
  • tests/Backend/Feature/MetricsTest.php
  • tests/Backend/Feature/api/v1/Room/RoomTest.php
  • tests/Backend/Feature/api/v1/ServerTest.php
  • tests/Backend/Unit/Console/PollServerTest.php
  • tests/Backend/Unit/ServerPoolTest.php
  • tests/Backend/Unit/ServerServiceTest.php
  • tests/Backend/Unit/ServerTest.php
  • tests/Frontend/e2e/AdminServersEdit.cy.js
  • tests/Frontend/e2e/AdminServersIndex.cy.js
  • tests/Frontend/e2e/AdminServersNew.cy.js
  • tests/Frontend/e2e/AdminServersView.cy.js
  • tests/Frontend/e2e/AdminServersViewServerActions.cy.js
  • tests/Frontend/fixtures/server.json
  • tests/Frontend/fixtures/servers.json
💤 Files with no reviewable changes (1)
  • app/Enums/ServerStatus.php

Comment thread app/Http/Requests/ServerRequest.php
Comment thread app/Models/Server.php
Comment thread app/Services/ServerService.php Outdated
Comment thread tests/Frontend/e2e/AdminServersEdit.cy.js Outdated
@THM-Health THM-Health deleted a comment from cursor Bot Aug 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

Suppressed comments (4)

app/Http/Controllers/api/v1/ServerController.php:149

  • Same as in update(): when connection_status_always_online is true, skipping updateUsage() can leave load as null on create. Since load balancing requires a non-null load, a newly created always-online server may not be selected until a later successful poll (which defeats the purpose in single-endpoint deployments).
        // Check if server is online/offline and update usage data
        if (! $server->connection_status_always_online) {
            $serverService = new ServerService($server);
            $serverService->updateUsage();
        }

app/Models/Server.php:88

  • connection_status_always_online is intended to make a server considered online regardless of the health counters, but getConnectionStatusAttribute() currently ignores the flag and still derives the status solely from recover_count/error_count. This can leave an always-online server reported as FAULTY/OFFLINE (and potentially excluded by selection logic) if counters are low (e.g., seeded/factory data or manual DB changes).
    public function getConnectionStatusAttribute(): ?ServerConnectionStatus
    {
        if ($this->status == ServerStatus::DISABLED) {
            return null;
        }

        return self::calculateConnectionStatus($this->recover_count, $this->error_count);

app/Http/Controllers/api/v1/ServerController.php:119

  • When connection_status_always_online is enabled, this skips updateUsage(). The load column is nullable (default null) and load balancing currently filters servers with whereNotNull('load'), so an always-online server can remain ineligible immediately after enabling the flag (or after being offline) because load stays null.

This issue also appears on line 145 of the same file.

        // Check if server is online/offline and update usage data
        if (! $server->connection_status_always_online) {
            $serverService = new ServerService($server);
            $serverService->updateUsage();
        }

app/Prometheus/Collectors/ServerCollector.php:33

  • With the new connection_status_always_online flag, server status metrics should treat these servers as online and exclude them from offline/faulty counts. Currently the gauge queries are based purely on counters, so an always-online server could still be counted as offline/faulty if its counters don’t match the thresholds (e.g., right after enabling the flag or for imported data).
            ->set(Server::where('status', ServerStatus::ENABLED)
                ->where('recover_count', '<', config('bigbluebutton.server_online_threshold'))
                ->where('error_count', '<', config('bigbluebutton.server_offline_threshold'))
                ->count(), ['faulty']);

Copilot AI review requested due to automatic review settings August 3, 2026 15:19
@samuelwei
samuelwei force-pushed the add-connection_status_always_online branch from 9d001ff to 6171944 Compare August 3, 2026 15:19
@THM-Health THM-Health deleted a comment from cursor Bot Aug 3, 2026
@samuelwei
samuelwei force-pushed the add-connection_status_always_online branch from 6171944 to 4db8df5 Compare August 3, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

Suppressed comments (5)

app/Http/Controllers/api/v1/ServerController.php:149

  • Same issue in store(): when creating a server with connection_status_always_online=true, updateUsage() is skipped and load remains null, which prevents the server from ever being selected by load balancing (whereNotNull('load')). Set a non-null default load when always-online is enabled so the server stays eligible immediately after creation.
        // Check if server is online/offline and update usage data
        if (! $server->connection_status_always_online) {
            $serverService = new ServerService($server);
            $serverService->updateUsage();
        }

lang/en/admin.php:225

  • admin.servers.faulty is added here, but the other locale files under lang/*/admin.php still define admin.servers.unhealthy and don’t include a faulty key. That will cause missing-translation fallbacks (English or raw key) in non-English UIs.
        'enabled' => 'Enabled',
        'faulty' => 'Faulty',
        'flash' => [

app/Http/Requests/ServerRequest.php:23

  • connection_status_always_online is a newly added field but is validated as required|boolean, which will cause 422s for existing API clients (and any older frontend) that don’t send the field yet. Since the DB column has a default (false) and the controllers already use $request->boolean(...), this can safely be optional in validation to preserve backward compatibility.
            'base_url' => ['required', 'url', 'string', 'max:255', Rule::unique('servers', 'base_url')],
            'secret' => ['required', 'string', 'max:255'],
            'strength' => ['required', 'integer', 'min:1', 'max:10'],
            'status' => ['required', Rule::enum(ServerStatus::class)],
            'connection_status_always_online' => ['required', 'boolean'],
        ];

app/Http/Controllers/api/v1/ServerController.php:111

  • $request->boolean('connection_status_always_online') returns false when the field is missing. If the field becomes optional (to keep backwards compatibility), an older client doing an update could unintentionally reset an existing true value back to false. Only set the attribute when the request actually includes the key.
        $server->secret = $request->secret;
        $server->strength = $request->strength;
        $server->status = $request->status;
        $server->connection_status_always_online = $request->boolean('connection_status_always_online');

app/Http/Controllers/api/v1/ServerController.php:119

  • When connection_status_always_online is enabled you skip updateUsage(), but servers.load is nullable and load balancing explicitly filters out servers with load = null (see LoadBalancingService::getLowestUsageServer() using whereNotNull('load')). This means an always-online server can still be excluded from new meetings (e.g. right after creation, or after previously being offline and having load nulled). Initialize load to a non-null value when always-online is enabled.

This issue also appears on line 145 of the same file.

        // Check if server is online/offline and update usage data
        if (! $server->connection_status_always_online) {
            $serverService = new ServerService($server);
            $serverService->updateUsage();
        }

@samuelwei
samuelwei force-pushed the add-connection_status_always_online branch from 3338051 to 539b997 Compare August 4, 2026 16:10
@samuelwei
samuelwei force-pushed the add-connection_status_always_online branch from 539b997 to 42af7e4 Compare August 4, 2026 16:11
@samuelwei
samuelwei requested a review from Sabr1n4W August 4, 2026 16:11
@samuelwei samuelwei added this to the v4.x milestone Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Comment thread resources/js/views/AdminServersIndex.vue
Comment thread app/Http/Controllers/api/v1/ServerController.php Outdated
Comment thread app/Http/Controllers/api/v1/ServerController.php Outdated
Comment thread app/Models/Server.php

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
app/Services/LoadBalancingService.php (1)

16-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add explicit return types to the changed method declarations.

Use : self for LoadBalancingService::setServerPool(). Use : void for the changed PHPUnit test methods.

  • app/Services/LoadBalancingService.php#L16-L20: add : self to setServerPool().
  • tests/Backend/Unit/ServerPoolTest.php#L65-L66: add : void to test_load_balancing_always_online().
  • tests/Backend/Unit/ServerServiceTest.php#L260-L260: add : void to test_server_connection_status_failing().
  • tests/Backend/Unit/ServerServiceTest.php#L304-L304: add : void to test_server_connection_status_single_failure().
  • tests/Backend/Unit/ServerServiceTest.php#L348-L348: add : void to test_server_connection_status_recovering().
  • tests/Backend/Unit/ServerServiceTest.php#L501-L502: add : void to test_end_detached_meeting_on_online_with_connection_status_always_online().
  • tests/Backend/Unit/ServerServiceTest.php#L634-L635: add : void to test_server_draining_with_connection_status_always_online().
  • tests/Backend/Unit/ServerServiceTest.php#L783-L784: add : void to test_connection_status_always_online_on_api_failure().
  • tests/Backend/Unit/ServerServiceTest.php#L822-L823: add : void to test_connection_status_always_online_on_api_success().
  • tests/Backend/Unit/ServerTest.php#L50-L50: add : void to test_server_connection_status().

As per coding guidelines: "**/*.php: ... declare explicit return types and parameter type hints."

🤖 Prompt for AI Agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

In `@app/Services/LoadBalancingService.php` around lines 16 - 20, Declare explicit
return types on LoadBalancingService::setServerPool() using : self, and on the
specified PHPUnit test methods using : void:
ServerPoolTest::test_load_balancing_always_online(), the listed
ServerServiceTest methods, and ServerTest::test_server_connection_status().
Apply the changes at app/Services/LoadBalancingService.php lines 16-20;
tests/Backend/Unit/ServerPoolTest.php lines 65-66;
tests/Backend/Unit/ServerServiceTest.php lines 260, 304, 348, 501-502, 634-635,
783-784, and 822-823; and tests/Backend/Unit/ServerTest.php line 50.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

Inline comments:
In `@app/Services/LoadBalancingService.php`:
- Around line 28-37: Update ServerPool::servers() to document its return type as
BelongsToMany<Server, $this>, preserving the Server generic so callers such as
getLowestUsageServer(): ?Server retain the correct model type.

In `@tests/Frontend/fixtures/servers.json`:
- Around line 100-101: Update tests/Frontend/fixtures/servers.json lines 100-101
so meta.to is 5, matching the five records and total values. Update
tests/Frontend/e2e/AdminServersIndex.cy.js line 871 and the related setup at
line 835 so last_page and total are consistent before asserting five paginator
pages.

---

Nitpick comments:
In `@app/Services/LoadBalancingService.php`:
- Around line 16-20: Declare explicit return types on
LoadBalancingService::setServerPool() using : self, and on the specified PHPUnit
test methods using : void: ServerPoolTest::test_load_balancing_always_online(),
the listed ServerServiceTest methods, and
ServerTest::test_server_connection_status(). Apply the changes at
app/Services/LoadBalancingService.php lines 16-20;
tests/Backend/Unit/ServerPoolTest.php lines 65-66;
tests/Backend/Unit/ServerServiceTest.php lines 260, 304, 348, 501-502, 634-635,
783-784, and 822-823; and tests/Backend/Unit/ServerTest.php line 50.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d9ed99db-bde2-4e67-b0b9-a9ab5952236b

📥 Commits

Reviewing files that changed from the base of the PR and between 9d001ff and f35b62c.

📒 Files selected for processing (16)
  • CHANGELOG.md
  • app/Http/Controllers/api/v1/ServerController.php
  • app/Models/Server.php
  • app/Models/ServerPool.php
  • app/Services/LoadBalancingService.php
  • app/Services/ServerService.php
  • lang/en/admin.php
  • resources/js/views/AdminServersIndex.vue
  • resources/js/views/AdminServersView.vue
  • tests/Backend/Unit/ServerPoolTest.php
  • tests/Backend/Unit/ServerServiceTest.php
  • tests/Backend/Unit/ServerTest.php
  • tests/Frontend/e2e/AdminServersEdit.cy.js
  • tests/Frontend/e2e/AdminServersIndex.cy.js
  • tests/Frontend/e2e/AdminServersViewServerActions.cy.js
  • tests/Frontend/fixtures/servers.json
🚧 Files skipped from review as they are similar to previous changes (7)
  • CHANGELOG.md
  • tests/Frontend/e2e/AdminServersViewServerActions.cy.js
  • app/Services/ServerService.php
  • tests/Frontend/e2e/AdminServersEdit.cy.js
  • resources/js/views/AdminServersView.vue
  • lang/en/admin.php
  • app/Models/Server.php

Comment thread app/Services/LoadBalancingService.php
Comment thread tests/Frontend/fixtures/servers.json
@samuelwei
samuelwei requested a review from Sabr1n4W August 13, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow excluding servers from health checks

4 participants