-
Notifications
You must be signed in to change notification settings - Fork 136
Fix package reporting implementation #1670
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
Open
lrafeei
wants to merge
55
commits into
main
Choose a base branch
from
loaded-modules-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
89203b0
Change loaded modules to go one at a time
lrafeei 11aaece
Merge branch 'main' into loaded-modules-fix
lrafeei 2454063
Send individual plugin inside list
lrafeei b93898c
Reset plugin generator for reconnect
lrafeei c99e785
[MegaLinter] Apply linters fixes
lrafeei dd0cca6
Clarify comment
lrafeei bcbfad4
Merge branch 'main' into loaded-modules-fix
lrafeei 2a32b43
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8cfbb0d
Merge branch 'main' into loaded-modules-fix
mergify[bot] 28993c2
Revert to original logic (with bug fixes)
lrafeei c2031f1
[MegaLinter] Apply linters fixes
lrafeei 515b5b7
Merge branch 'main' into loaded-modules-fix
mergify[bot] c6be361
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8c476a0
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8d38018
Tweak logic for package reporting
lrafeei d4d0262
Merge branch 'main' into loaded-modules-fix
mergify[bot] ed8ad69
Merge branch 'main' into loaded-modules-fix
mergify[bot] 53af784
Remove time constraint completely for first iteration
lrafeei 89594b4
[MegaLinter] Apply linters fixes
lrafeei 7265f2f
Merge branch 'main' into loaded-modules-fix
mergify[bot] 4968e64
Merge branch 'main' into loaded-modules-fix
mergify[bot] 3808b05
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8cc9f6c
Merge branch 'main' into loaded-modules-fix
mergify[bot] d06ae42
Merge branch 'main' into loaded-modules-fix
mergify[bot] c4f906c
Merge branch 'main' into loaded-modules-fix
mergify[bot] 133c954
Merge branch 'main' into loaded-modules-fix
mergify[bot] 7628eb2
Merge branch 'main' into loaded-modules-fix
mergify[bot] ad8bccc
Merge branch 'main' into loaded-modules-fix
mergify[bot] 78f0512
Merge branch 'main' into loaded-modules-fix
mergify[bot] 63f579c
Merge branch 'main' into loaded-modules-fix
mergify[bot] 2c2a62e
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8961d8c
Merge branch 'main' into loaded-modules-fix
mergify[bot] 467cc52
Merge branch 'main' into loaded-modules-fix
mergify[bot] e6f1559
Merge branch 'main' into loaded-modules-fix
mergify[bot] d6aecbe
Merge branch 'main' into loaded-modules-fix
mergify[bot] 7b7cf99
Merge branch 'main' into loaded-modules-fix
mergify[bot] 935f0c5
Merge branch 'main' into loaded-modules-fix
mergify[bot] 1b90863
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8f96bdd
Merge branch 'main' into loaded-modules-fix
mergify[bot] 86dca9b
Merge branch 'main' into loaded-modules-fix
mergify[bot] d70fbcd
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8e73e0b
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8e6668b
Merge branch 'main' into loaded-modules-fix
mergify[bot] d83c9f3
Merge branch 'main' into loaded-modules-fix
mergify[bot] 786ba5f
Merge branch 'main' into loaded-modules-fix
mergify[bot] 6edebee
Merge branch 'main' into loaded-modules-fix
mergify[bot] 64273a1
Merge branch 'main' into loaded-modules-fix
mergify[bot] 406ba4e
Merge branch 'main' into loaded-modules-fix
mergify[bot] 66f5ccc
Merge branch 'main' into loaded-modules-fix
mergify[bot] 8fdd467
Merge branch 'main' into loaded-modules-fix
mergify[bot] 2e250e5
Merge branch 'main' into loaded-modules-fix
mergify[bot] 81de885
Merge branch 'main' into loaded-modules-fix
mergify[bot] aa8ee8a
Merge branch 'main' into loaded-modules-fix
mergify[bot] 23415ab
Merge branch 'main' into loaded-modules-fix
mergify[bot] bf214f6
Merge branch 'main' into loaded-modules-fix
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ | |
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
| MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST = 2.0 | ||
| MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST = 3.0 | ||
|
|
||
|
|
||
| class Application: | ||
|
|
@@ -105,8 +105,6 @@ def __init__(self, app_name, linked_applications=None): | |
| self._data_samplers_lock = threading.Lock() | ||
| self._data_samplers_started = False | ||
|
|
||
| self._remaining_plugins = True | ||
|
|
||
| self._agent_control_health_thread = threading.Thread( | ||
| name="Agent-Control-Health-Session-Thread", target=agent_control_healthcheck_loop | ||
| ) | ||
|
|
@@ -1284,27 +1282,20 @@ def harvest(self, shutdown=False, flexible=False): | |
| data_sampler.name, | ||
| ) | ||
|
|
||
| # Send environment plugin list | ||
|
|
||
| stopwatch_start = time.time() | ||
| while ( | ||
| configuration | ||
| and configuration.package_reporting.enabled | ||
| and self._remaining_plugins | ||
| and ((time.time() - stopwatch_start) < MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST) | ||
| ): | ||
| try: | ||
| module_info = next(self.plugins) | ||
| self.modules.append(module_info) | ||
| except StopIteration: | ||
| self._remaining_plugins = False | ||
|
|
||
| # Send the accumulated environment plugin list if not empty | ||
| if self.modules: | ||
| self._active_session.send_loaded_modules(self.modules) | ||
|
|
||
| # Reset the modules list every harvest cycle | ||
| self.modules = [] | ||
| # Send environment plugin. | ||
| # If a module takes less than 0.5 seconds to load, | ||
| # continue to upload. Do this until we reach 5.0 | ||
| # seconds or until a module has taken more than | ||
| # 0.5 seconds to upload. Then, wait for the next | ||
| # harvest cycle before resuming. | ||
| if self.plugins and self.configuration and self.configuration.package_reporting.enabled: | ||
| start = time.time() | ||
| while (time.time() - start) < MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| try: | ||
| self._active_session.send_loaded_modules([next(self.plugins)]) | ||
| except StopIteration: | ||
| self.plugins = False | ||
| break | ||
|
|
||
| # Add a metric we can use to track how many harvest | ||
| # periods have occurred. | ||
|
|
@@ -1741,19 +1732,13 @@ def internal_agent_shutdown(self, restart=False): | |
|
|
||
| self.stop_data_samplers() | ||
|
|
||
| # Finishes collecting environment plugin information | ||
| # if this has not been completed during harvest | ||
| # lifetime of the application | ||
|
|
||
| while self.configuration and self.configuration.package_reporting.enabled and self._remaining_plugins: | ||
| try: | ||
| module_info = next(self.plugins) | ||
| self.modules.append(module_info) | ||
| except StopIteration: | ||
| self._remaining_plugins = False | ||
| if self.modules: | ||
| self._active_session.send_loaded_modules(self.modules) | ||
| self.modules = [] | ||
| # Finishes collecting environment plugin information if this has | ||
| # not been completed during harvest lifetime of the application. | ||
| if self.plugins and self.configuration and self.configuration.package_reporting.enabled: | ||
| # Anything that was left in the plugins | ||
| # generator will be resolved here. | ||
| plugins_list = list(self.plugins) | ||
| self._active_session.send_loaded_modules(plugins_list) | ||
|
|
||
| # Now shutdown the actual agent session. | ||
|
|
||
|
|
@@ -1776,6 +1761,9 @@ def internal_agent_shutdown(self, restart=False): | |
| # as shutdown. | ||
|
|
||
| if restart: | ||
| # Reset package/module generator | ||
| self.plugins = plugins() | ||
|
|
||
| self._agent_restart += 1 | ||
| self.activate_session() | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.