Skip to content

Commit

Permalink
Fix string comparisons (#1600)
Browse files Browse the repository at this point in the history
  • Loading branch information
narrieta authored Aug 2, 2019
1 parent b0420fd commit 5346d4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions azurelinuxagent/common/cgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ def create(cgroup_path, controller, extension_name):
"""
Factory method to create the correct CGroup.
"""
if controller is "cpu":
if controller == "cpu":
return CpuCgroup(extension_name, cgroup_path)
elif controller is "memory":
if controller == "memory":
return MemoryCgroup(extension_name, cgroup_path)
raise CGroupsException('CGroup controller {0} is not supported'.format(controller))

def __init__(self, name, cgroup_path, controller_type):
"""
Expand Down
7 changes: 5 additions & 2 deletions azurelinuxagent/common/cgroupstelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from azurelinuxagent.common import logger
from azurelinuxagent.common.future import ustr
from azurelinuxagent.common.exception import CGroupsException


class CGroupsTelemetry(object):
Expand Down Expand Up @@ -165,10 +166,12 @@ def _add_cpu_usage(self, metric):

def add_new_data(self, controller, metric):
if metric:
if controller is "cpu":
if controller == "cpu":
self._add_cpu_usage(metric)
elif controller is "memory":
elif controller == "memory":
self._add_memory_usage(metric)
else:
raise CGroupsException('CGroup controller {0} is not supported'.format(controller))

def get_metrics(self):
return self._current_memory_usage, self._max_memory_levels, self._current_cpu_usage
Expand Down

0 comments on commit 5346d4a

Please sign in to comment.