Skip to content

Conversation

kaanyalti
Copy link
Contributor

@kaanyalti kaanyalti commented Jul 24, 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

Copy link
Contributor

mergify bot commented Jul 24, 2025

This pull request does not have a backport label. Could you fix it @kaanyalti? 🙏
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.

@kaanyalti kaanyalti added the backport-active-all Automated backport with mergify to all the active branches label Jul 25, 2025
@kaanyalti kaanyalti force-pushed the enhancement/5235_insufficient_disk_handling_retry_shows_underlying_error branch from fc9adb5 to 7e18028 Compare July 31, 2025 10:39
@kaanyalti kaanyalti marked this pull request as ready for review July 31, 2025 13:41
@kaanyalti kaanyalti requested a review from a team as a code owner July 31, 2025 13:41
@kaanyalti
Copy link
Contributor Author

/testthis

@kaanyalti
Copy link
Contributor Author

failing due to known flaky test

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Aug 5, 2025
@elasticmachine
Copy link
Collaborator

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

@ycombinator
Copy link
Contributor

ycombinator commented Aug 6, 2025

Hey @kaanyalti, I'm having a bit of a hard time reviewing this PR because of the amount of changes in it. I understand most of them are related to testing — making the code more testable and/or adding more test coverage — and that's a good thing. But I do think these changes have made the code more indirect and harder to review.

Would it be possible to break this PR up into multiple PRs, each one only containing a set of related changes? For example, you're introducing a ProgressReporter type in this PR and tests + code related to it. Would it be possible to extract these changes into their own separate PR, then have a follow up PR that builds upon them with another set of related changes, and so on? Ultimately, it would be ideal if there was a final PR in such a series that introduced ErrInsufficientDiskSpace and only any changes strictly related to that.

@kaanyalti
Copy link
Contributor Author

Hey @kaanyalti, I'm having a bit of a hard time reviewing this PR because of the amount of changes in it. I understand most of them are related to testing — making the code more testable and/or adding more test coverage — and that's a good thing. But I do think these changes have made the code more indirect and harder to review.

Would it be possible to break this PR up into multiple PRs, each one only containing a set of related changes? For example, you're introducing a ProgressReporter type in this PR and tests + code related to it. Would it be possible to extract these changes into their own separate PR, then have a follow up PR that builds upon them with another set of related changes, and so on? Ultimately, it would be ideal if there was a final PR in such a series that introduced ErrInsufficientDiskSpace and only any changes strictly related to that.

Yes I can split the PR, will start posting the smaller PRs right away

@kaanyalti kaanyalti force-pushed the enhancement/5235_insufficient_disk_handling_retry_shows_underlying_error branch from 0aedf85 to 7789dd3 Compare August 11, 2025 12:04
@kaanyalti
Copy link
Contributor Author

After having a discussion with @ycombinator I switched my approach to mocking stdlib functions and simplified the tests. This way I was able to remove much of the complexity from before and reduced the amount of changes. I won't be splitting the PR, however I'd still be happy to do so if it'll help reviewers.

@kaanyalti
Copy link
Contributor Author

Quick update, caught a logic error. IsDiskSpaceError should not be returning true for ErrInsufficientDiskSpace. With the current implementation we can end up chaining multiple ErrInsufficientDiskSpace which is not what we want to do. I will address this tomorrow in the morning in a new commit, but the rest of the PR is still valid and ready for review.

Fixed this logic error in my last commit

@ycombinator @pkoutsovasilis @blakerouse @michalpristas

@elasticmachine
Copy link
Collaborator

@kaanyalti
Copy link
Contributor Author

Adressing ci failure

@kaanyalti
Copy link
Contributor Author

Addressed the ci failure with my last commit

Copy link

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

Left a few minor comments / nits but overall LGTM!

@kaanyalti kaanyalti merged commit 134b3de into elastic:main Sep 8, 2025
23 checks passed
Copy link
Contributor

github-actions bot commented Sep 8, 2025

@Mergifyio backport 8.18 8.19 9.0 9.1

Copy link
Contributor

mergify bot commented Sep 8, 2025

mergify bot pushed a commit that referenced this pull request Sep 8, 2025
…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)

# Conflicts:
#	internal/pkg/agent/application/upgrade/artifact/download/http/downloader_test.go
mergify bot pushed a commit that referenced this pull request Sep 8, 2025
…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 bot pushed a commit that referenced this pull request Sep 8, 2025
…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)

# Conflicts:
#	internal/pkg/agent/application/upgrade/artifact/download/http/downloader_test.go
#	internal/pkg/agent/application/upgrade/upgrade.go
mergify bot pushed a commit that referenced this pull request Sep 8, 2025
…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)
kaanyalti added a commit that referenced this pull request Sep 8, 2025
…ror (#9122) (#9798)

* 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)

Co-authored-by: Kaan Yalti <[email protected]>
kaanyalti added a commit that referenced this pull request Sep 8, 2025
…ror (#9122) (#9800)

* 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)

Co-authored-by: Kaan Yalti <[email protected]>
kaanyalti added a commit that referenced this pull request Sep 8, 2025
…try shows underlying error (#9799)

* Enhancement/5235 insufficient disk handling retry shows underlying error (#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)

# Conflicts:
#	internal/pkg/agent/application/upgrade/artifact/download/http/downloader_test.go
#	internal/pkg/agent/application/upgrade/upgrade.go

* resolved conflicts

---------

Co-authored-by: Kaan Yalti <[email protected]>
kaanyalti added a commit that referenced this pull request Sep 8, 2025
…etry shows underlying error (#9797)

* Enhancement/5235 insufficient disk handling retry shows underlying error (#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)

# Conflicts:
#	internal/pkg/agent/application/upgrade/artifact/download/http/downloader_test.go

* resolved conflicts

---------

Co-authored-by: Kaan Yalti <[email protected]>
intxgo pushed a commit to intxgo/elastic-agent that referenced this pull request Sep 24, 2025
…ror (elastic#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
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 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.

7 participants