Skip to content

Conversation

pchila
Copy link
Member

@pchila pchila commented Sep 10, 2025

What does this PR do?

This PR allows overriding AGENT_PACKAGE_VERSION and MANIFEST_URL when packaging using the information in package.version file. This is achieved by loading the package.version data before looking up the relevant env vars and using the values assigned from package version as fallbacks if the env vars are not defined.

Why is it important?

This allows for easy repackaging elastic-agent from a working directory, in order to have 2 "different" versions for the elastic-agent package: this is useful mostly when testing some upgrade scenarios.
Most of the time USER_PACKAGE_VERSION=true by itself will do a fine job for packaging so the usage of this change should be limited to some very specific testing.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in ./changelog/fragments using the changelog tool
  • [ ] I have added an integration test or an E2E test

Disruptive User Impact

None. This PR only adds the possibility to override some strings coming from package.version

How to test this PR locally

  • Run a normal packaging using package version:
    USE_PACKAGE_VERSION=true  EXTERNAL=true  PACKAGES="tar.gz" PLATFORMS="linux/amd64" mage -v package
  • Now run the same packaging but specifying a different AGENT_PACKAGE_VERSION (before this PR this was producing the same package as the previous command)
    AGENT_PACKAGE_VERSION=9.1.0+20250910000000 USE_PACKAGE_VERSION=true  EXTERNAL=true  PACKAGES="tar.gz" PLATFORMS="linux/amd64" mage -v package

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@pchila pchila self-assigned this Sep 10, 2025
@pchila pchila added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent Label for the Agent team labels Sep 10, 2025
Copy link
Contributor

mergify bot commented Sep 10, 2025

This pull request does not have a backport label. Could you fix it @pchila? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label that automatically backports to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@pchila pchila marked this pull request as ready for review September 10, 2025 17:44
@pchila pchila requested a review from a team as a code owner September 10, 2025 17:44
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

Copy link
Contributor

@pkoutsovasilis pkoutsovasilis left a comment

Choose a reason for hiding this comment

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

ok although this opens up a lot of possibilities, in terms of packaging env vars, that I am not sure all of them will result in a happy path (😄) I understand that there is a need for flexibility, just keep in mind with great power comes great responsibility. So aside the lint error this LGTM, let's address it @pchila

Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@elasticmachine
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @pchila

@pchila pchila merged commit 3a2bbed into elastic:main Sep 11, 2025
23 checks passed
v1v added a commit that referenced this pull request Sep 16, 2025
* upstream: (26 commits)
  fix: ensure EDOT subprocess shuts down gracefully on agent termination (#9886)
  [main][Automation] Update versions (#9976)
  Add Collector reference docs and automation (#9953)
  [beatreceivers] Integrate beatsauthextension (#9257)
  [main][Automation] Update versions (#9941)
  Update OTel components to v0.132.0/v1.38.0 (#9954)
  Enhancement/5235 wrap errors when marking upgrade (#9366)
  Mount Go build cache into crossbuild container (#9094)
  Liveness agent state (#9673)
  [main][Automation] Bump VM Image version to 1757725254 (#9942)
  Enhancement/5235 correctly wrap errors from copyActionDir and copyRunDirectory (#9349)
  [main][Automation] Update elastic/beats to afc53c0479ac (#9874)
  Add -coverpkg option when running unit test to calculate coverage across packages (#9913)
  Cache binaries downloaded for packaging locally (#9133)
  [main][Automation] Update versions (#9897)
  Disable flaky test TestBeatsReceiverLogs (#9891)
  Allow overriding AGENT_PACKAGE_VERSION and MANIFEST_URL when USE_PACKAGE_VERSION=true (#9864)
  add ingest-docs team as CODEOWNERS for release notes and docset.yml (#9865)
  fix: correct spelling of 'output' in various templates and monitoring code (#9827)
  k8s: Add comment around hostUsers for Universal Profiling deployments (#9847)
  ...
intxgo pushed a commit to intxgo/elastic-agent that referenced this pull request Sep 24, 2025
…AGE_VERSION=true (elastic#9864)

* Allow overriding AGENT_PACKAGE_VERSION and MANIFEST_URL when USE_PACKAGE_VERSION=true

* Update dev-tools/mage/settings.go

* fix lint errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request skip-changelog Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants