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.13](backport #4846) [windows] if elastic-agent run fails, log error to Application EventLog #4918

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/cmd/run.go
#	internal/pkg/agent/install/install_windows.go
#	internal/pkg/agent/install/uninstall.go
@mergify mergify bot added the backport label Jun 13, 2024
@mergify mergify bot requested a review from a team as a code owner June 13, 2024 00:48
@mergify mergify bot added the conflicts There is a conflict in the backported pull request label Jun 13, 2024
@mergify mergify bot requested review from michalpristas and pchila and removed request for a team June 13, 2024 00:48
Copy link
Contributor Author

mergify bot commented Jun 13, 2024

Cherry-pick of 6c20730 has failed:

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

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
	new file:   internal/pkg/agent/cmd/run_unix.go
	new file:   internal/pkg/agent/cmd/run_windows.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   internal/pkg/agent/cmd/run.go
	both modified:   internal/pkg/agent/install/install_windows.go
	both modified:   internal/pkg/agent/install/uninstall.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

@pierrehilbert
Copy link
Contributor

We are not planning to release new 8.13 binaries so I'm closing this one.

@mergify mergify bot deleted the mergify/bp/8.13/pr-4846 branch June 13, 2024 07:07
@leehinman leehinman restored the mergify/bp/8.13/pr-4846 branch June 13, 2024 14:45
@leehinman leehinman reopened this Jun 13, 2024
@leehinman leehinman force-pushed the mergify/bp/8.13/pr-4846 branch from 1af0fe8 to 6283cc7 Compare June 13, 2024 18:09
Copy link

Quality Gate failed Quality Gate failed

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

See analysis details on SonarQube

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? 🙏

@jlind23
Copy link
Contributor

jlind23 commented Jun 17, 2024

@leehinman unsure why you reopened this but no more 8.13 patch release will be made.

@jlind23 jlind23 closed this Jun 17, 2024
@mergify mergify bot deleted the mergify/bp/8.13/pr-4846 branch June 17, 2024 07:35
@pierrehilbert pierrehilbert restored the mergify/bp/8.13/pr-4846 branch June 17, 2024 12:15
@pierrehilbert pierrehilbert reopened this Jun 17, 2024
@leehinman leehinman merged commit 9e138bd into 8.13 Jun 18, 2024
13 of 14 checks passed
@leehinman leehinman deleted the mergify/bp/8.13/pr-4846 branch June 18, 2024 15:22
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.

3 participants