Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d460511
PMM-15130 Validate connection on agent params change
4nte Jul 8, 2026
d5cc56b
Merge branch 'main' into PMM-15130-validate-connection-on-agent-param…
4nte Jul 8, 2026
7aea13e
PMM-15130 Use *bool for change-agent skip_connection_check flag
4nte Jul 9, 2026
5016b86
PMM-15130 Add tests
4nte Jul 9, 2026
5eb363f
PMM-15130 make gen && make format
4nte Jul 9, 2026
f8a0b78
PMM-15130 Add CLI test for --skip-connection-check parsing
4nte Jul 9, 2026
d1f16cc
PMM-15130 Fix linter warnings
4nte Jul 9, 2026
c1c7d8e
Merge branch 'main' into PMM-15130-validate-connection-on-agent-param…
4nte Jul 9, 2026
d5e4b16
Merge branch 'main' into PMM-15130-validate-connection-on-agent-param…
4nte Jul 10, 2026
ff5e63b
PMM-15130 Move `skipConnectionCheck` into `models.ChangeAgentParams`
4nte Jul 10, 2026
912b6d4
PMM-15130 Fix err check in `ChangeQANPostgreSQLPgStatementsAgent`
4nte Jul 10, 2026
742d8f0
PMM-15130 Remove unused `lll` nolint directive
4nte Jul 10, 2026
2c7d7d8
PMM-15130 Add docs for `--skip-connection-check` flag
4nte Jul 10, 2026
ae91246
PMM-15130 Refactor: extract common helper `executeAgentAdd`
4nte Jul 13, 2026
e3ace3f
Merge branch 'main' into PMM-15130-validate-connection-on-agent-param…
4nte Jul 13, 2026
4a10d0c
PMM-15130 Check type assertions gracefully instead of panicking
4nte Jul 13, 2026
524e213
Merge branch 'main' into PMM-15130-validate-connection-on-agent-param…
4nte Jul 13, 2026
834a8b7
Merge branch 'main' into PMM-15130-validate-connection-on-agent-param…
4nte Jul 14, 2026
7b656b7
Merge branch 'main' into PMM-15130-validate-connection-on-agent-param…
4nte Jul 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions admin/commands/inventory/change_agent_external_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type ChangeAgentExternalExporterCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentExternalExporterCommand and returns the result.
Expand All @@ -82,12 +85,13 @@ func (cmd *ChangeAgentExternalExporterCommand) RunCmd() (commands.Result, error)
customLabels := commands.ParseKeyValuePair(cmd.CustomLabels)

body := &agents.ChangeAgentParamsBodyExternalExporter{
Enable: cmd.Enable,
Username: cmd.Username,
ListenPort: cmd.ListenPort,
Scheme: cmd.MetricsScheme,
MetricsPath: cmd.MetricsPath,
EnablePushMetrics: cmd.PushMetrics,
Enable: cmd.Enable,
Username: cmd.Username,
ListenPort: cmd.ListenPort,
Scheme: cmd.MetricsScheme,
MetricsPath: cmd.MetricsPath,
EnablePushMetrics: cmd.PushMetrics,
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
4 changes: 4 additions & 0 deletions admin/commands/inventory/change_agent_mongodb_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ type ChangeAgentMongodbExporterCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentMongodbExporterCommand and returns the result.
Expand Down Expand Up @@ -155,6 +158,7 @@ func (cmd *ChangeAgentMongodbExporterCommand) RunCmd() (commands.Result, error)
EnablePushMetrics: cmd.PushMetrics,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
4 changes: 4 additions & 0 deletions admin/commands/inventory/change_agent_mysqld_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ type ChangeAgentMysqldExporterCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentMysqldExporterCommand and returns the result.
Expand Down Expand Up @@ -146,6 +149,7 @@ func (cmd *ChangeAgentMysqldExporterCommand) RunCmd() (commands.Result, error) {
EnablePushMetrics: cmd.PushMetrics,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
35 changes: 35 additions & 0 deletions admin/commands/inventory/change_agent_mysqld_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,41 @@ Configuration changes applied:
assert.JSONEq(t, expectedJSON, capturedRequestBody)
})

t.Run("KongParsingWithSkipConnectionCheck", func(t *testing.T) {
agentID := "test-mysqld-skip"

var capturedRequestBody string

cleanup := setupChangeAgentTestServer(t, agentID, "", &capturedRequestBody)
defer cleanup()

var cmd ChangeAgentMysqldExporterCommand
parser := kong.Must(&cmd)

args := []string{agentID, "--skip-connection-check"}

ctx, err := parser.Parse(args)
require.NoError(t, err)
require.NotNil(t, ctx)

require.NotNil(t, cmd.SkipConnectionCheck)
assert.True(t, *cmd.SkipConnectionCheck)

result, err := cmd.RunCmd()
require.NoError(t, err)
require.NotNil(t, result)

// Positive counterpart to KongParsingWithMinimalFlags: when the flag IS passed,
// the request body must carry skip_connection_check: true (not omitted).
expectedJSON := `{
"mysqld_exporter": {
"disable_collectors": null,
"skip_connection_check": true
}
}`
assert.JSONEq(t, expectedJSON, capturedRequestBody)
})

t.Run("KongParsingErrorCases", func(t *testing.T) {
t.Run("MissingRequiredArgument", func(t *testing.T) {
var cmd ChangeAgentMysqldExporterCommand
Expand Down
4 changes: 4 additions & 0 deletions admin/commands/inventory/change_agent_postgres_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ type ChangeAgentPostgresExporterCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentPostgresExporterCommand and returns the result.
Expand Down Expand Up @@ -148,6 +151,7 @@ func (cmd *ChangeAgentPostgresExporterCommand) RunCmd() (commands.Result, error)
MaxExporterConnections: cmd.MaxExporterConnections,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
26 changes: 15 additions & 11 deletions admin/commands/inventory/change_agent_proxysql_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type ChangeAgentProxysqlExporterCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentProxysqlExporterCommand and returns the result.
Expand All @@ -97,17 +100,18 @@ func (cmd *ChangeAgentProxysqlExporterCommand) RunCmd() (commands.Result, error)
customLabels := commands.ParseKeyValuePair(cmd.CustomLabels)

body := &agents.ChangeAgentParamsBodyProxysqlExporter{
Enable: cmd.Enable,
Username: cmd.Username,
Password: cmd.Password,
TLS: cmd.TLS,
TLSSkipVerify: cmd.TLSSkipVerify,
DisableCollectors: cmd.DisableCollectors,
AgentPassword: cmd.AgentPassword,
ExposeExporter: cmd.ExposeExporter,
EnablePushMetrics: cmd.PushMetrics,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout),
Enable: cmd.Enable,
Username: cmd.Username,
Password: cmd.Password,
TLS: cmd.TLS,
TLSSkipVerify: cmd.TLSSkipVerify,
DisableCollectors: cmd.DisableCollectors,
AgentPassword: cmd.AgentPassword,
ExposeExporter: cmd.ExposeExporter,
EnablePushMetrics: cmd.PushMetrics,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ type ChangeAgentQANMongoDBMongologAgentCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentQANMongoDBMongologAgentCommand and returns the result.
Expand Down Expand Up @@ -126,6 +129,7 @@ func (cmd *ChangeAgentQANMongoDBMongologAgentCommand) RunCmd() (commands.Result,
AuthenticationMechanism: cmd.AuthenticationMechanism,
AuthenticationDatabase: cmd.AuthenticationDatabase,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

// Parse custom labels if provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type ChangeAgentQANMongoDBProfilerAgentCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentQANMongoDBProfilerAgentCommand and returns the result.
Expand Down Expand Up @@ -130,6 +133,7 @@ func (cmd *ChangeAgentQANMongoDBProfilerAgentCommand) RunCmd() (commands.Result,
AuthenticationDatabase: cmd.AuthenticationDatabase,
MaxQueryLength: cmd.MaxQueryLength,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ type ChangeAgentQANMySQLPerfSchemaAgentCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentQANMySQLPerfSchemaAgentCommand and returns the result.
Expand Down Expand Up @@ -135,6 +138,7 @@ func (cmd *ChangeAgentQANMySQLPerfSchemaAgentCommand) RunCmd() (commands.Result,
DisableQueryExamples: cmd.DisableQueryExamples,
DisableCommentsParsing: cmd.CommentsParsingDisabled(),
LogLevel: convertLogLevelPtr(cmd.LogLevel),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ type ChangeAgentQANMySQLSlowlogAgentCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentQANMySQLSlowlogAgentCommand and returns the result.
Expand Down Expand Up @@ -135,6 +138,7 @@ func (cmd *ChangeAgentQANMySQLSlowlogAgentCommand) RunCmd() (commands.Result, er
DisableQueryExamples: cmd.DisableQueryExamples,
DisableCommentsParsing: cmd.CommentsParsingDisabled(),
LogLevel: convertLogLevelPtr(cmd.LogLevel),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ type ChangeAgentQANPostgreSQLPgStatementsAgentCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentQANPostgreSQLPgStatementsAgentCommand and returns the result.
Expand Down Expand Up @@ -133,6 +136,7 @@ func (cmd *ChangeAgentQANPostgreSQLPgStatementsAgentCommand) RunCmd() (commands.
MaxQueryLength: cmd.MaxQueryLength,
DisableCommentsParsing: cmd.CommentsParsingDisabled(),
LogLevel: convertLogLevelPtr(cmd.LogLevel),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type ChangeAgentQANPostgreSQLPgStatMonitorAgentCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentQANPostgreSQLPgStatMonitorAgentCommand and returns the result.
Expand Down Expand Up @@ -136,6 +139,7 @@ func (cmd *ChangeAgentQANPostgreSQLPgStatMonitorAgentCommand) RunCmd() (commands
DisableQueryExamples: cmd.DisableQueryExamples,
DisableCommentsParsing: cmd.CommentsParsingDisabled(),
LogLevel: convertLogLevelPtr(cmd.LogLevel),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
4 changes: 4 additions & 0 deletions admin/commands/inventory/change_agent_rta_mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ type ChangeAgentRTAMongoDBAgentCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentRTAMongoDBAgentCommand and returns the result.
Expand Down Expand Up @@ -127,6 +130,7 @@ func (cmd *ChangeAgentRTAMongoDBAgentCommand) RunCmd() (commands.Result, error)
TLSCa: tlsCa,
AuthenticationMechanism: cmd.AuthenticationMechanism,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
32 changes: 18 additions & 14 deletions admin/commands/inventory/change_agent_valkey_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ type ChangeAgentValkeyExporterCommand struct {

// Custom labels
CustomLabels *map[string]string `mapsep:"," help:"Custom user-assigned labels"`

// Connection check
SkipConnectionCheck *bool `help:"Skip connection check"`
}

// RunCmd executes the ChangeAgentValkeyExporterCommand and returns the result.
Expand Down Expand Up @@ -126,20 +129,21 @@ func (cmd *ChangeAgentValkeyExporterCommand) RunCmd() (commands.Result, error) {
}

body := &agents.ChangeAgentParamsBodyValkeyExporter{
Enable: cmd.Enable,
Username: cmd.Username,
Password: cmd.Password,
TLS: cmd.TLS,
TLSSkipVerify: cmd.TLSSkipVerify,
AgentPassword: cmd.AgentPassword,
TLSCa: tlsCa,
TLSCert: tlsCert,
TLSKey: tlsKey,
DisableCollectors: cmd.DisableCollectors,
ExposeExporter: cmd.ExposeExporter,
EnablePushMetrics: cmd.PushMetrics,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout),
Enable: cmd.Enable,
Username: cmd.Username,
Password: cmd.Password,
TLS: cmd.TLS,
TLSSkipVerify: cmd.TLSSkipVerify,
AgentPassword: cmd.AgentPassword,
TLSCa: tlsCa,
TLSCert: tlsCert,
TLSKey: tlsKey,
DisableCollectors: cmd.DisableCollectors,
ExposeExporter: cmd.ExposeExporter,
EnablePushMetrics: cmd.PushMetrics,
LogLevel: convertLogLevelPtr(cmd.LogLevel),
ConnectionTimeout: commands.DurationString(cmd.ConnectionTimeout),
SkipConnectionCheck: cmd.SkipConnectionCheck,
}

if customLabels != nil {
Expand Down
20 changes: 12 additions & 8 deletions api-tests/inventory/agents_external_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ func TestExternalExporter(t *testing.T) {
AgentID: agentID,
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
Username: new("rotated-external-user"),
SkipConnectionCheck: new(true),
Username: new("rotated-external-user"),
},
},
Context: pmmapitests.Context,
Expand All @@ -467,8 +468,9 @@ func TestExternalExporter(t *testing.T) {
AgentID: agentID,
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
Scheme: new("http"),
MetricsPath: new("/new-metrics"),
SkipConnectionCheck: new(true),
Scheme: new("http"),
MetricsPath: new("/new-metrics"),
},
},
Context: pmmapitests.Context,
Expand Down Expand Up @@ -527,7 +529,8 @@ func TestExternalExporter(t *testing.T) {
AgentID: agentID,
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
Username: new("changed-external-user"),
SkipConnectionCheck: new(true),
Username: new("changed-external-user"),
// Note: custom labels, scheme, metrics path, push metrics are NOT specified
},
},
Expand Down Expand Up @@ -598,10 +601,11 @@ func TestExternalExporter(t *testing.T) {
AgentID: agentID,
Body: agents.ChangeAgentBody{
ExternalExporter: &agents.ChangeAgentParamsBodyExternalExporter{
Username: new("changed-external-user"),
Scheme: new("https"),
MetricsPath: new("/new-metrics"),
ListenPort: new(int64(8080)),
SkipConnectionCheck: new(true),
Username: new("changed-external-user"),
Scheme: new("https"),
MetricsPath: new("/new-metrics"),
ListenPort: new(int64(8080)),
CustomLabels: &agents.ChangeAgentParamsBodyExternalExporterCustomLabels{
Values: map[string]string{
"environment": "production",
Expand Down
Loading
Loading