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 Slice unit property before setting up azure.slice #3196

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions azurelinuxagent/ga/cgroupconfigurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,30 @@ def initialize(self):
log_cgroup_warning("Unable to determine which cgroup version to use: {0}".format(ustr(e)), send_event=True)
return

# Setup the slices before v2 check. Cgroup v2 usage is disabled for agent and extensions, but can be
# enabled for log collector in waagent.conf. The log collector slice should be created in case v2
# usage is enabled for log collector.
self.__setup_azure_slice()

if self.using_cgroup_v2():
log_cgroup_info("Agent and extensions resource monitoring is not currently supported on cgroup v2")
return

# We check the agent unit 'Slice' property before setting up azure.slice. This check is done first
# because the agent's Slice unit property will be 'azure.slice' if the slice drop-in file exists, even
# though systemd has not moved the agent to azure.slice yet. Systemd will only move the agent to
# azure.slice after a service restart.
agent_unit_name = systemd.get_agent_unit_name()
agent_slice = systemd.get_unit_property(agent_unit_name, "Slice")
if agent_slice not in (AZURE_SLICE, "system.slice"):
log_cgroup_warning("The agent is within an unexpected slice: {0}".format(agent_slice))
return

# Notes about slice setup:
# 1. On first agent update (for machines where daemon version did not already create azure.slice), the
# agent creates azure.slice and the agent unit Slice drop-in file, but systemd does not move the agent
# unit to azure.slice until service restart. It is ok to enable cgroup usage in this case if agent is
# running in system.slice.
# 2. We setup the slices before v2 check. Cgroup v2 usage is disabled for agent and extensions, but
# can be enabled for log collector in waagent.conf. The log collector slice should be created in case
# v2 usage is enabled for log collector.
self.__setup_azure_slice()

if self.using_cgroup_v2():
log_cgroup_info("Agent and extensions resource monitoring is not currently supported on cgroup v2")
return

# Log mount points/root paths for cgroup controllers
self._cgroups_api.log_root_paths()

Expand Down
Loading