Skip to content

Commit

Permalink
add configuration for unlimited cgroups (#1337)
Browse files Browse the repository at this point in the history
  • Loading branch information
hglkrijger authored Sep 6, 2018
1 parent 4f55648 commit 527e863
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 6 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ OS.SshDir=/etc/ssh
HttpProxy.Host=None
HttpProxy.Port=None
CGroups.EnforceLimits=y
CGroups.Excluded=customscript,runcommand
```

The various configuration options are described in detail below. Configuration
Expand Down Expand Up @@ -461,6 +462,13 @@ _Default: y_
If set, the agent will attempt to set cgroups limits for cpu and memory for the agent process itself
as well as extension processes. See the wiki for further details on this.

#### __CGroups.Excluded__

_Type: String_
_Default: customscript,runcommand_

The list of extensions which will be excluded from cgroups limits. This should be comma separated.

### Telemetry

WALinuxAgent collects usage data and sends it to Microsoft to help improve our products and services. The data collected is used to track service health and
Expand Down Expand Up @@ -489,7 +497,7 @@ Run once:
2. Create the pbuilder environment

```bash
sudo pbuilder create --debootstrapopts --variant=buildd`
sudo pbuilder create --debootstrapopts --variant=buildd
```

3. Obtain `waagent.dsc` from a downstream package repo
Expand All @@ -505,7 +513,7 @@ To compile the package, from the top-most directory:
2. Build the package

```bash
sudo pbuilder build {waagent.dsc}
sudo pbuilder build waagent.dsc
```

3. Fetch the built package, usually from `/var/cache/pbuilder/result`
Expand Down
4 changes: 1 addition & 3 deletions azurelinuxagent/common/cgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import errno
import os
import re
import traceback

import time

Expand All @@ -32,7 +31,6 @@
WRAPPER_CGROUP_NAME = "Agent+Extensions"
METRIC_HIERARCHIES = ['cpu', 'memory']
MEMORY_DEFAULT = -1
UNLIMITED_INSTANCES = ['customscript', 'runcommand']

# percentage of a single core
DEFAULT_CPU_LIMIT_AGENT = 10
Expand Down Expand Up @@ -489,7 +487,7 @@ def set_limits(self):
if self.name is None:
return

for ext in UNLIMITED_INSTANCES:
for ext in conf.get_cgroups_excluded():
if ext in self.name.lower():
logger.info('No cgroups limits for {0}'.format(self.name))
return
Expand Down
8 changes: 7 additions & 1 deletion azurelinuxagent/common/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def load_conf_from_file(conf_file_path, conf=__conf__):
"ResourceDisk.MountPoint": "/mnt/resource",
"ResourceDisk.MountOptions": None,
"ResourceDisk.Filesystem": "ext3",
"AutoUpdate.GAFamily": "Prod"
"AutoUpdate.GAFamily": "Prod",
"CGroups.Excluded": "customscript,runcommand",
}


Expand Down Expand Up @@ -367,3 +368,8 @@ def get_disable_agent_file_path(conf=__conf__):

def get_cgroups_enforce_limits(conf=__conf__):
return conf.get_switch("CGroups.EnforceLimits", True)


def get_cgroups_excluded(conf=__conf__):
excluded_value = conf.get("CGroups.Excluded", "customscript, runcommand")
return [s for s in [i.strip().lower() for i in excluded_value.split(',')] if len(s) > 0] if excluded_value else []
3 changes: 3 additions & 0 deletions config/alpine/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ OS.EnableFirewall=y

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=y

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
3 changes: 3 additions & 0 deletions config/bigip/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@ OS.EnableFirewall=y

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=y

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
3 changes: 3 additions & 0 deletions config/coreos/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ OS.EnableFirewall=y

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=y

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
3 changes: 3 additions & 0 deletions config/debian/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,6 @@ OS.EnableFirewall=n

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=y

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
3 changes: 3 additions & 0 deletions config/freebsd/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,6 @@ OS.EnableFirewall=y

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=n

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
3 changes: 3 additions & 0 deletions config/ubuntu/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,6 @@ OS.EnableFirewall=y

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=y

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
3 changes: 3 additions & 0 deletions config/waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ OS.EnableFirewall=y

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=y

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
34 changes: 34 additions & 0 deletions tests/common/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class TestConf(AgentTestCase):
"OS.AllowHTTP": False,
"OS.EnableFirewall": False,
"CGroups.EnforceLimits": True,
"CGroups.Excluded": "customscript,runcommand",
}

def setUp(self):
Expand Down Expand Up @@ -135,3 +136,36 @@ def test_write_agent_disabled(self):
def test_get_extensions_enabled(self):
self.assertTrue(get_extensions_enabled(self.conf))

@patch('azurelinuxagent.common.conf.ConfigurationProvider.get')
def assert_get_cgroups_excluded(self, patch_get, config, expected_value):
patch_get.return_value = config
self.assertEqual(expected_value, conf.get_cgroups_excluded(self.conf))

def test_get_cgroups_excluded(self):
self.assert_get_cgroups_excluded(config=None,
expected_value=[])

self.assert_get_cgroups_excluded(config='',
expected_value=[])

self.assert_get_cgroups_excluded(config=' ',
expected_value=[])

self.assert_get_cgroups_excluded(config=' , ,, ,',
expected_value=[])

standard_values = ['customscript', 'runcommand']
self.assert_get_cgroups_excluded(config='CustomScript, RunCommand',
expected_value=standard_values)

self.assert_get_cgroups_excluded(config='customScript, runCommand , , ,,',
expected_value=standard_values)

self.assert_get_cgroups_excluded(config=' customscript,runcommand ',
expected_value=standard_values)

self.assert_get_cgroups_excluded(config='customscript,, runcommand',
expected_value=standard_values)

self.assert_get_cgroups_excluded(config=',,customscript ,runcommand',
expected_value=standard_values)
3 changes: 3 additions & 0 deletions tests/data/test_waagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ OS.EnableFirewall=n

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=y

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
1 change: 1 addition & 0 deletions tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
AutoUpdate.GAFamily = Prod
Autoupdate.Frequency = 3600
CGroups.EnforceLimits = True
CGroups.Excluded = customscript,runcommand
DVD.MountPoint = /mnt/cdrom/secure
DetectScvmmEnv = False
EnableOverProvisioning = True
Expand Down

0 comments on commit 527e863

Please sign in to comment.