Skip to content

PMM-15360: Gate OpenManager's service on the switch - #5852

Open
plebioda wants to merge 3 commits into
PMM-15360-om-switch-flagfrom
PMM-15360-om-service-gate
Open

PMM-15360: Gate OpenManager's service on the switch#5852
plebioda wants to merge 3 commits into
PMM-15360-om-switch-flagfrom
PMM-15360-om-service-gate

Conversation

@plebioda

@plebioda plebioda commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

What

Implements Enabled() bool on om.Service, so every /v1/om/* RPC and the scheduled topology collection refuse while OpenManager is off, via the same generic gRPC-service-enabled interceptor BackupService and the other preview features already use — no proto or per-method changes needed.

Adds IsAvailable(), a read against SEP's om_inventory app (the same call the scheduled collection already makes), and wires it into ChangeSettings so turning OpenManager on is refused unless the app is actually reachable — rather than accepting a setting that would do nothing. Turning it on also kicks an immediate topology collection so the page is not empty on first view.

Does not touch SEP's om_inventory app in any way — turning the switch off does not stop its periodic sweep. That's deferred to a follow-up.

Ticket: PMM-15360

Stacking

Second of three PRs for PMM-15360. Stacks on PMM-15326-om-backend (#5816, needs om.Service) and #5851 (needs Settings.OpenManager.Enabled) — both are merged in here since there's no single upstream branch with both yet, so this diff includes #5851's changes inline until that one merges. Only the last commit ("Gate OpenManager's service on the switch") is net-new here.

Feature build: N/A on its own, same reasoning as #5851 — the UI half that would make this visible lands in the sibling nav/page PR.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 13.88889% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.90%. Comparing base (9bac502) to head (a606a2d).

Files with missing lines Patch % Lines
managed/services/om/service.go 0.00% 24 Missing ⚠️
managed/services/om/sep_client.go 0.00% 22 Missing ⚠️
managed/services/server/server.go 45.45% 10 Missing and 2 partials ⚠️
managed/cmd/pmm-managed/main.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           PMM-15360-om-switch-flag    #5852      +/-   ##
============================================================
- Coverage                     46.94%   46.90%   -0.05%     
============================================================
  Files                           430      430              
  Lines                         45409    45478      +69     
============================================================
+ Hits                          21318    21331      +13     
- Misses                        22030    22084      +54     
- Partials                       2061     2063       +2     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@plebioda
plebioda force-pushed the PMM-15360-om-service-gate branch 2 times, most recently from 8a4d7f9 to ff8c156 Compare August 31, 2026 08:19
@plebioda
plebioda deleted the branch PMM-15360-om-switch-flag August 31, 2026 10:22
Base automatically changed from PMM-15326-om-backend to PMM-15299-open-manager August 31, 2026 10:22
@plebioda plebioda closed this Aug 31, 2026
@plebioda plebioda reopened this Aug 31, 2026
@plebioda
plebioda force-pushed the PMM-15360-om-service-gate branch 2 times, most recently from a7edb05 to 38d343d Compare August 31, 2026 10:38
@plebioda
plebioda changed the base branch from PMM-15299-open-manager to PMM-15360-om-switch-flag August 31, 2026 10:38
@plebioda
plebioda force-pushed the PMM-15360-om-service-gate branch from 38d343d to 2ec32ca Compare August 31, 2026 10:59
@plebioda
plebioda force-pushed the PMM-15360-om-service-gate branch from 2ec32ca to 2f0a73e Compare August 31, 2026 11:13
@plebioda

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The OM service now reports whether OpenManager is enabled and whether SEP Inventory is available. Scheduled collection skips disabled ticks. The server receives the OM service through Params, validates OpenManager settings, persists EnableOM, and triggers topology collection after a disabled-to-enabled transition. Startup constructs the OM service before creating the server and passes it through serverParams.

Merge Risk: 🔵 Low · up to 2f0a7

The change gates OpenManager RPCs and collection on the persisted switch, validates SEP before enabling, and starts an initial collection. It is mergeable with owner awareness because repeated updates can fail during temporary SEP unavailability, while configuration or initial collection failures may leave the switch enabled despite an error response; failure logging should also preserve structured error context.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: gating OpenManager service behavior on the OpenManager switch.
Description check ✅ Passed The description explains the implementation, validation behavior, immediate collection, deferred scope, ticket, stacked PRs, and feature-build status. It does not include the template's API documentat…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the implementation, validation behavior, immediate collection, deferred scope, ticket, stacked PRs, and feature-build status. It does not include the template's API documentation checkbox, but the description states that no proto or per-method changes were made, so this is non-critical.


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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 782889cc-c850-4ecb-bd31-b1430e5860f9

📥 Commits

Reviewing files that changed from the base of the PR and between be40598 and 2f0a73e.

📒 Files selected for processing (4)
  • managed/cmd/pmm-managed/main.go
  • managed/services/om/service.go
  • managed/services/server/deps.go
  • managed/services/server/server.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • percona/pmm-qa (manual)
  • percona/pmm (manual)

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread managed/services/server/server.go Outdated
Comment thread managed/services/server/server.go Outdated
Implements Enabled() bool on om.Service, so every /v1/om/* RPC and the
scheduled topology collection refuse while OpenManager is off, via the
same generic gRPC-service-enabled interceptor BackupService and the
other preview features already use -- no proto or per-method changes
needed.

Adds IsAvailable(), a read against SEP's om_inventory app (the same
call the scheduled collection already makes), and wires it into
ChangeSettings so turning OpenManager on is refused unless the app is
actually reachable -- rather than accepting a setting that would do
nothing. Turning it on also kicks an immediate topology collection
(extracted into its own method: golangci-lint's gocognit check flags
ChangeSettings once this is inlined alongside Advisors' and
telemetry's own transition handling).

The generated swagger client's field names are OMEnabled/EnableOM here
(not OmEnabled/EnableOm, as in the settings-flag commit this stacks
on): this branch's api/Makefile, via PMM-15326-om-api already merged
into PMM-15326-om-backend, registers "om" as an additional-initialism
for the swagger client generator. That commit hasn't reached the epic
yet, so the settings-flag PR's own branch (based on the epic directly)
correctly generates the un-capitalized form; this is the make gen
output for this branch specifically.

Does not touch SEP's om_inventory app in any way -- turning the switch
off does not stop its periodic sweep. That's deferred to a follow-up.

Signed-off-by: Pawel Lebioda <pawel.lebioda@percona.com>
@plebioda
plebioda force-pushed the PMM-15360-om-service-gate branch from 2f0a73e to bdf0a85 Compare August 31, 2026 12:57
@plebioda
plebioda marked this pull request as ready for review August 31, 2026 13:31
@plebioda
plebioda requested a review from a team as a code owner August 31, 2026 13:31
@plebioda
plebioda requested review from JiriCtvrtka and ademidoff and removed request for a team August 31, 2026 13:31
ChangeSettings now tells SEP whether OpenManager is on, on either
transition of the switch: patchConfig and triggerRun are two small
additions to sep_client.go's existing (previously read-only) client,
and Service.SyncInventoryEnabled uses them to PATCH the app's ENABLED
field and, on enabling, kick an immediate sweep rather than leaving
the estate to wait out SCHEDULE's own interval.

ENABLED rather than SCHEDULE, because the app's own configured
cadence is an operator setting independent of whether OpenManager is
turned on; PATCHing SCHEDULE here would silently overwrite a
customized interval every time the switch is toggled off and back on.
See OmInventorySettings in SEP (PMM-15326) for the other half.

Both calls are best-effort, matching the existing
triggerOMCollectionIfJustEnabled: a stale write or a sweep that does
not fire means SEP is briefly out of step with the switch, not a
broken settings change, so failure is logged rather than returned to
the caller.

No new permission needed on SEP's side: its existing --sep-token
credential already clears the admin gate on the endpoints this uses,
by identity, the same way scheduled inventory sync and scheduled
execution already do.

Verified end-to-end against a live dev stack through the real
PUT /v1/server/settings API: disabling/enabling OpenManager there
flips SEP's ENABLED accordingly, a custom SCHEDULE survives the round
trip untouched, and an immediate sweep fires on enabling instead of
waiting out SCHEDULE's own interval.

Signed-off-by: Pawel Lebioda <pawel.lebioda@percona.com>
if s.probe == nil || s.probe.app.client == nil {
return
}
if err := s.probe.app.patchConfig(ctx, map[string]any{"ENABLED": enabled}); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
avoid inline error handling using if err := ...; err != nil; use plain assignment err := ... (noinlineerr)

if !enabled {
return
}
if err := s.probe.app.triggerRun(ctx); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚫 [golangci] reported by reviewdog 🐶
avoid inline error handling using if err := ...; err != nil; use plain assignment err := ... (noinlineerr)

@plebioda

plebioda commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

The failing Unit tests job isn't caused by this commit - managed/services/server's TestFiles fails on a postgresql14.log vs postgresql.log mismatch, unrelated to anything this PR touches (managed/services/om, managed/services/server/deps.go/server.go wiring to SEP).

Evidence it's environmental, not this diff:

  • The prior commit on this branch (bdf0a854) passed CI cleanly yesterday with the identical test file.
  • Re-running the job just now reproduces the exact same failure - not flaky/transient.
  • A completely unrelated PR (PMM-15191 Reject a Change*Agent request for the wrong agent type before it commits. #5703, PMM-15191-admin-change-error) failed its own Managed unit-test job around the same time today, with a different test (TestProgramRunningStatuses).

Looks like the shared CI base image (ghcr.io/percona/pmm:3-dev-container) changed its bundled PostgreSQL log naming sometime between yesterday and today, breaking TestFiles for anyone building against it right now. Leaving this failing rather than patching around it - flagging for whoever owns the image/test.

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.

2 participants