Skip to content
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

[8.14](backport #4846) [windows] if elastic-agent run fails, log error to Application EventLog #4919

Merged
merged 3 commits into from
Jun 18, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jun 13, 2024

What does this PR do?

On Windows if the run command fails, then the error message will be sent to the Application EventLog. Other OSes do not require this since they capture stderr from processes that run as services, Windows does not.

This is only for the run command because the other commands should be run from the CLI, where the error is already published on stderr.

Why is it important?

If any error happens before the elastic-agent internal logging is setup and the run command exits while running as a Windows service, the error is lost. Without this error it is very difficult to determine why elastic-agent run is failing.

Checklist

  • 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

How to test this PR locally

  1. Install elastic-agent with -a flag pointing to CA certificates on the local filesystem
  2. Stop elastic-agent service
  3. Rename the CA certificates
  4. Try to start elastic-agent service
  5. Verify that Application EventLog has event showing that elastic-agent failed and what the error was.

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

Screenshots

Screenshot 2024-06-04 at 10 19 55
This is an automatic backport of pull request #4846 done by [Mergify](https://mergify.com).

…tLog (#4846)

* windows if `elastic-agent run` fails, log error to eventviewer

* linter fixes

* updated fragment and skip cleaning up registry

(cherry picked from commit 6c20730)

# Conflicts:
#	internal/pkg/agent/install/install_windows.go
@mergify mergify bot requested a review from a team as a code owner June 13, 2024 07:14
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Jun 13, 2024
@mergify mergify bot requested review from andrzej-stencel and pchila and removed request for a team June 13, 2024 07:14
Copy link
Contributor Author

mergify bot commented Jun 13, 2024

Cherry-pick of 6c20730 has failed:

On branch mergify/bp/8.14/pr-4846
Your branch is up to date with 'origin/8.14'.

You are currently cherry-picking commit 6c20730d5c.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   changelog/fragments/1717516439-Capture-early-errors-on-Windows.yaml
	modified:   internal/pkg/agent/cmd/run.go
	new file:   internal/pkg/agent/cmd/run_unix.go
	new file:   internal/pkg/agent/cmd/run_windows.go
	modified:   internal/pkg/agent/install/uninstall.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   internal/pkg/agent/install/install_windows.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link
Contributor Author

mergify bot commented Jun 17, 2024

This pull request has not been merged yet. Could you please review and merge it @leehinman? 🙏

Copy link

Quality Gate failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

@leehinman leehinman merged commit fce6ac7 into 8.14 Jun 18, 2024
12 of 13 checks passed
@leehinman leehinman deleted the mergify/bp/8.14/pr-4846 branch June 18, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport conflicts There is a conflict in the backported pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants