Repository: rucio/rucio

Issue:
Lifetime Model: Limit the duration of the extension to one year in the UI
Motivation
----------
Lifetime Model : Limit the duration of the extension to one year in the UI






UniqueViolation PSQL driver problem
Motivation
----------

```
InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (psycopg2.errors.UniqueViolation) duplicate key value violates unique cons
traint "ACCOUNT_ATTR_MAP_PK"
DETAIL:  Key (account, key)=(root, jdoe-6803bb40932c423f99c0) already exists.

[SQL: INSERT INTO dev.account_attr_map (account, key, value, updated_at, created_at) VALUES (%(account)s, %(key)s, %(value)s, %(updated_at)s, %(created_at)s)]
[parameters: {'value': 'true', 'created_at': datetime.datetime(2019, 11, 22, 11, 4, 50, 279628), 'account': 'root', 'key': 'jdoe-6803bb40932c423f99c0', 'updated_at': datetime.datetime(2019, 11, 22, 11, 4, 50, 279621)}]
(Background on this error at: http://sqlalche.me/e/gkpj) (Background on this error at: http://sqlalche.me/e/7s2a)
```

Modification
------------

Add new error string handling.


Discussion:

Resolving patch:
diff --git a/lib/rucio/core/account.py b/lib/rucio/core/account.py
--- a/lib/rucio/core/account.py
+++ b/lib/rucio/core/account.py
@@ -1,19 +1,27 @@
-# Copyright European Organization for Nuclear Research (CERN)
+# Copyright 2012-2019 CERN for the benefit of the ATLAS collaboration.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
-# You may not use this file except in compliance with the License.
+# you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# http://www.apache.org/licenses/LICENSE-2.0
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 #
 # Authors:
-# - Thomas Beermann, <thomas.beermann@cern.ch>, 2012
-# - Angelos Molfetas, <angelos.molfetas@cern.ch>, 2012
-# - Mario Lassnig, <mario.lassnig@cern.ch>, 2012-2013, 2017
-# - Vincent Garonne, <vincent.garonne@cern.ch>, 2012-2015
-# - Martin Barisits, <martin.barisits@cern.ch>, 2014
-# - Cedric Serfon, <cedric.serfon@cern.ch>, 2014-2019
-# - Joaquin Bogado, <joaquin.bogado@cern.ch>, 2015
-# - Hannes Hansen, <hannes.jakob.hansen@cern.ch>, 2018-2019
+# - Thomas Beermann <thomas.beermann@cern.ch>, 2012
+# - Angelos Molfetas <Angelos.Molfetas@cern.ch>, 2012
+# - Mario Lassnig <mario.lassnig@cern.ch>, 2012-2019
+# - Vincent Garonne <vgaronne@gmail.com>, 2012-2015
+# - Martin Barisits <martin.barisits@cern.ch>, 2014
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2014-2019
+# - Joaquin Bogado <jbogado@linti.unlp.edu.ar>, 2015
+# - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2018-2019
+# - Andrew Lister <andrew.lister@stfc.ac.uk>, 2019
 #
 # PY3K COMPATIBLE
 
@@ -254,7 +262,8 @@ def add_account_attribute(account, key, value, session=None):
            or match('.*IntegrityError.*1062.*Duplicate entry.*for key.*', error.args[0]) \
            or match('.*IntegrityError.*UNIQUE constraint failed: account_attr_map.account, account_attr_map.key.*', error.args[0]) \
            or error.args[0] == "(IntegrityError) column account/key is not unique" \
-           or match('.*IntegrityError.*duplicate key value violates unique constraint.*', error.args[0]):
+           or match('.*IntegrityError.*duplicate key value violates unique constraint.*', error.args[0]) \
+           or match('.*UniqueViolation.*duplicate key value violates unique constraint.*', error.args[0]):
             raise exception.Duplicate('Key {0} already exist for account {1}!'.format(key, account))
     except Exception:
         raise exception.RucioException(str(format_exc()))


Test patch: