1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix ulimit comparison

This commit is contained in:
chouseknecht 2016-06-21 02:20:50 -04:00 committed by Matt Clay
parent 6d6b8a1823
commit cc053c45ce

View file

@ -1017,7 +1017,7 @@ class TaskParameters(DockerBaseClass):
def _parse_ulimits(self): def _parse_ulimits(self):
''' '''
Turn ulimits into a dictionary Turn ulimits into an array of Ulimit objects
''' '''
if self.ulimits is None: if self.ulimits is None:
return None return None
@ -1029,6 +1029,7 @@ class TaskParameters(DockerBaseClass):
if len(pieces) >= 2: if len(pieces) >= 2:
limits['name'] = pieces[0] limits['name'] = pieces[0]
limits['soft'] = int(pieces[1]) limits['soft'] = int(pieces[1])
limits['hard'] = int(pieces[2])
if len(pieces) == 3: if len(pieces) == 3:
limits['hard'] = int(pieces[2]) limits['hard'] = int(pieces[2])
try: try:
@ -1147,7 +1148,6 @@ class Container(DockerBaseClass):
restart_policy = host_config.get('RestartPolicy', dict()) restart_policy = host_config.get('RestartPolicy', dict())
config = self.container['Config'] config = self.container['Config']
network = self.container['NetworkSettings'] network = self.container['NetworkSettings']
host_config['Ulimits'] = self._get_expected_ulimits(host_config['Ulimits'])
# The previous version of the docker module ignored the detach state by # The previous version of the docker module ignored the detach state by
# assuming if the container was running, it must have been detached. # assuming if the container was running, it must have been detached.
@ -1530,20 +1530,13 @@ class Container(DockerBaseClass):
self.log('_get_expected_ulimits') self.log('_get_expected_ulimits')
if config_ulimits is None: if config_ulimits is None:
return None return None
results = [] results = []
if isinstance(config_ulimits[0], Ulimit): for limit in config_ulimits:
for limit in config_ulimits: results.append(dict(
if limit.hard: Name=limit.name,
results.append("%s:%s" % (limit.name, limit.soft, limit.hard)) Soft=limit.soft,
else: Hard=limit.hard
results.append("%s:%s" % (limit.name, limit.soft)) ))
else:
for limit in config_ulimits:
if limit.get('hard'):
results.append("%s:%s" % (limit.get('name'), limit.get('hard')))
else:
results.append("%s:%s" % (limit.get('name'), limit.get('soft')))
return results return results
def _get_expected_cmd(self): def _get_expected_cmd(self):