Skip to content

PMM-12575 change api for agents #4066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: v3
Choose a base branch
from

Conversation

BupycHuk
Copy link
Member

@BupycHuk BupycHuk commented Jun 1, 2025

PMM-12575

Link to the Feature Build: SUBMODULES-0

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

  • API Docs updated

If this PR is related to some other PRs in this or other repositories, please provide links to those PRs:

  • Links to related pull requests (optional).

BupycHuk added 2 commits May 30, 2025 13:45
- Added validation rules for the new fields in the corresponding validation files.
- Improved error handling and logging for agent configuration changes.
- Updated related tests to cover new functionality and ensure proper behavior.
Simplified agent parameter updates by replacing `ChangeAgentByType` with `ChangeAgent`. Updated related tests to ensure proper functionality for various agent options and persistence in the database.
Copy link

codecov bot commented Jun 1, 2025

Codecov Report

Attention: Patch coverage is 74.00235% with 443 lines in your changes missing coverage. Please review.

Project coverage is 45.35%. Comparing base (3bce330) to head (13b3f94).
Report is 6 commits behind head on v3.

Files with missing lines Patch % Lines
...mmands/inventory/change_agent_postgres_exporter.go 69.23% 30 Missing and 10 partials ⚠️
.../inventory/change_agent_qan_mysql_slowlog_agent.go 68.50% 30 Missing and 10 partials ⚠️
...commands/inventory/change_agent_valkey_exporter.go 68.50% 30 Missing and 10 partials ⚠️
...commands/inventory/change_agent_mysqld_exporter.go 70.99% 27 Missing and 11 partials ⚠️
...ventory/change_agent_qan_mysql_perfschema_agent.go 69.91% 28 Missing and 9 partials ⚠️
.../change_agent_qan_postgresql_pgstatements_agent.go 68.10% 28 Missing and 9 partials ⚠️
...change_agent_qan_postgresql_pgstatmonitor_agent.go 69.91% 28 Missing and 9 partials ⚠️
...ommands/inventory/change_agent_mongodb_exporter.go 78.32% 23 Missing and 8 partials ⚠️
...ventory/change_agent_qan_mongodb_profiler_agent.go 77.47% 19 Missing and 6 partials ⚠️
.../commands/inventory/add_agent_postgres_exporter.go 0.00% 13 Missing ⚠️
... and 37 more
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #4066      +/-   ##
==========================================
+ Coverage   44.16%   45.35%   +1.18%     
==========================================
  Files         369      386      +17     
  Lines       45306    47390    +2084     
==========================================
+ Hits        20009    21492    +1483     
- Misses      23610    24136     +526     
- Partials     1687     1762      +75     
Flag Coverage Δ
admin 32.97% <74.00%> (+15.68%) ⬆️
agent 52.73% <ø> (ø)
managed 45.03% <ø> (+0.07%) ⬆️
vmproxy 73.45% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

BupycHuk added 6 commits June 2, 2025 12:58
…andling

- Consolidated client mutex locking to ensure thread safety during test server setup.
- Simplified the client initialization process for better readability and maintainability.
…change agent test files for cleaner code.
…ct format and year for consistency across the codebase.
Replaced redundant `len(*customLabels) > 0` with `len(*customLabels) != 0` for consistency. Removed unnecessary compound conditions to simplify code and improve readability.
@BupycHuk BupycHuk marked this pull request as ready for review June 2, 2025 13:59
@BupycHuk BupycHuk requested a review from a team as a code owner June 2, 2025 13:59
@BupycHuk BupycHuk requested review from idoqo, JiriCtvrtka and Copilot and removed request for a team June 2, 2025 13:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adjust custom labels handling across commands, introduce a new PostgreSQL exporter connection limit flag, and enhance template utilities.

  • Refactored ParseCustomLabels to accept and return pointers, updating all command usages.
  • Added MaxExporterConnections flag to AddAgentPostgresExporterCommand.
  • Extended base.go with FormatLogLevel and FormatCustomLabels template functions (added sort import).

Reviewed Changes

Copilot reviewed 104 out of 104 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
admin/commands/inventory/add_service_external.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_node_remote_rds.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_node_remote.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_node_generic.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_node_container.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_rds_exporter.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_qan_postgres_pgstatmonitor_agent.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_qan_postgres_pgstatements_agent.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_qan_mysql_slowlog_agent.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_qan_mysql_perfschema_agent.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_qan_mongodb_profiler_agent.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_proxysql_exporter.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_postgres_exporter.go Updated ParseCustomLabels call; added new flag
admin/commands/inventory/add_agent_pmm_agent.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_node_exporter.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_mysqld_exporter.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_mongodb_exporter.go Updated ParseCustomLabels call to use pointer
admin/commands/inventory/add_agent_external_exporter.go Updated ParseCustomLabels call to use pointer
admin/commands/base_test.go Adapted tests for pointer-based ParseCustomLabels
admin/commands/base.go Changed ParseCustomLabels signature; added imports and template functions
Comments suppressed due to low confidence (3)

admin/commands/base.go:27

  • The new FormatCustomLabels function uses fmt.Sprintf but fmt is not imported; add "fmt" to the imports to avoid compilation errors.
import (

admin/commands/base.go:221

  • The new FormatCustomLabels (and FormatLogLevel) functions lack unit tests. Consider adding tests to cover these formatting helpers to prevent regressions.
func FormatCustomLabels(labels interface{}) string {

admin/commands/base.go:161

  • [nitpick] Using *map[string]string is uncommon in Go since maps are reference types. Consider returning a map[string]string and using nil to represent absence for a more idiomatic API.
func ParseCustomLabels(labels *map[string]string) *map[string]string {

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.

3 participants