Skip to content

Conversation

@idoqo
Copy link
Contributor

@idoqo idoqo commented Oct 30, 2025

PMM-14375

Link to the Feature Build: SUBMODULES-0

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 53.84615% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.72%. Comparing base (586a922) to head (729dc2b).

Files with missing lines Patch % Lines
managed/services/management/mongodb.go 0.00% 24 Missing ⚠️
managed/models/models.go 38.88% 10 Missing and 1 partial ⚠️
managed/models/encryption_helpers.go 0.00% 4 Missing and 1 partial ⚠️
managed/services/agents/mongodb.go 42.85% 2 Missing and 2 partials ⚠️
admin/commands/management/add_mongodb.go 0.00% 2 Missing ⚠️
managed/models/agent_helpers.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #4717      +/-   ##
==========================================
- Coverage   45.75%   45.72%   -0.04%     
==========================================
  Files         364      364              
  Lines       37755    37805      +50     
==========================================
+ Hits        17275    17286      +11     
- Misses      18823    18857      +34     
- Partials     1657     1662       +5     
Flag Coverage Δ
admin 17.90% <0.00%> (-0.02%) ⬇️
agent 53.58% <ø> (-0.13%) ⬇️
managed 46.22% <54.90%> (+<0.01%) ⬆️
vmproxy 72.09% <ø> (ø)

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.

@idoqo idoqo requested a review from Copilot October 30, 2025 13:13
Copy link
Contributor

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

This PR adds support for environment variables to be passed to MongoDB agents (MongoDB Exporter, QAN MongoDB Profiler Agent, and QAN MongoDB Mongolog Agent). The changes enable users to configure custom environment variables for these agents through the API, command-line tools, and internal configuration.

Key changes:

  • Added EnvironmentVariables field to the Agent database model with encryption support
  • Extended API definitions to accept agent_environment_variables parameter for MongoDB agents
  • Updated service creation and configuration logic to pass environment variables to agents
  • Added database schema migration to support the new field
  • Included command-line support for setting environment variables via the admin tool

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
managed/models/agent_model.go Adds EnvironmentVariables field to Agent struct with getter/setter methods
managed/models/database.go Adds database migration to create environment_variables column
managed/models/encryption_helpers.go Adds encryption support for environment variables
managed/services/management/mongodb.go Passes environment variables when creating MongoDB agents
managed/services/inventory/agents.go Retrieves and passes environment variables for MongoDB agents
managed/services/agents/mongodb.go Constructs environment variables for MongoDB exporter and QAN agents
api/inventory/v1/agents.proto Adds agent_environment_variables field to MongoDB agent API definitions
api/management/v1/mongodb.proto Adds agent_environment_variables field to MongoDB service params
admin/commands/management/add_mongodb.go Adds CLI support for agent environment variables
api-tests/management/mongodb_test.go Fixes variable naming typo in test

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@idoqo idoqo marked this pull request as ready for review October 30, 2025 13:23
@idoqo idoqo requested a review from a team as a code owner October 30, 2025 13:23
@idoqo idoqo requested review from BupycHuk, JiriCtvrtka and ademidoff and removed request for a team October 30, 2025 13:23
Copy link
Member

@BupycHuk BupycHuk left a comment

Choose a reason for hiding this comment

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

I don't see how this env variable is passed to QAN agent.

}

// GetEnvironmentVariables decodes environment variables.
func (s *Agent) GetEnvironmentVariables() (map[string]string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

if error isn't used anywhere why do we return it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was because of the underlying getLabel() function - will update the callers to use the errors.

@idoqo
Copy link
Contributor Author

idoqo commented Nov 11, 2025

I don't see how this env variable is passed to QAN agent.

Based on the discussion here, I don't think we need to do anything special to share env variables with qan agents - they are still part of the original pmm-agent process and have access to the same env variables - will remove them from the proto definitions for qan agents as well

@BupycHuk
Copy link
Member

So you have to set that env variable for pmm-agent and also pass it in pmm-admin command? isn't it too complex?

@idoqo
Copy link
Contributor Author

idoqo commented Nov 11, 2025

So you have to set that env variable for pmm-agent and also pass it in pmm-admin command? isn't it too complex?

yeahh opened to a different flow really, one option will be to automatically pass pmm-agent environment variables to exporters. Sharing all of it might not be a good idea, hence, we might still need some flag to specify what variables should be shared (only difference is that this time, user only specifies the variable names, not values).

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