Skip to content

Fix download_rate as string on checkin handling#5176

Merged
michel-laterman merged 9 commits intoelastic:mainfrom
michel-laterman:fix/download-rate-string
Jul 29, 2025
Merged

Fix download_rate as string on checkin handling#5176
michel-laterman merged 9 commits intoelastic:mainfrom
michel-laterman:fix/download-rate-string

Conversation

@michel-laterman
Copy link
Copy Markdown
Contributor

What is the problem this PR solves?

Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

How does this PR solve the problem?

Fleet-server will parse the string into a float representing bps and re-marshal the metadata.

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.

Checklist

  • 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

Related issues

@michel-laterman michel-laterman requested a review from a team as a code owner July 24, 2025 16:05
@michel-laterman michel-laterman added bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-active-all Automated backport with mergify to all the active branches labels Jul 24, 2025
@prodsecmachine
Copy link
Copy Markdown

prodsecmachine commented Jul 24, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Comment thread internal/pkg/api/handleCheckin.go Outdated
@michel-laterman
Copy link
Copy Markdown
Contributor Author

Marking this back as a draft, I wasn't confident in the fix and have added an e2e test that shows it's still failing

@michel-laterman michel-laterman marked this pull request as draft July 24, 2025 19:42
@michel-laterman michel-laterman marked this pull request as ready for review July 24, 2025 21:50
@cmacknz
Copy link
Copy Markdown
Member

cmacknz commented Jul 28, 2025

Current example of this error in a support case:

Error while parsing document for index [.fleet-agents-7]: [1:3875] failed to parse field [upgrade_details.metadata.download_rate] of type [double] in document with id '1046bb63-c8aa-4ea2-8690-9bc2bd378af1'. Preview of field's value: '320.822575kBps'

Comment thread internal/pkg/api/metadata_test.go
@michel-laterman
Copy link
Copy Markdown
Contributor Author

buildkite test this

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.

Looks good.

Nice coverage on the tests.

@michel-laterman michel-laterman merged commit c94d8d9 into elastic:main Jul 29, 2025
9 checks passed
@michel-laterman michel-laterman deleted the fix/download-rate-string branch July 29, 2025 23:20
@github-actions
Copy link
Copy Markdown
Contributor

@Mergifyio backport 8.17 8.18 8.19 9.0 9.1

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Jul 29, 2025

backport 8.17 8.18 8.19 9.0 9.1

✅ Backports have been created

Details
mergify Bot pushed a commit that referenced this pull request Jul 29, 2025
Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)

# Conflicts:
#	testing/e2e/scaffold/scaffold.go
mergify Bot pushed a commit that referenced this pull request Jul 29, 2025
Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)

# Conflicts:
#	testing/e2e/scaffold/scaffold.go
mergify Bot pushed a commit that referenced this pull request Jul 29, 2025
Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)
mergify Bot pushed a commit that referenced this pull request Jul 29, 2025
Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)

# Conflicts:
#	testing/e2e/scaffold/scaffold.go
mergify Bot pushed a commit that referenced this pull request Jul 29, 2025
Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)
michel-laterman added a commit that referenced this pull request Jul 30, 2025
…#5191)

* Fix download_rate as string on checkin handling (#5176)

Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)

# Conflicts:
#	testing/e2e/scaffold/scaffold.go

* Fix merge

---------

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Co-authored-by: michel-laterman <michel.laterman@elastic.co>
michel-laterman added a commit that referenced this pull request Jul 30, 2025
Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
michel-laterman added a commit that referenced this pull request Jul 30, 2025
#5188)

* Fix download_rate as string on checkin handling (#5176)

Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)

# Conflicts:
#	testing/e2e/scaffold/scaffold.go

* Fix merge

* Add upgrade response body for errors

---------

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Co-authored-by: michel-laterman <michel.laterman@elastic.co>
michel-laterman added a commit that referenced this pull request Jul 30, 2025
#5189)

* Fix download_rate as string on checkin handling (#5176)

Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)

# Conflicts:
#	testing/e2e/scaffold/scaffold.go

* Fix merge

* Add upgrade response body for errors

---------

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Co-authored-by: michel-laterman <michel.laterman@elastic.co>
}
if err := details.Metadata.FromUpgradeMetadataDownloading(upgradeDetails); err != nil {
vSpan.End()
return fmt.Errorf("%w %s: unable to repack metadata: %w", ErrInvalidUpgradeMetadata, UpgradeDetailsStateUPGDOWNLOADING, err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the late review, but the root cause one layer up from this is we consider parsing upgrade details to be a fatal error and it isn't. Upgrade details are nice to have.

michel-laterman added a commit that referenced this pull request Aug 7, 2025
#5190)

* Fix download_rate as string on checkin handling (#5176)

Fix fleet-server to properly handle when an agent sends the upgrade downloading detail's download_rate as a string instead of float64.

(cherry picked from commit c94d8d9)

* Add upgrade response body for errors

* change upgrade version

---------

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Co-authored-by: michel-laterman <michel.laterman@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

4 participants