Fix ulimit comparison

pull/18777/head
chouseknecht 9 years ago committed by Matt Clay
parent 6d6b8a1823
commit cc053c45ce

@ -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:
if limit.hard: results.append(dict(
results.append("%s:%s" % (limit.name, limit.soft, limit.hard)) Name=limit.name,
else: Soft=limit.soft,
results.append("%s:%s" % (limit.name, limit.soft)) Hard=limit.hard
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):

Loading…
Cancel
Save