Optimize container CLI for getting unique names
Do not call it twice in the while{} loop. It is pointless to double-check for a container existence after we have determined weither its name is in use or not. This decreases the pressure on the container system. Change-Id: Ife65f082f389ad4a730b3f9cf07d32ac4be32b45 Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
parent
6ca0170eeb
commit
a6df749249
|
@ -123,11 +123,13 @@ class BaseRunner(object):
|
|||
suffix = ''.join(random.choice(
|
||||
string.ascii_lowercase + string.digits) for i in range(8))
|
||||
container_name = '%s-%s' % (container, suffix)
|
||||
break
|
||||
else:
|
||||
while self.container_exist(container_name, quiet=True):
|
||||
suffix = ''.join(random.choice(
|
||||
string.ascii_lowercase + string.digits) for i in range(8))
|
||||
container_name = '%s-%s' % (container, suffix)
|
||||
break
|
||||
return container_name
|
||||
|
||||
def discover_container_name(self, container, cid):
|
||||
|
|
Loading…
Reference in New Issue