Repository: rucio/rucio

Issue:
rucio-admin config set silently fails
Motivation
----------
 rucio-admin config set silently fails, e.g. :
```
rucio-admin config set --section throttler --option "Data Consolidation,xyz" --value 2000
Set configuration: throttler.Data Consolidation,xyz=2000
```
But on the server side, it returns a `500`







Discussion:

Resolving patch:
diff --git a/lib/rucio/client/configclient.py b/lib/rucio/client/configclient.py
--- a/lib/rucio/client/configclient.py
+++ b/lib/rucio/client/configclient.py
@@ -18,6 +18,7 @@
 # - Vincent Garonne <vgaronne@gmail.com>, 2014-2018
 # - Ralph Vigne <ralph.vigne@cern.ch>, 2015
 # - Martin Barisits <martin.barisits@cern.ch>, 2018
+# - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2019
 #
 # PY3K COMPATIBLE
 
@@ -82,8 +83,7 @@ def set_config_option(self, section, option, value):
         url = build_url(choice(self.list_hosts), path=path)
 
         r = self._send_request(url, type='PUT')
-
-        if r.status_code != codes.ok:
+        if r.status_code == codes.created:
             return True
         else:
             exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
diff --git a/lib/rucio/web/rest/flaskapi/v1/config.py b/lib/rucio/web/rest/flaskapi/v1/config.py
--- a/lib/rucio/web/rest/flaskapi/v1/config.py
+++ b/lib/rucio/web/rest/flaskapi/v1/config.py
@@ -25,8 +25,10 @@
 from logging import getLogger, StreamHandler, DEBUG
 from flask import Flask, Blueprint, Response, request as request
 from flask.views import MethodView
+from traceback import format_exc
 
 from rucio.api import config
+from rucio.common.exception import ConfigurationError
 from rucio.common.utils import generate_http_error_flask
 from rucio.web.rest.flaskapi.v1.common import before_request, after_request, check_accept_header_wrapper_flask
 
@@ -152,8 +154,11 @@ def put(self, section, option, value):
 
         try:
             config.set(section=section, option=option, value=value, issuer=request.environ.get('issuer'))
-        except Exception:
+        except ConfigurationError:
             return generate_http_error_flask(500, 'ConfigurationError', 'Could not set value \'%s\' for section \'%s\' option \'%s\'' % (value, section, option))
+        except Exception as error:
+            print(format_exc())
+            return error, 500
         return "Created", 201
 
 
diff --git a/lib/rucio/web/rest/webpy/v1/config.py b/lib/rucio/web/rest/webpy/v1/config.py
--- a/lib/rucio/web/rest/webpy/v1/config.py
+++ b/lib/rucio/web/rest/webpy/v1/config.py
@@ -23,10 +23,11 @@
 import json
 
 from logging import getLogger, StreamHandler, DEBUG
-
-from web import application, ctx, Created, loadhook, header
+from traceback import format_exc
+from web import application, ctx, Created, loadhook, header, InternalError
 
 from rucio.api import config
+from rucio.common.exception import ConfigurationError
 from rucio.common.utils import generate_http_error
 from rucio.web.rest.common import rucio_loadhook, RucioController, exception_wrapper, check_accept_header_wrapper
 
@@ -166,8 +167,11 @@ def PUT(self, section, option, value):
 
         try:
             config.set(section=section, option=option, value=value, issuer=ctx.env.get('issuer'))
-        except:
+        except ConfigurationError:
             raise generate_http_error(500, 'ConfigurationError', 'Could not set value \'%s\' for section \'%s\' option \'%s\'' % (value, section, option))
+        except Exception as error:
+            print(format_exc())
+            raise InternalError(error)
         raise Created()
 
 


Test patch: