-
Notifications
You must be signed in to change notification settings - Fork 246
Enhancement/5235 insufficient disk handling retry shows underlying error #9122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kaanyalti
merged 26 commits into
elastic:main
from
kaanyalti:enhancement/5235_insufficient_disk_handling_retry_shows_underlying_error
Sep 8, 2025
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
0c6f048
enhancement(5235): added stdlib wrapper functions for testability
f1c546e
enhancement(5235): using stdlib wrappers in http downloader
ddfa584
enhancement(5235): using stdlib wrappers in fs downloader
5c25064
enhancement(5235): added stlib mocker utils
312b98b
enhancement(5235): wrapping errors in http downloader
ba56ecd
enhancement(5235): wrapping errors in fs downloader
ddbf6a3
enhancement(5235): added disk space error and relevant tests
4f19b00
enhancement(5235): added diskspace error check in http downloader bef…
9b0f555
enhancement(5235): added http downloader test for disk space error
65402d5
enhancement(5235): added fs downloader disk space error tests
f93c888
enhancement(5235): replaced errors.New with fmt.Errorf in step_download
a2a0d89
enhancement(5235): wrapping error in backoff.Permanent in download wi…
da64ead
enhancement(5235): added insufficient disk space test case in step do…
3191fa1
enhancement(5235): added archive helper functions in upgrade tests
685de17
enhancement(5235): added deferred error handler in upgrade function t…
621e9a6
enhancement(5235): added upgrader test for download error handling
74b4996
enhancement(5235): remove stdlib wrappers and mock utils
ceef034
enhancement(5235): add stdlib funcs in http downloader struct, update…
11a20a8
enhancement(5235): add stdlib funcs in fs downloader struct and updat…
e9ea9f2
enhancement(5235): separated artifact downloader from upgrader, updat…
6982b9d
enhancement(5235): added artifact downloader interface, updated SetCl…
2df4465
enhancement(5235): fix fs downloader tests
b967b89
enhancement(5235): added comment in upgrader struct
1b7cee8
enhancement(5235): refactored upgrade test for readabiltiy
51cbb2e
enhancement(5235): updated disk space error check function to return …
c638322
enhancement(5235): fixed download with retries error handling test case
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
internal/pkg/agent/application/upgrade/artifact/download/errors/disk_space_errors.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
| // you may not use this file except in compliance with the Elastic License 2.0. | ||
|
|
||
| package errors | ||
|
|
||
| import "errors" | ||
|
|
||
| var ErrInsufficientDiskSpace = errors.New("insufficient disk space") | ||
|
|
||
| func IsDiskSpaceError(err error) bool { | ||
| for _, osErr := range OS_DiskSpaceErrors { | ||
| if errors.Is(err, osErr) { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| return false | ||
| } |
14 changes: 14 additions & 0 deletions
14
internal/pkg/agent/application/upgrade/artifact/download/errors/disk_space_errors_other.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
| // you may not use this file except in compliance with the Elastic License 2.0. | ||
|
|
||
| //go:build !windows | ||
|
|
||
| package errors | ||
|
|
||
| import "syscall" | ||
|
|
||
| var OS_DiskSpaceErrors = []error{ | ||
| syscall.ENOSPC, | ||
| syscall.EDQUOT, | ||
| } |
34 changes: 34 additions & 0 deletions
34
internal/pkg/agent/application/upgrade/artifact/download/errors/disk_space_errors_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
| // you may not use this file except in compliance with the Elastic License 2.0. | ||
|
|
||
| package errors | ||
|
|
||
| import ( | ||
| goerrors "errors" | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| agentErrors "github.com/elastic/elastic-agent/internal/pkg/agent/errors" | ||
| ) | ||
|
|
||
| func TestIsDiskSpaceError(t *testing.T) { | ||
| for _, err := range OS_DiskSpaceErrors { | ||
| testCases := map[string]struct { | ||
| err error | ||
| want bool | ||
| }{ | ||
| "os_error": {err: err, want: true}, | ||
| "wrapped_os_error": {err: fmt.Errorf("wrapped: %w", err), want: true}, | ||
| "joined_error": {err: goerrors.Join(err, goerrors.New("test")), want: true}, | ||
| "new_error": {err: agentErrors.New(err, fmt.Errorf("test")), want: false}, | ||
| } | ||
| for name, tc := range testCases { | ||
| t.Run(fmt.Sprintf("%s_%s", err.Error(), name), func(t *testing.T) { | ||
| require.Equal(t, tc.want, IsDiskSpaceError(tc.err)) | ||
| }) | ||
| } | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
internal/pkg/agent/application/upgrade/artifact/download/errors/disk_space_errors_windows.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
| // you may not use this file except in compliance with the Elastic License 2.0. | ||
|
|
||
| //go:build windows | ||
|
|
||
| package errors | ||
|
|
||
| import "golang.org/x/sys/windows" | ||
|
|
||
| var OS_DiskSpaceErrors = []error{ | ||
| windows.ERROR_DISK_FULL, | ||
| windows.ERROR_HANDLE_DISK_FULL, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.