Skip to content

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 8, 2025

PR 1/6

  • Enhancement

What does this PR do?

  • Updates the upgrade downloaders to return insufficient disk error
  • Introduces custom error for insufficient disk space
  • Insufficient disk errors stops download retries

Why is it important?

  • The current error is less user friendly and includes unnecessary information
  • Disk errors get replaced by context deadline error when retries time out, this pr fixes this for disk space errors.

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, unless user relies on specific error messages in upgrade details in the status output.

How to test this PR locally

  • Build for windows, mac, linux
  • Install agent (managed and standalone)
  • Fill up disk until there is approximately 200mb left
  • Trigger upgrade
    • From fleet
    • Cli with remote url and file
  • Validate the upgrade detail error message shows insufficient disk error message both in the status output and on fleet ui.

Related issues


This is an automatic backport of pull request #9122 done by [Mergify](https://mergify.com).

…ror (#9122)

* enhancement(5235): added stdlib wrapper functions for testability

enhancement(5235): added comment in stdlib wrappers

enhancement(5235): added license header in stdlib wrappers

* enhancement(5235): using stdlib wrappers in http downloader

enhancement(5235): added comments explaining why stdlib wrappers are used in http downloader

* enhancement(5235): using stdlib wrappers in fs downloader

enhancement(5235): added comments in fs downloader explaining why stdlib wrappers are used

* enhancement(5235): added stlib mocker utils

enhancement(5235): ran mage update

enhancement(5235): updated the stdlib wrapper mocker to use map instead of switch

* enhancement(5235): wrapping errors in http downloader

* enhancement(5235): wrapping errors in fs downloader

* enhancement(5235): added disk space error and relevant tests

* enhancement(5235): added diskspace error check in http downloader before calling reporter

enhancement(5235): added comment in http downloader explaining why diskpace error chec is called before the download progress reporter call

enhancement(5235): instead of overwriting the error we are using a copy to report. the returned error is now wrapped in the htttp downloadfile function

* enhancement(5235): added http downloader test for disk space error

enhancement(5235): using stdlib mocker in http donwloader test

enhancement(5235): removed unnecessary fmt

enhancement(5235): added state message assertion in http downloader test

enhancement(5235): using common stdlib mock util in http downloader test

enhancement(5235): updated http downloader test

* enhancement(5235): added fs downloader disk space error tests

enhancement(5235): using common stdlib mock util in fs downloader

* enhancement(5235): replaced errors.New with fmt.Errorf in step_download

* enhancement(5235): wrapping error in backoff.Permanent in download with retries if the error is a diskspace error.

enhancement(5235): added downloaderrors import in step download

* enhancement(5235): added insufficient disk space test case in step download tests

* enhancement(5235): added archive helper functions in upgrade tests

enhancement(5235): added comments for the archive helper functions

enhancement(5235): added archive helper functions in upgrade tests

enhancement(5235): added comments for the archive helper functions

enhancement(5235): buildArchiveFiles archive helper function

* enhancement(5235): added deferred error handler in upgrade function to add insufficient disk space error into the error chain

enhancement(5235): added comments for the deferred error handler in upgrade func

* enhancement(5235): added upgrader test for download error handling

enhancement(5235): updated the download error handling test, added additional assertions in mocked functions to make sure that they are called

enhancement(5235): added comments explaining steps taken in upgrader test

enhancement(5235): using common stdlib mock util in upgrade test

enhancement(5235): removed error string comparison

* enhancement(5235):  remove stdlib wrappers and mock utils

* enhancement(5235): add stdlib funcs in http downloader struct, update http downloader tests

* enhancement(5235): add stdlib funcs in fs downloader struct and update tests

* enhancement(5235): separated artifact downloader from upgrader, updated relevant tests

* enhancement(5235): added artifact downloader interface, updated SetClient function to set downloader fleet server uri. Updated upgrader tests

* enhancement(5235): fix fs downloader tests

* enhancement(5235): added comment in upgrader struct

* enhancement(5235): refactored upgrade test for readabiltiy

* enhancement(5235): updated disk space error check function to return false for ErrInsufficientDiskSpace

* enhancement(5235): fixed download with retries error handling test case

(cherry picked from commit 134b3de)
@mergify mergify bot added the backport label Sep 8, 2025
@mergify mergify bot requested a review from a team as a code owner September 8, 2025 13:54
@mergify mergify bot added the backport label Sep 8, 2025
@mergify mergify bot removed the request for review from a team September 8, 2025 13:54
@github-actions github-actions bot added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog labels Sep 8, 2025
@elasticmachine
Copy link
Collaborator

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

Copy link

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

cc @kaanyalti

@kaanyalti kaanyalti merged commit cc67043 into 8.19 Sep 8, 2025
22 checks passed
@kaanyalti kaanyalti deleted the mergify/bp/8.19/pr-9122 branch September 8, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants