outposts: add recursion limit for docker controller
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
e4790f9060
commit
f6953296d8
|
@ -102,9 +102,11 @@ class DockerController(BaseController):
|
||||||
)
|
)
|
||||||
|
|
||||||
# pylint: disable=too-many-return-statements
|
# pylint: disable=too-many-return-statements
|
||||||
def up(self):
|
def up(self, depth=1):
|
||||||
if self.outpost.managed == MANAGED_OUTPOST:
|
if self.outpost.managed == MANAGED_OUTPOST:
|
||||||
return None
|
return None
|
||||||
|
if depth >= 10:
|
||||||
|
raise ControllerException("Giving up since we exceeded recursion limit.")
|
||||||
try:
|
try:
|
||||||
container, has_been_created = self._get_container()
|
container, has_been_created = self._get_container()
|
||||||
if has_been_created:
|
if has_been_created:
|
||||||
|
@ -120,17 +122,17 @@ class DockerController(BaseController):
|
||||||
should=self.get_container_image(),
|
should=self.get_container_image(),
|
||||||
)
|
)
|
||||||
self.down()
|
self.down()
|
||||||
return self.up()
|
return self.up(depth + 1)
|
||||||
# Check container's ports
|
# Check container's ports
|
||||||
if self._comp_ports(container):
|
if self._comp_ports(container):
|
||||||
self.logger.info("Container has mis-matched ports, re-creating...")
|
self.logger.info("Container has mis-matched ports, re-creating...")
|
||||||
self.down()
|
self.down()
|
||||||
return self.up()
|
return self.up(depth + 1)
|
||||||
# Check that container values match our values
|
# Check that container values match our values
|
||||||
if self._comp_env(container):
|
if self._comp_env(container):
|
||||||
self.logger.info("Container has outdated config, re-creating...")
|
self.logger.info("Container has outdated config, re-creating...")
|
||||||
self.down()
|
self.down()
|
||||||
return self.up()
|
return self.up(depth + 1)
|
||||||
if (
|
if (
|
||||||
container.attrs.get("HostConfig", {})
|
container.attrs.get("HostConfig", {})
|
||||||
.get("RestartPolicy", {})
|
.get("RestartPolicy", {})
|
||||||
|
@ -140,7 +142,7 @@ class DockerController(BaseController):
|
||||||
):
|
):
|
||||||
self.logger.info("Container has mis-matched restart policy, re-creating...")
|
self.logger.info("Container has mis-matched restart policy, re-creating...")
|
||||||
self.down()
|
self.down()
|
||||||
return self.up()
|
return self.up(depth + 1)
|
||||||
# Check that container is healthy
|
# Check that container is healthy
|
||||||
if (
|
if (
|
||||||
container.status == "running"
|
container.status == "running"
|
||||||
|
|
Reference in New Issue