Skip to content

PMM-15295 Warn on Nomad without public address. - #5849

Open
JiriCtvrtka wants to merge 3 commits into
mainfrom
PMM-15295-warn-nomad-without-public-address
Open

PMM-15295 Warn on Nomad without public address.#5849
JiriCtvrtka wants to merge 3 commits into
mainfrom
PMM-15295-warn-nomad-without-public-address

Conversation

@JiriCtvrtka

@JiriCtvrtka JiriCtvrtka commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Ticket number: PMM-15295

Feature build: SUBMODULES-0

What

Emit a configuration warning when PMM_ENABLE_NOMAD is set but PMM_PUBLIC_ADDRESS is not, instead of silently skipping the Nomad server.

Why

Nomad needs both variables. With the flag alone, Settings.IsNomadEnabled() returns false and supervisord skips the nomad-server template — no error, no warning. The container is healthy and PMM works, so nothing indicates why nothing can be executed.

This cost real debugging time during SEP integration testing: SEP dispatches task execution through PMM's embedded Nomad, so the failure surfaces as "SEP cannot run anything", several layers away from one unset variable. The requirement is documented in documentation/docs/reference/nomad.md, but the runtime said nothing.

How

A post-loop cross-check in ParseEnvVars appending to the existing warns list — no new plumbing:

if envSettings.EnableNomad != nil && *envSettings.EnableNomad &&
    (envSettings.PMMPublicAddress == nil || *envSettings.PMMPublicAddress == "") {
    warns = append(warns, "PMM_ENABLE_NOMAD is set but PMM_PUBLIC_ADDRESS is not; Nomad will not start")
}

The warning reaches the operator through the same channel as every other environment-variable warning: pmm-managed-init/main.go logs it as Configuration warning: %s, and server.go via s.l.Warnln on UpdateSettingsFromEnv.

This is a diagnostic, not a new failure mode. Only warns is appended to; errs is untouched, so pmm-managed-init does not exit and PMM starts exactly as before.

Behaviour

Environment | Warning -- | -- PMM_ENABLE_NOMAD=1, no public address | yes PMM_ENABLE_NOMAD=1, PMM_PUBLIC_ADDRESS= (empty) | yes — IsNomadEnabled() also treats empty as disabled PMM_ENABLE_NOMAD=1 + public address | no PMM_ENABLE_NOMAD=0 | no Neither set | no Public address only | no PMM_ENABLE_NOMAD=maybe | no — the existing parse error already reports it

Testing

TestNomadWithoutPublicAddress in managed/utils/envvars/parser_test.go covers every row above. Statement and branch coverage of the new block is complete, and each sub-term of the predicate is exercised both true and false.

  • go test ./managed/utils/envvars/... — pass
  • bin/golangci-lint run managed/utils/envvars/... — 0 issues
  • go build ./managed/..., go vet — clean

Out of scope

Changing the requirement itself — Nomad genuinely needs the public address.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.56%. Comparing base (31318c7) to head (1b8f7b4).
⚠️ Report is 158 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5849      +/-   ##
==========================================
+ Coverage   43.59%   45.56%   +1.97%     
==========================================
  Files         415      217     -198     
  Lines       43134    28116   -15018     
==========================================
- Hits        18804    12811    -5993     
+ Misses      22454    13920    -8534     
+ Partials     1876     1385     -491     

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

@JiriCtvrtka
JiriCtvrtka marked this pull request as ready for review August 31, 2026 11:03
@JiriCtvrtka
JiriCtvrtka requested a review from a team as a code owner August 31, 2026 11:03
@JiriCtvrtka
JiriCtvrtka requested review from 4nte and ademidoff and removed request for a team August 31, 2026 11:03
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b5bfc7d-204e-4c94-b261-eb3547addb5e

📥 Commits

Reviewing files that changed from the base of the PR and between 95c70a4 and 1b8f7b4.

📒 Files selected for processing (2)
  • managed/utils/envvars/parser.go
  • managed/utils/envvars/parser_test.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; 2 remain after this review.


Walkthrough

ParseEnvVars now appends a warning when PMM_ENABLE_NOMAD is enabled and PMM_PUBLIC_ADDRESS is unset or empty. The warning states that Nomad will not start without a configured public address. TestNomadWithoutPublicAddress verifies warning presence and absence across seven environment-variable combinations. It also verifies that an invalid Nomad value returns one error and no warning.

Merge Risk: ⚪ Minimal · up to 1b8f7

This change warns operators when Nomad is enabled without the required public address, without altering service behavior or access controls. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: warning when Nomad is enabled without a public address.
Description check ✅ Passed The description includes the required ticket number and feature build, explains what, why, and how, documents behavior and testing, and identifies out-of-scope work. The API documentation checkbox is …
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 includes the required ticket number and feature build, explains what, why, and how, documents behavior and testing, and identifies out-of-scope work. The API documentation checkbox is not required because this PR does not alter API endpoints.


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.

@yyyyyyyan yyyyyyyan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@JiriCtvrtka — This lands cleanly. The cross-check reuses the warns slice ParseEnvVars already returns rather than adding plumbing, errs stays untouched so boot behaviour is unchanged, and TestNomadWithoutPublicAddress exercises both sub-terms of the predicate in both directions plus the PMM_ENABLE_NOMAD=maybe row — that last one is the case easiest to forget. 1b8f7b4 also caught something subtle: the public address can come from Settings rather than the environment.

Two things I'd like to see before merge. They are the same observation from two sides.

The Nomad reference now contradicts the runtime. The page still tells operators the skip happens "with no error or warning", which is precisely what this PR changes:

Setting `PMM_ENABLE_NOMAD=1` alone is not sufficient. If `PMM_PUBLIC_ADDRESS` is not set, PMM silently skips starting the Nomad server process with no error or warning.

That page is where someone debugging an unexplained Nomad failure ends up, so leaving it saying there is nothing to look for in the log gives back most of what the warning buys. I checked the neighbours — env_var.md's "has no effect" and "Nomad does not start" both stay true — so this single sentence looks like the whole edit.

The check is environment-scoped and the comment above it is not. IsNomadEnabled() is pointer.GetBool(s.Nomad.Enabled) && s.PMMPublicAddress != "" over the merged settings (managed/models/settings.go:166), and UpdateSettings overwrites PMMPublicAddress only when the parsed pointer is non-nil (managed/models/settings_helpers.go:218). On an instance whose address was set through Configuration > Settings > Advanced settings — the route nomad.md:19 documents, restart included — PMM_ENABLE_NOMAD=1 alone makes this warning fire on every start while Nomad is up and healthy.

I would keep the check where it is: pmm-managed-init has no database, so the environment really is all it can see, and catching the common case at the earliest point is worth a false positive on the Settings route. The message already hedges for it. What I would change is the comment, so the next reader does not "correct" the message back to the unhedged form — suggestion inline. (If you would rather make it exact, UpdateSettingsFromEnv already has the merged settings in hand — models.UpdateSettings returns them and the result is currently discarded — and !settings.IsNomadEnabled() && pointer.GetBool(settings.Nomad.Enabled) would be precise there. It costs the pmm-managed-init line, which is the one an operator watching the container start sees first, so I do not think it is the better trade.)

Comment on lines +326 to +327
// Nomad needs the public address to build the URL agents connect back to, so enabling it
// without one leaves the Nomad server silently not started.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The first clause holds — advertise.rpc in managed/services/nomad/server.hcl is the public address, and the server certificate is named after it. It is the second clause I would reword. "Silently" is what this PR removes, and "without one" claims more than the condition below can support: it sees only the environment, so an address already stored in Settings keeps Nomad running while this still fires. 1b8f7b4 already taught the message that distinction; the comment is the last place holding the unhedged version, and it is the version a future reader will trust when tidying the string.

Suggested change
// Nomad needs the public address to build the URL agents connect back to, so enabling it
// without one leaves the Nomad server silently not started.
// Nomad needs the public address to build the URL agents connect back to. Only the
// environment is visible here, so an address held only in Settings warns anyway.

Writing the guard as pointer.GetBool(envSettings.EnableNomad) && pointer.GetString(envSettings.PMMPublicAddress) == "" would help too — it makes this the visible mirror of IsNomadEnabled() rather than a second spelling of the same question.

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