From 60426ec8a27cbfd927b62f0875453f615657b56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Ctvrtka?= Date: Fri, 28 Aug 2026 10:40:58 +0200 Subject: [PATCH 1/2] PMM-15295 Warn on Nomad without public address. --- managed/utils/envvars/parser.go | 7 +++ managed/utils/envvars/parser_test.go | 68 ++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/managed/utils/envvars/parser.go b/managed/utils/envvars/parser.go index 953f6ee5f8..567ac7efa2 100644 --- a/managed/utils/envvars/parser.go +++ b/managed/utils/envvars/parser.go @@ -323,6 +323,13 @@ func ParseEnvVars(envs []string) (*models.ChangeSettingsParams, []error, []strin } } + // 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. + 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") + } + return envSettings, errs, warns } diff --git a/managed/utils/envvars/parser_test.go b/managed/utils/envvars/parser_test.go index 9881de244d..579df428cb 100644 --- a/managed/utils/envvars/parser_test.go +++ b/managed/utils/envvars/parser_test.go @@ -280,6 +280,74 @@ func TestEnvVarValidator(t *testing.T) { }) } +func TestNomadWithoutPublicAddress(t *testing.T) { + t.Parallel() + + const warning = "PMM_ENABLE_NOMAD is set but PMM_PUBLIC_ADDRESS is not; Nomad will not start" + + for _, tt := range []struct { + name string + envs []string + expected bool + }{ + { + name: "Nomad enabled without public address", + envs: []string{"PMM_ENABLE_NOMAD=1"}, + expected: true, + }, + { + name: "Nomad enabled with non-numeric truthy value", + envs: []string{"PMM_ENABLE_NOMAD=TRUE"}, + expected: true, + }, + { + name: "Nomad enabled with empty public address", + envs: []string{"PMM_ENABLE_NOMAD=1", "PMM_PUBLIC_ADDRESS="}, + expected: true, + }, + { + name: "Nomad enabled with public address", + envs: []string{"PMM_ENABLE_NOMAD=1", "PMM_PUBLIC_ADDRESS=1.2.3.4:5678"}, + expected: false, + }, + { + name: "Nomad explicitly disabled without public address", + envs: []string{"PMM_ENABLE_NOMAD=0"}, + expected: false, + }, + { + name: "neither variable set", + envs: []string{"PMM_DATA_RETENTION=72h"}, + expected: false, + }, + { + name: "only public address set", + envs: []string{"PMM_PUBLIC_ADDRESS=1.2.3.4:5678"}, + expected: false, + }, + } { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + + _, gotErrs, gotWarns := ParseEnvVars(tt.envs) + assert.Nil(t, gotErrs) + if tt.expected { + assert.Contains(t, gotWarns, warning) + } else { + assert.NotContains(t, gotWarns, warning) + } + }) + } + + t.Run("invalid Nomad value reports an error without the warning", func(t *testing.T) { + t.Parallel() + + _, gotErrs, gotWarns := ParseEnvVars([]string{"PMM_ENABLE_NOMAD=maybe"}) + assert.Len(t, gotErrs, 1) + assert.NotContains(t, gotWarns, warning) + }) +} + func TestRedactSecretEnvVar(t *testing.T) { t.Parallel() From 1b8f7b443bbc0b0183ab3242cbc93cd77972c209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Ctvrtka?= Date: Mon, 31 Aug 2026 12:45:37 +0200 Subject: [PATCH 2/2] PMM-15295 Clarify Nomad warning for settings-configured public address. --- managed/utils/envvars/parser.go | 3 ++- managed/utils/envvars/parser_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/managed/utils/envvars/parser.go b/managed/utils/envvars/parser.go index 567ac7efa2..8cc37ce836 100644 --- a/managed/utils/envvars/parser.go +++ b/managed/utils/envvars/parser.go @@ -327,7 +327,8 @@ func ParseEnvVars(envs []string) (*models.ChangeSettingsParams, []error, []strin // without one leaves the Nomad server silently not started. 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") + warns = append(warns, "PMM_ENABLE_NOMAD is set but PMM_PUBLIC_ADDRESS is not; "+ + "Nomad will not start unless a public address is configured in PMM settings") } return envSettings, errs, warns diff --git a/managed/utils/envvars/parser_test.go b/managed/utils/envvars/parser_test.go index 579df428cb..7919d4b7df 100644 --- a/managed/utils/envvars/parser_test.go +++ b/managed/utils/envvars/parser_test.go @@ -283,7 +283,8 @@ func TestEnvVarValidator(t *testing.T) { func TestNomadWithoutPublicAddress(t *testing.T) { t.Parallel() - const warning = "PMM_ENABLE_NOMAD is set but PMM_PUBLIC_ADDRESS is not; Nomad will not start" + const warning = "PMM_ENABLE_NOMAD is set but PMM_PUBLIC_ADDRESS is not; " + + "Nomad will not start unless a public address is configured in PMM settings" for _, tt := range []struct { name string