Skip to content

Conversation

@straistaru
Copy link
Contributor

@straistaru straistaru commented Sep 30, 2025

What does this PR do?

Avoid logging a nil error for provider exits.

Why is it important?

Some providers intentionally stop and return a nil error; they already log the exit reason internally. The previous log formatted a nil error into "%!s()", which can be confusing (e.g. provider "env" failed to run (will retry in 30s): %!s()). This change removes the incorrect formatting and only includes the error text when non-nil.

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.

Related issues

@mergify
Copy link
Contributor

mergify bot commented Sep 30, 2025

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

@straistaru straistaru 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 Oct 2, 2025
@straistaru straistaru marked this pull request as ready for review October 6, 2025 06:43
@straistaru straistaru requested a review from a team as a code owner October 6, 2025 06:43
@elasticmachine
Copy link
Contributor

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

@swiatekm
Copy link
Contributor

swiatekm commented Oct 6, 2025

If the provider already logged the reason internally, do we need to emit any more log lines? The line you're adding seems confusing as well. If we want to log something here, I'd drop the with a nil error, as that's an implementation detail.

@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 6, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @straistaru

@straistaru straistaru merged commit 0a5c2a4 into elastic:main Oct 7, 2025
21 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2025

@Mergifyio backport 8.18 8.19 9.0 9.1 9.2

@mergify
Copy link
Contributor

mergify bot commented Oct 7, 2025

backport 8.18 8.19 9.0 9.1 9.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Oct 7, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)
mergify bot pushed a commit that referenced this pull request Oct 7, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)
mergify bot pushed a commit that referenced this pull request Oct 7, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)
mergify bot pushed a commit that referenced this pull request Oct 7, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)
mergify bot pushed a commit that referenced this pull request Oct 7, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)
straistaru added a commit that referenced this pull request Oct 8, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)

Co-authored-by: Stefan Traistaru <[email protected]>
straistaru added a commit that referenced this pull request Oct 8, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)

Co-authored-by: Stefan Traistaru <[email protected]>
straistaru added a commit that referenced this pull request Oct 8, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)

Co-authored-by: Stefan Traistaru <[email protected]>
straistaru added a commit that referenced this pull request Oct 8, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)

Co-authored-by: Stefan Traistaru <[email protected]>
straistaru added a commit that referenced this pull request Oct 8, 2025
* Fix error logging for provider failures

* Add changelog fragment

* Omit nil error detail from logs

(cherry picked from commit 0a5c2a4)

Co-authored-by: Stefan Traistaru <[email protected]>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elastic Agent: env provider fails with unhelpful log message %!s(<nil>)

4 participants