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

check agent cg after goal state processed and handle extensions to starts in extension slice #2546

Merged
merged 8 commits into from
Apr 19, 2022

Conversation

nagworld9
Copy link
Contributor

Description

  • check cgroup and disable if any extension started in agent cgroup after goal state processed.
  • Handle extensions to starts in extension slice if they are already installed.

Issue #


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made

Quality of Code and Contribution Guidelines

if self.is_azuremonitorlinuxagent(self.get_full_name()) and \
not CGroupConfigurator.get_instance().is_extension_resource_limits_setup_completed(self.get_full_name()):
# This check to call the setup if extension already installed and not called setup before
if not CGroupConfigurator.get_instance().is_extension_resource_limits_setup_completed(self.get_full_name()):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we used to do it for only AMA but this setup needed for every extension to starts in VMExtension slice.

@codecov
Copy link

codecov bot commented Apr 12, 2022

Codecov Report

Merging #2546 (7706bb5) into develop (02db57b) will increase coverage by 0.03%.
The diff coverage is 92.85%.

@@             Coverage Diff             @@
##           develop    #2546      +/-   ##
===========================================
+ Coverage    71.76%   71.79%   +0.03%     
===========================================
  Files          102      102              
  Lines        15314    15321       +7     
  Branches      2426     2429       +3     
===========================================
+ Hits         10990    11000      +10     
+ Misses        3834     3829       -5     
- Partials       490      492       +2     
Impacted Files Coverage Δ
azurelinuxagent/ga/exthandlers.py 85.78% <0.00%> (+0.07%) ⬆️
azurelinuxagent/common/cgroupconfigurator.py 73.89% <96.15%> (+0.69%) ⬆️
azurelinuxagent/ga/update.py 88.66% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02db57b...7706bb5. Read the comment docs.

@nagworld9 nagworld9 changed the title check agent cg after goal state processed check agent cg after goal state processed and handle extensions to starts in extension slice Apr 12, 2022
@@ -540,7 +540,7 @@ def __try_set_cpu_quota(quota):
return False
return True

def check_cgroups(self, cgroup_metrics):
def check_cgroups(self, cgroup_metrics=None):
Copy link
Member

Choose a reason for hiding this comment

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

None is not a good default value. Maybe a list of values, or an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -614,6 +614,10 @@ def _process_goal_state(self, exthandlers_handler, remote_access_handler):
self._extensions_summary = ExtensionsSummary()
exthandlers_handler.run()

# check cgroup and disable if any extension started in agent cgroup after goal state processed.
# Note: Monitor thread periodically checks this in addition to here.
CGroupConfigurator.get_instance().check_cgroups()
Copy link
Member

Choose a reason for hiding this comment

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

since now this is called from 2 threads, please verify the method is thread-safe or add a lock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added locking.

@@ -131,6 +132,7 @@ def __init__(self):
self._cgroups_api = None
self._agent_cpu_cgroup_path = None
self._agent_memory_cgroup_path = None
self._lock = threading.RLock()
Copy link
Member

Choose a reason for hiding this comment

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

can we rename this to help document what the lock is meant to be used for?

_check_cgroups_lock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

narrieta
narrieta previously approved these changes Apr 15, 2022
@nagworld9 nagworld9 merged commit 362df3f into Azure:develop Apr 19, 2022
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