Skip to content

Added version round tripper#13695

Open
michalpristas wants to merge 3 commits intoelastic:mainfrom
michalpristas:fix/ua-header
Open

Added version round tripper#13695
michalpristas wants to merge 3 commits intoelastic:mainfrom
michalpristas:fix/ua-header

Conversation

@michalpristas
Copy link
Copy Markdown
Contributor

In order to use custom header for agentless deployments, we need to provide some way for fleet server to detect agent version

at this point server parser User agent header and expects Elastic Agent v1.2.3 this is no longer true.
Adding Elastic-Agent-Version header that can use as a fallback for cases when version is not included in User Agent

@michalpristas michalpristas self-assigned this Apr 20, 2026
@michalpristas michalpristas requested a review from a team as a code owner April 20, 2026 08:39
@michalpristas michalpristas added the enhancement New feature or request label Apr 20, 2026
@michalpristas michalpristas added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Apr 20, 2026
@michalpristas michalpristas requested a review from samuelvl April 20, 2026 08:39
@michalpristas michalpristas added the backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches label Apr 20, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

lgtm!

@cmacknz
Copy link
Copy Markdown
Member

cmacknz commented Apr 20, 2026

we need to provide some way for fleet server to detect agent version

They all still have a version don't they? Looking at the paired elastic/fleet-server#6864 where you'd need ECH deployments to update for this to work, what problem are you solving that requires both of these?

IIRC the original motivation for this was to get agentless to show in proxy telemetry, you just need to insert the word agentless somewhere don't you? Is the problem that you are injecting the user agent yourself and you don't know the agent version when you do that (is this actually true? You know what container tag you deployed don't you?)?

I am not opposed to the changes in isolation but I worry this is creating a series of incompatibilities it would be better to avoid instead.

@michalpristas
Copy link
Copy Markdown
Contributor Author

michalpristas commented Apr 21, 2026

well for this to work by "placing agentless somewhere" we would need to make it part of the version.
now if we want to use FLEET_HEADERS to override user agent as elaborated and agreed we dont' have an option to make it place agentless somewhere kind. it needs to be hardcoded value.

for this to work it would need to be Elastic Agent v8.0.0-agentless (as we strip whatever comes after -) with 8.0.0 being always current version. otherwise miriad of fleet side validations and checks would fail. this of course is not possible from controller. we don't have info, we would need to detect it from an image name, with image name possibly containing a hash, making it way riskier change than reporting additional header as a fallback

@nkvoll
Copy link
Copy Markdown
Contributor

nkvoll commented Apr 21, 2026

we don't have info, we would need to detect it from an image name, with image name possibly containing a hash

We know the version for ECH, and we have the image tags, so for ECH presumably we could just append -agentless to the current image tag, so it becomes Elastic Agent v{1.2.3-somehash}-agentless etc (where 1.2.3-somehash is any image tag)?

For serverless, I think I can see a problem, as we don't actually have a version there -- the image tag doesn't contain a version, so it is not suitable to be inserted the same way into the user agent string. So, how would we construct a valid user agent string in this scenario?

Is this a fair understanding of the limitations on the agentless side regarding agent versions and the ability to construct compatible user-agent strings without changing the validation?

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 21, 2026

💔 Build Failed

Failed CI Steps

History

cc @michalpristas

@michalpristas
Copy link
Copy Markdown
Contributor Author

yes what you described @nkvoll is correct, ECH is not problematic we have stack version, but Serverless is very unknown, no stack version, and useless tag.

so i see 2 options here maybe.
moving forward with this solution that will add fallback to additional version fields. as @cmacknz brought up, we dont really know if proxy, other telemetry are not relying on current format as well.

handling this from opposite side, and dealing with a problem inside agent itself-if marked as agentless append this info to a header itself.

i'd be in favor additionally on top of this work to introduce a restriction to override user agent from FLEET_HEADERS or --headers as this is user facing and can turn agent useless (no checkin, no enroll will happen)

@cmacknz
Copy link
Copy Markdown
Member

cmacknz commented Apr 21, 2026

handling this from opposite side, and dealing with a problem inside agent itself-if marked as agentless append this info to a header itself.

Agentless has it's own container, so you can change or set the user agent at build time based on the build time stack version in the agent repository can't you? There isn't a need to do this in the controller necessarily.

@cmacknz
Copy link
Copy Markdown
Member

cmacknz commented Apr 21, 2026

If you want to try doing it the current way in serverless and check if it works we can also do that, might be faster than debating about how to do it instead.

I don't have a strong opinion here I was just surprised to see that Fleet Server needed a change as well, and began wondering if anything else might or if this would limit us later in some way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches enhancement New feature or request skip-changelog 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.

5 participants