Skip to content

PMM-14665 Skip nodes internal to a PMM deployment when adding a service - #5704

Open
ademidoff wants to merge 8 commits into
mainfrom
PMM-14665-skip-non-eligible-nodes-from-add-service
Open

PMM-14665 Skip nodes internal to a PMM deployment when adding a service#5704
ademidoff wants to merge 8 commits into
mainfrom
PMM-14665-skip-non-eligible-nodes-from-add-service

Conversation

@ademidoff

@ademidoff ademidoff commented Jul 27, 2026

Copy link
Copy Markdown
Member

Ticket number: PMM-14665

Feature build: Percona-Lab/pmm-submodules#4498

In an HA deployment the PostgreSQL cluster backing PMM's persistence layer runs pmm-client sidecars, so its pods were offered in the "Nodes" dropdown of Add Service as valid monitoring delegates. Those nodes are dedicated and must not take on any extra monitoring workloads.

PMM Server now accepts PMM_INTERNAL_NODE_NAME_PREFIXES (set by the pmm-ha Helm chart), reports the nodes it matches as is_pmm_internal_node on ListNodes/GetNode, and rejects requests which delegate monitoring of a remote address to an agent running on one of them.

Local addresses (empty, localhost, 127.0.0.1, ::1) stay allowed on those nodes: that is how the PostgreSQL operator's sidecar registers its own PostgreSQL and Patroni services on every pod start, so a blanket rejection would break the persistence layer's own monitoring. An airtight alternative is to key the check on the registering service account instead, which is deliberately deferred - see the ticket.

AddAzureDatabaseRequest gains pmm_agent_id, which the UI has always sent but the server discarded, placing Azure exporters on the PMM Server unconditionally.

PMM Server nodes stay eligible on purpose: until the Azure API accepts an agent, Azure monitoring cannot run anywhere else.

If this PR adds, removes or alters one or more API endpoints, please review and update the relevant API documentation as well:

  • API Docs updated

If this PR is related to other PRs, contributions, or ongoing work in this or other repositories, please reference them here:

In an HA deployment the PostgreSQL cluster backing PMM's persistence layer runs
pmm-client sidecars, so its pods were offered in the Nodes dropdown as valid
monitoring delegates. Those Nodes are dedicated and must not take on extra
monitoring workloads.

PMM Server now accepts PMM_INTERNAL_NODE_NAME_PREFIXES, reports the Nodes it
matches as is_pmm_internal_node, and rejects requests which delegate monitoring
of a remote address to an Agent running on one of them. Local addresses remain
allowed, so those Nodes keep monitoring the services inside their own pod.

AddAzureDatabaseRequest gains pmm_agent_id, which the UI has always sent but the
server discarded, placing Azure exporters on the PMM Server unconditionally.
@ademidoff
ademidoff requested a review from a team as a code owner July 27, 2026 22:25
@ademidoff
ademidoff requested review from 4nte and JiriCtvrtka and removed request for a team July 27, 2026 22:25
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.39286% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.27%. Comparing base (31318c7) to head (6e61bd3).
⚠️ Report is 79 commits behind head on main.

Files with missing lines Patch % Lines
managed/cmd/pmm-managed/main.go 53.84% 6 Missing ⚠️
managed/services/management/service.go 89.09% 3 Missing and 3 partials ⚠️
managed/services/management/azure_database.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5704      +/-   ##
==========================================
+ Coverage   43.59%   45.27%   +1.67%     
==========================================
  Files         415      418       +3     
  Lines       43134    43397     +263     
==========================================
+ Hits        18804    19647     +843     
+ Misses      22454    21805     -649     
- Partials     1876     1945      +69     
Flag Coverage Δ
admin 34.96% <ø> (+0.17%) ⬆️
agent 50.28% <ø> (+1.24%) ⬆️
managed 45.06% <88.39%> (+2.08%) ⬆️
vmproxy 72.22% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

`pmm-agent setup` registered the Node on every run, and a forced registration
makes PMM Server drop the Node together with every Service on it. That is
harmless for the database operators, whose sidecars re-add their own services on
each container start, but it would silently delete user-added services from a
long-lived PMM Client pod, which is what the pmm-ha Helm chart is about to
pre-provision as monitoring delegates.

Registration is now skipped when the Agent already holds an ID and is being set
up against the same PMM Server it is registered with. `--force` still registers
the Node again, and pointing an Agent at a different PMM Server registers it
there as before.
…gent

Skipping registration for an Agent which already holds an ID strands it whenever
PMM Server no longer knows that ID, e.g. after the server was reinstalled or
restored from a backup taken before the Agent was registered. pmm-agent then
loops on "No Agent with ID" while the Node monitors nothing.

`pmm-agent setup` now asks the server whether it still knows the Agent and
registers the Node again when it does not. Credentials the server rejects count
as an answer too: registering reports that with an actionable message, whereas
skipping it would fail silently later on.

An unreachable server is not an answer: a failed check keeps the registration, so
an Agent still starts while PMM Server has no leader elected yet.
@ademidoff
ademidoff marked this pull request as draft July 28, 2026 07:56
ademidoff and others added 2 commits July 28, 2026 11:04
Keeping this ticket to what it is about: reporting the Nodes of a PMM deployment's
own infrastructure as internal and refusing to delegate monitoring to them.

Making `pmm-agent setup` idempotent is what would let a pre-provisioned PMM Client
pod register once and keep its identity across restarts, but the chart can do that
with a one-time init container instead. The agent side is worth its own effort:
it changes pmm-agent CLI behaviour, it needs a release note, and the surrounding
questions - how an Agent recovers when PMM Server no longer knows it, and how an
orphaned Node is reclaimed - deserve their own design and review.
@ademidoff
ademidoff marked this pull request as ready for review July 30, 2026 07:40
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.

1 participant