Make docker cleanup more robust for overlayfs issues (#2033)

* Make docker cleanup more robust for overlayfs issues

* it's an issue

* more decent handling
This commit is contained in:
Pascal Vizeli 2020-09-09 16:25:18 +02:00 committed by GitHub
parent 548737a559
commit 0e3d95cac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -334,7 +334,13 @@ class DockerInterface(CoreSysAttributes):
raise DockerAPIError() from err
# Cleanup Current
for image in self.sys_docker.images.list(name=self.image):
try:
images_list = self.sys_docker.images.list(name=self.image)
except (docker.errors.DockerException, requests.RequestException) as err:
_LOGGER.waring("Corrupt docker overlayfs found: %s", err)
raise DockerAPIError() from err
for image in images_list:
if origin.id == image.id:
continue
@ -346,7 +352,13 @@ class DockerInterface(CoreSysAttributes):
if not old_image or self.image == old_image:
return
for image in self.sys_docker.images.list(name=old_image):
try:
images_list = self.sys_docker.images.list(name=old_image)
except (docker.errors.DockerException, requests.RequestException) as err:
_LOGGER.waring("Corrupt docker overlayfs found: %s", err)
raise DockerAPIError() from err
for image in images_list:
with suppress(docker.errors.DockerException, requests.RequestException):
_LOGGER.info("Cleanup images: %s", image.tags)
self.sys_docker.images.remove(image.id, force=True)