Skip to content

Commit

Permalink
Use event.warn instead of log_cgroup_warning
Browse files Browse the repository at this point in the history
  • Loading branch information
maddieford committed Oct 11, 2024
1 parent 85b2ae1 commit 68ba023
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions azurelinuxagent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from azurelinuxagent.ga import logcollector, cgroupconfigurator
from azurelinuxagent.ga.cgroupcontroller import AGENT_LOG_COLLECTOR
from azurelinuxagent.ga.cpucontroller import _CpuController
from azurelinuxagent.ga.cgroupapi import get_cgroup_api, log_cgroup_warning, InvalidCgroupMountpointException
from azurelinuxagent.ga.cgroupapi import get_cgroup_api, InvalidCgroupMountpointException
from azurelinuxagent.ga.firewall_manager import FirewallManager

import azurelinuxagent.common.conf as conf
Expand Down Expand Up @@ -218,21 +218,22 @@ def collect_logs(self, is_full_mode):
try:
cgroup_api = get_cgroup_api()
except InvalidCgroupMountpointException as e:
log_cgroup_warning("The agent does not support cgroups if the default systemd mountpoint is not being used: {0}".format(ustr(e)), op=WALAEventOperation.LogCollection, send_event=True)
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)
except CGroupsException as e:
log_cgroup_warning("Unable to determine which cgroup version to use: {0}".format(ustr(e)), op=WALAEventOperation.LogCollection, send_event=True)
event.warn(WALAEventOperation.LogCollection, "Unable to determine which cgroup version to use: {0}", ustr(e))
sys.exit(logcollector.INVALID_CGROUPS_ERRCODE)

log_collector_cgroup = cgroup_api.get_process_cgroup(process_id="self", cgroup_name=AGENT_LOG_COLLECTOR)
tracked_controllers = log_collector_cgroup.get_controllers()

if len(tracked_controllers) != len(log_collector_cgroup.get_supported_controller_names()):
log_cgroup_warning("At least one required controller is missing. The following controllers are required for the log collector to run: {0}".format(log_collector_cgroup.get_supported_controller_names()), op=WALAEventOperation.LogCollection)
event.warn(WALAEventOperation.LogCollection, "At least one required controller is missing. The following controllers are required for the log collector to run: {0}", log_collector_cgroup.get_supported_controller_names())
sys.exit(logcollector.INVALID_CGROUPS_ERRCODE)

if not log_collector_cgroup.check_in_expected_slice(cgroupconfigurator.LOGCOLLECTOR_SLICE):
log_cgroup_warning("The Log Collector process is not in the proper cgroups", op=WALAEventOperation.LogCollection, send_event=True)
expected_slice = cgroupconfigurator.LOGCOLLECTOR_SLICE
if not log_collector_cgroup.check_in_expected_slice(expected_slice):
event.warn(WALAEventOperation.LogCollection, "The Log Collector process is not in the proper cgroups. Expected slice: {0}", expected_slice)
sys.exit(logcollector.INVALID_CGROUPS_ERRCODE)

try:
Expand Down

0 comments on commit 68ba023

Please sign in to comment.