Handle docker data root doesn't exist

In kolla, zun compute run inside a container so it couldn't
access the docker data root. Zun needs to handle this case.

Change-Id: I6882803404a1a5a6a5fe59afb1ee4b63bcd36514
Closes-Bug: #1795262
This commit is contained in:
Hongbin Lu 2018-10-03 03:55:53 +00:00
parent 24b212e987
commit d71af9ea44

View File

@ -12,6 +12,7 @@
# limitations under the License.
import datetime
import errno
import eventlet
import functools
import types
@ -1118,7 +1119,14 @@ class DockerDriver(driver.ContainerDriver):
runtimes)
def get_total_disk_for_container(self):
disk_usage = psutil.disk_usage(CONF.docker.docker_data_root)
try:
disk_usage = psutil.disk_usage(CONF.docker.docker_data_root)
except OSError as e:
if e.errno != errno.ENOENT:
raise
LOG.warning('Docker data root doesnot exist.')
# give another try with system root
disk_usage = psutil.disk_usage('/')
total_disk = disk_usage.total / 1024 ** 3
return int(total_disk * (1 - CONF.compute.reserve_disk_for_image))