Skip to content

Commit

Permalink
e2e test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nagworld9 committed Dec 17, 2024
1 parent 4533f3a commit 3b6d0d3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions azurelinuxagent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def collect_logs(self, is_full_mode):
if CollectLogsHandler.is_enabled_monitor_cgroups_check():
try:
cgroup_api = create_cgroup_api()
logger.info("Using cgroup {0} for resource enforcement and monitoring".format(cgroup_api.get_cgroup_version()))
except InvalidCgroupMountpointException as e:
event.warn(WALAEventOperation.LogCollection, "The agent does not support cgroups if the default systemd mountpoint is not being used: {0}", ustr(e))
sys.exit(logcollector.INVALID_CGROUPS_ERRCODE)
Expand Down
18 changes: 18 additions & 0 deletions azurelinuxagent/ga/cgroupapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ def __init__(self):
self._systemd_run_commands = []
self._systemd_run_commands_lock = threading.RLock()

def get_cgroup_version(self):
"""
Returns the version of the cgroup hierarchy in use.
"""
return NotImplementedError()

def get_systemd_run_commands(self):
"""
Returns a list of the systemd-run commands currently running (given as PIDs)
Expand Down Expand Up @@ -295,6 +301,12 @@ def _get_controller_mountpoints():
mount_points[controller] = path
return mount_points

def get_cgroup_version(self):
"""
Returns the version of the cgroup hierarchy in use.
"""
return "v1"

def get_controller_mountpoints(self):
"""
Returns a dictionary of controller-mountpoint mappings.
Expand Down Expand Up @@ -477,6 +489,12 @@ def _get_root_cgroup_path():
return root_cgroup_path
return ""

def get_cgroup_version(self):
"""
Returns the version of the cgroup hierarchy in use.
"""
return "v2"

def get_root_cgroup_path(self):
"""
Returns the unified cgroup mountpoint.
Expand Down
5 changes: 2 additions & 3 deletions azurelinuxagent/ga/cgroupconfigurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def _check_cgroups_supported(self):

try:
self._cgroups_api = create_cgroup_api()
log_cgroup_info("Using cgroup {0} for resource enforcement and monitoring".format(self._cgroups_api.get_cgroup_version()))
except InvalidCgroupMountpointException as e:
# Systemd mounts the cgroup file system at '/sys/fs/cgroup'. Previously, the agent supported cgroup
# usage if a user mounted the cgroup filesystem elsewhere. The agent no longer supports that
Expand All @@ -229,11 +230,9 @@ def _check_cgroups_supported(self):
return False

if self.using_cgroup_v2():
log_cgroup_info("Using cgroup v2 for resource enforcement and monitoring")
log_cgroup_info("Agent and extensions resource enforcement and monitoring is not currently supported on cgroup v2", send_event=True)
return False
else:
log_cgroup_info("Using cgroup v1 for resource enforcement and monitoring")

return True

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion tests_e2e/tests/cgroup_v2_disabled/cgroup_v2_disabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def run(self):
# Verify that the agent does not support cgroup v2
log.info("")
log.info("Checking that the agent does not use cgroup v2 for resource enforcement and monitoring...")
self.check_agent_log_contains('Agent and extensions resource monitoring is not currently supported on cgroup v2',
self.check_agent_log_contains('Agent and extensions resource enforcement and monitoring is not currently supported on cgroup v2',
'The agent should not attempt to use cgroup v2 for resource enforcement and monitoring')
self.check_agent_log_contains('Agent cgroups enabled: False',
'The agent should not enable cgroups when system is using v2')
Expand Down

0 comments on commit 3b6d0d3

Please sign in to comment.