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
This commit is contained in:
Marcin Juszkiewicz 2019-03-13 15:45:22 +01:00
parent 7d8eafaee8
commit a21ab86ca6
1 changed files with 13 additions and 7 deletions

View File

@ -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,6 +29,7 @@ from kolla.image import build # noqa
def main():
try:
statuses = build.run_build()
if statuses:
(bad_results, good_results, unmatched_results,
@ -35,6 +37,10 @@ def main():
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__':