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

Fix windows event logs to only starts once #851

Merged
merged 1 commit into from
Sep 15, 2023
Merged

Fix windows event logs to only starts once #851

merged 1 commit into from
Sep 15, 2023

Conversation

okankoAMZ
Copy link
Contributor

@okankoAMZ okankoAMZ commented Sep 13, 2023

Description of the issue

Currently, when the agent start in windows both log agent and telegraf start the windows log event plugin. As a result, the the plugins generates duplicate logs.

Description of changes

Changed the start function of the plugin to be exclusively ran once to avoid any duplicate plugin calls to be started.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Created and ran a units test this can be seen in TestWindowsDuplicateStart
Also ran integration test: this is the instance where there is only logs

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@okankoAMZ okankoAMZ force-pushed the okanko-dev branch 7 times, most recently from 0a0ee6e to f019777 Compare September 15, 2023 18:00
@okankoAMZ okankoAMZ marked this pull request as ready for review September 15, 2023 18:02
@okankoAMZ okankoAMZ requested a review from a team as a code owner September 15, 2023 18:02
plugins/inputs/windows_event_log/windows_event_log_test.go Outdated Show resolved Hide resolved
@@ -25,6 +27,8 @@ const (
forcePullInterval = 250 * time.Millisecond
)

var startOnlyOnce sync.Once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think we might be able to move this into the Plugin struct since the plugin should only be initialized in the init function and should be the same instance wherever it's used.

bhanuba
bhanuba previously approved these changes Sep 15, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 15, 2023

Codecov Report

Patch coverage: 40.32% and project coverage change: +2.83% 🎉

Comparison is base (96d4763) 57.58% compared to head (c9ffed8) 60.42%.
Report is 401 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #851      +/-   ##
==========================================
+ Coverage   57.58%   60.42%   +2.83%     
==========================================
  Files         370      356      -14     
  Lines       17548    18116     +568     
==========================================
+ Hits        10105    10946     +841     
+ Misses       6848     6595     -253     
+ Partials      595      575      -20     
Files Changed Coverage Δ
cfg/aws/credentials.go 2.94% <0.00%> (-0.40%) ⬇️
cfg/commonconfig/commonconfig.go 8.00% <ø> (ø)
...md/amazon-cloudwatch-agent-config-wizard/wizard.go 59.55% <ø> (-8.51%) ⬇️
...amazon-cloudwatch-agent/amazon-cloudwatch-agent.go 2.68% <ø> (ø)
...oudwatch-agent/register_event_logger_notwindows.go 0.00% <ø> (ø)
...-cloudwatch-agent/register_event_logger_windows.go 0.00% <ø> (ø)
cmd/config-translator/translator.go 0.00% <ø> (ø)
cmd/xray-migration/commands_unix.go 42.50% <ø> (ø)
cmd/xray-migration/commands_windows.go 42.50% <ø> (ø)
cmd/xray-migration/xray-migration.go 30.28% <ø> (ø)
... and 22 more

... and 208 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Name: "System Event//Log::",
}
plugin.Events = append(plugin.Events, ec)
require.Equal(t, 0, len(plugin.newEvents), "Start should be ran only once so there should be only 1 new event")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The error log would be misleading.

@jefchien
Copy link
Contributor

Please update the title to better reflect the change. Maybe something like "Fix windows event logs to only starts once"

@okankoAMZ okankoAMZ changed the title Windows Duplication Bug Fix Fix windows event logs to only starts once Sep 15, 2023
@okankoAMZ okankoAMZ merged commit 6ec4040 into main Sep 15, 2023
216 of 235 checks passed
@okankoAMZ okankoAMZ deleted the okanko-dev branch September 15, 2023 20:54
@okankoAMZ okankoAMZ restored the okanko-dev branch September 15, 2023 20:54
@okankoAMZ okankoAMZ deleted the okanko-dev branch September 15, 2023 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants