Browse Source

build: handle template syntax errors better

Before:

(venv-for-kolla) 15:35 (s) hrw@puchatek:kolla$ ./tools/build.py --template-only
INFO:kolla.common.utils:Found the docker image folder at /home/hrw/devel/linaro/kolla/docker
Traceback (most recent call last):

[.. here goes 100 lines of Jinja2 traceback ..]

jinja2.exceptions.TemplateSyntaxError: unexpected '}', expected ']'

After:

(venv-for-kolla) 15:44 (s) hrw@puchatek:kolla$ ./tools/build.py --template-only
INFO:kolla.common.utils:Found the docker image folder at /home/hrw/devel/linaro/kolla/docker
ERROR:kolla.common.utils:Syntax error in template: ironic-inspector/Dockerfile.j2
ERROR:kolla.common.utils:unexpected '}', expected ']'
INFO:kolla.common.utils:Dockerfiles are generated in /tmp/kolla-2019-03-13_15-44-28_0ovk4xu_/docker

Change-Id: Iaa899f0b81f6698aa86b15977c39af3269d31e9a
changes/63/643063/4
Marcin Juszkiewicz 2 years ago
parent
commit
a21ab86ca6
  1. 20
      kolla/cmd/build.py

20
kolla/cmd/build.py

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import jinja2
import os
import sys
@ -28,13 +29,18 @@ from kolla.image import build # noqa
def main():
statuses = build.run_build()
if statuses:
(bad_results, good_results, unmatched_results,
skipped_results) = statuses
if bad_results:
return 1
return 0
try:
statuses = build.run_build()
if statuses:
(bad_results, good_results, unmatched_results,
skipped_results) = statuses
if bad_results:
return 1
return 0
except jinja2.exceptions.TemplateSyntaxError as e:
build.LOG.error("Syntax error in template: %s" % e.name)
build.LOG.error(e.message)
return 1
if __name__ == '__main__':

Loading…
Cancel
Save