diff options
| author | Michal Arbet <michal.arbet@ultimum.io> | 2023-09-12 02:28:08 +0200 |
|---|---|---|
| committer | Michal Arbet <michal.arbet@ultimum.io> | 2023-09-21 11:01:21 +0200 |
| commit | b76bd4c6efa22af43d7895a7b5e95c75806d3893 (patch) | |
| tree | f9fcabc48ef5e6badbb0800a98c4cc605886eea9 /kolla/image/tasks.py | |
| parent | 4871ca4d6b83f6d28d790722eae52de5e56becee (diff) | |
| download | kolla-b76bd4c6efa22af43d7895a7b5e95c75806d3893.tar.gz kolla-b76bd4c6efa22af43d7895a7b5e95c75806d3893.zip | |
Add podman for image building
Add podman as an option to choose for container engine
for kolla-build (--engine podman)
Signed-off-by: Konstantin Yarovoy <konstantin.yarovoy@tietoevry.com>
Co-Authored-By: Michal Arbet <michal.arbet@ultimum.io>
Change-Id: I068c906df97745e397408d8c3ef6af47ee037638
Diffstat (limited to 'kolla/image/tasks.py')
| -rw-r--r-- | kolla/image/tasks.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/kolla/image/tasks.py b/kolla/image/tasks.py index 1fbfbd6b5..ada30d664 100644 --- a/kolla/image/tasks.py +++ b/kolla/image/tasks.py @@ -12,11 +12,16 @@ import datetime import errno +import json import os import shutil import tarfile import docker.errors +try: + import podman.errors.exceptions +except (ImportError, ModuleNotFoundError): + pass import git import requests from requests import exceptions as requests_exc @@ -367,6 +372,20 @@ class BuildTask(EngineTask): pull = self.conf.pull if image.parent is None else False buildargs = self.update_buildargs() + + kwargs = {} + if self.conf.engine == engine.Engine.PODMAN.value: + # TODO(kevko): dockerfile path is a workaround, + # should be removed as soon as it will be fixed in podman-py + # https://github.com/containers/podman-py/issues/177 + kwargs["dockerfile"] = image.path + '/Dockerfile' + # Podman squash is different by default + # https://github.com/containers/buildah/issues/1234 + if self.conf.squash: + kwargs["squash"] = False + kwargs["layers"] = False + else: + kwargs["layers"] = True try: for stream in self.engine_client.images.build( path=image.path, @@ -376,7 +395,10 @@ class BuildTask(EngineTask): network_mode=self.conf.network_mode, pull=pull, forcerm=self.forcerm, - buildargs=buildargs)[1]: + buildargs=buildargs, + **kwargs)[1]: + if self.conf.engine == engine.Engine.PODMAN.value: + stream = json.loads(stream) if 'stream' in stream: for line in stream['stream'].split('\n'): if line: @@ -399,6 +421,11 @@ class BuildTask(EngineTask): for line in e.build_log: if 'stream' in line: self.logger.error(line['stream'].strip()) + if isinstance(e, podman.errors.exceptions.BuildError): + for line in e.build_log: + line = json.loads(line) + if 'stream' in line: + self.logger.error(line['stream'].strip()) self.logger.exception('Unknown container engine ' 'error when building') |
