From 6488f4677e3927e31bf996c41eae69b3dc2137c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 13 Sep 2017 15:22:04 +0200 Subject: [PATCH] Be more graceful when URLer service isn't configured properly. Errors are still logged, but find_url_for_node() will just act as if the node doesn't exist when the URLer authentication token is invalid. --- pillar/web/nodes/finders.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pillar/web/nodes/finders.py b/pillar/web/nodes/finders.py index f93b1274..06950a7c 100644 --- a/pillar/web/nodes/finders.py +++ b/pillar/web/nodes/finders.py @@ -3,6 +3,7 @@ import logging from flask import current_app, url_for +import werkzeug.exceptions as wz_exceptions import pillarsdk from pillarsdk import Node @@ -105,8 +106,13 @@ def project_url(project_id, project): urler_api = system_util.pillar_api( token=current_app.config['URLER_SERVICE_AUTH_TOKEN']) - return pillarsdk.Project.find_from_endpoint( - '/service/urler/%s' % project_id, api=urler_api) + + try: + return pillarsdk.Project.find_from_endpoint( + '/service/urler/%s' % project_id, api=urler_api) + except pillarsdk.ForbiddenAccess as ex: + log.error('URLER request to find URL for project %s failed: %s', project_id, ex) + raise wz_exceptions.NotFound() # Cache the actual URL based on the node ID, for the duration of the request.