Skip to content

Enhancement/5235 wrap errors when marking upgrade#9366

Merged
kaanyalti merged 10 commits intoelastic:mainfrom
kaanyalti:enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade
Sep 15, 2025
Merged

Enhancement/5235 wrap errors when marking upgrade#9366
kaanyalti merged 10 commits intoelastic:mainfrom
kaanyalti:enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade

Conversation

@kaanyalti
Copy link
Copy Markdown

@kaanyalti kaanyalti commented Aug 14, 2025

PR 4/6

  • Enhancement

What does this PR do?

  • Modifies the mark upgrade step to wrap errors so that the errors are propagated correctly.
  • Adds relevant tests, asserts that errors get propagated up the call chain.

Why is it important?

Errors are not propagated up the call chain in some instances, this prevents checking for error types.

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

How to test this PR locally

Run the ugprade_test and step_unpack_test tests

Related issues

@kaanyalti kaanyalti requested a review from a team as a code owner August 14, 2025 13:25
@kaanyalti kaanyalti added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog labels Aug 14, 2025
@kaanyalti kaanyalti added the backport-active-all Automated backport with mergify to all the active branches label Aug 14, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@kaanyalti kaanyalti force-pushed the enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade branch from cb86100 to 269f22c Compare August 14, 2025 16:45
Comment thread internal/pkg/agent/application/upgrade/common/stdlib_wrappers.go Outdated
@kaanyalti kaanyalti force-pushed the enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade branch 2 times, most recently from df9dd27 to 3c97eb6 Compare August 15, 2025 14:01
@kaanyalti
Copy link
Copy Markdown
Author

kaanyalti commented Aug 15, 2025

The changelog fragment relevant to this PR is added in #9122
The changelog will be in a separate PR

@kaanyalti
Copy link
Copy Markdown
Author

@blakerouse @michalpristas the pr is ready for review

Comment thread internal/pkg/agent/application/upgrade/upgrade.go Outdated
@kaanyalti kaanyalti marked this pull request as draft September 2, 2025 13:05
@kaanyalti kaanyalti force-pushed the enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade branch 3 times, most recently from 3a0efec to 689e85d Compare September 8, 2025 15:41
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Sep 9, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade upstream/enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade
git merge upstream/main
git push upstream enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade

@kaanyalti kaanyalti changed the title Enhancement/5235 handle insufficient disk space when marking upgrade Enhancement/5235 wrap errors when marking upgrade Sep 9, 2025
@kaanyalti kaanyalti force-pushed the enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade branch from 689e85d to 1d7ff97 Compare September 12, 2025 17:20
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @kaanyalti

Kaan Yalti added 3 commits September 13, 2025 17:31
…nt types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function
…nstall in upgrader, updated error handling tests to use these abstractions
@kaanyalti kaanyalti force-pushed the enhancement/5235_handle_insufficient_disk_space_when_marking_upgrade branch from 1d7ff97 to bbca4d9 Compare September 13, 2025 14:32
@elastic-sonarqube
Copy link
Copy Markdown

@kaanyalti kaanyalti marked this pull request as ready for review September 14, 2025 20:56
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 testing.

@kaanyalti
Copy link
Copy Markdown
Author

Looks good.

Nice testing.

Thank you!

@kaanyalti kaanyalti merged commit 2e4e777 into elastic:main Sep 15, 2025
23 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@Mergifyio backport 8.18 8.19 9.0 9.1

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Sep 15, 2025

backport 8.18 8.19 9.0 9.1

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Sep 15, 2025
* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink

(cherry picked from commit 2e4e777)

# Conflicts:
#	internal/pkg/agent/application/upgrade/step_mark.go
#	internal/pkg/agent/application/upgrade/step_mark_test.go
#	internal/pkg/agent/application/upgrade/upgrade.go
#	internal/pkg/agent/application/upgrade/upgrade_test.go
mergify bot pushed a commit that referenced this pull request Sep 15, 2025
* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink

(cherry picked from commit 2e4e777)

# Conflicts:
#	internal/pkg/agent/application/upgrade/step_mark.go
#	internal/pkg/agent/application/upgrade/step_mark_test.go
mergify bot pushed a commit that referenced this pull request Sep 15, 2025
* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink

(cherry picked from commit 2e4e777)
mergify bot pushed a commit that referenced this pull request Sep 15, 2025
* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink

(cherry picked from commit 2e4e777)
kaanyalti pushed a commit that referenced this pull request Sep 15, 2025
* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink

(cherry picked from commit 2e4e777)

Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co>
kaanyalti pushed a commit that referenced this pull request Sep 15, 2025
* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink

(cherry picked from commit 2e4e777)

Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co>
kaanyalti pushed a commit that referenced this pull request Sep 15, 2025
…rade (#9966)

* Enhancement/5235 wrap errors when marking upgrade (#9366)

* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink

(cherry picked from commit 2e4e777)

# Conflicts:
#	internal/pkg/agent/application/upgrade/step_mark.go
#	internal/pkg/agent/application/upgrade/step_mark_test.go

* resolved conflicts

* removed unnecessary tests

* removed unused param

---------

Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co>
v1v added a commit that referenced this pull request Sep 16, 2025
* upstream: (26 commits)
  fix: ensure EDOT subprocess shuts down gracefully on agent termination (#9886)
  [main][Automation] Update versions (#9976)
  Add Collector reference docs and automation (#9953)
  [beatreceivers] Integrate beatsauthextension (#9257)
  [main][Automation] Update versions (#9941)
  Update OTel components to v0.132.0/v1.38.0 (#9954)
  Enhancement/5235 wrap errors when marking upgrade (#9366)
  Mount Go build cache into crossbuild container (#9094)
  Liveness agent state (#9673)
  [main][Automation] Bump VM Image version to 1757725254 (#9942)
  Enhancement/5235 correctly wrap errors from copyActionDir and copyRunDirectory (#9349)
  [main][Automation] Update elastic/beats to afc53c0479ac (#9874)
  Add -coverpkg option when running unit test to calculate coverage across packages (#9913)
  Cache binaries downloaded for packaging locally (#9133)
  [main][Automation] Update versions (#9897)
  Disable flaky test TestBeatsReceiverLogs (#9891)
  Allow overriding AGENT_PACKAGE_VERSION and MANIFEST_URL when USE_PACKAGE_VERSION=true (#9864)
  add ingest-docs team as CODEOWNERS for release notes and docset.yml (#9865)
  fix: correct spelling of 'output' in various templates and monitoring code (#9827)
  k8s: Add comment around hostUsers for Universal Profiling deployments (#9847)
  ...
kaanyalti pushed a commit that referenced this pull request Sep 18, 2025
…rade (#9965)

* Enhancement/5235 wrap errors when marking upgrade (#9366)

* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink

(cherry picked from commit 2e4e777)

# Conflicts:
#	internal/pkg/agent/application/upgrade/step_mark.go
#	internal/pkg/agent/application/upgrade/step_mark_test.go
#	internal/pkg/agent/application/upgrade/upgrade.go
#	internal/pkg/agent/application/upgrade/upgrade_test.go

* resolve conflicts

* removed unused tests

* removed unused var

---------

Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co>
intxgo pushed a commit to intxgo/elastic-agent that referenced this pull request Sep 24, 2025
* enhancement(5235): added markUpgradeFunc to abstract markUpgrade

* enhancement(5235): using markUpgradeFunc in Upgrade function

* enhancement(5235): wrapping writeFile errors in markUpgrade

enhancement(5235): added goerrors in step_mark

* enhancement(5235): using writeFile wrapper in markUpgrade

* enhancement(5235): added tests mark upgrade tests

enhancement(5235): updated step mark test to mock writeFile

* enhancement(5235): updated markUpgrade function so that it can be tested, jecting dependencies. updated relevant tests

* enhancement(5235): updated use of markUpgrade in rollback and rollback tests

* enhancement(5235): abstracted markupgrade from upgrader, added relevant types and updated the upgrader struct. added tests case for mark upgrade error handling in the upgrade function

* enhancement(5235): added abstractions for changesymlink and rollbackInstall in upgrader, updated error handling tests to use these abstractions

* enhancement(5235): added error handling test for changesymlink
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.

4 participants