Yedidyah Bar David has uploaded a new change for review.

Change subject: packaging: setup: Do not fail on errors while restoring 
permissions
......................................................................

packaging: setup: Do not fail on errors while restoring permissions

Bug-Url: https://bugzilla.redhat.com/1073471
Change-Id: I5368388764576a2900a772b82f84d0b366f106c7
Signed-off-by: Yedidyah Bar David <[email protected]>
---
M packaging/dbscripts/dbfunc-base.sh
M packaging/dbscripts/dbfunc-common.sh
2 files changed, 22 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-dwh refs/changes/60/27860/1

diff --git a/packaging/dbscripts/dbfunc-base.sh 
b/packaging/dbscripts/dbfunc-base.sh
index e5a8595..fb40909 100644
--- a/packaging/dbscripts/dbfunc-base.sh
+++ b/packaging/dbscripts/dbfunc-base.sh
@@ -31,7 +31,6 @@
        LC_ALL="C" "${PSQL}" \
                -w \
                --pset=tuples_only=on \
-               --set ON_ERROR_STOP=1 \
                ${DBFUNC_LOGFILE:+--log-file="${DBFUNC_LOGFILE}"} \
                --host="${DBFUNC_DB_HOST}" \
                --port="${DBFUNC_DB_PORT}" \
@@ -42,6 +41,7 @@
 
 dbfunc_psql() {
        dbfunc_psql_raw \
+               --set ON_ERROR_STOP=1 \
                ${DBFUNC_VERBOSE:+--echo-all} \
                "$@"
 }
@@ -50,6 +50,12 @@
        dbfunc_psql "$@" || die "Cannot execute sql command: $*"
 }
 
+dbfunc_psql_allow_errors() {
+       dbfunc_psql_raw \
+               ${DBFUNC_VERBOSE:+--echo-all} \
+               "$@"
+}
+
 dbfunc_psql_statement_parsable() {
        local statement="$1"
        dbfunc_psql_raw \
diff --git a/packaging/dbscripts/dbfunc-common.sh 
b/packaging/dbscripts/dbfunc-common.sh
index 23b6bdf..bf50da6 100644
--- a/packaging/dbscripts/dbfunc-common.sh
+++ b/packaging/dbscripts/dbfunc-common.sh
@@ -47,6 +47,19 @@
        dbfunc_psql_die --command="${statement}" > /dev/null
 }
 
+dbfunc_common_restore_permissions() {
+       local permissions="$1"
+       echo "Applying custom users permissions on database objects..."
+       if ! local output=$(dbfunc_psql_allow_errors --command="${permissions}" 
2>&1); then
+               echo "While running:"
+               echo "${permissions}"
+               echo "Output was:"
+               echo "${output}"
+               local fatal=$(echo "${output}" | grep -v 'ERROR: *relation [^ 
]* does not exist')
+               [ -n "${fatal}" ] && die "Errors while restoring custom 
permissions: ${fatal}"
+       fi
+}
+
 dbfunc_common_schema_apply() {
        # check database connection
        dbfunc_psql_die --command="select 1;" > /dev/null
@@ -67,8 +80,7 @@
 
        _dbfunc_common_schema_upgrade
 
-       echo "Applying custom users permissions on database objects..."
-       dbfunc_psql_die --command="${permissions}"
+       dbfunc_common_restore_permissions "${permissions}"
 }
 
 dbfunc_common_schema_refresh() {
@@ -80,8 +92,7 @@
        _dbfunc_common_schema_refresh_drop
        _dbfunc_common_schema_refresh_create
 
-       echo "Applying custom users permissions on database objects..."
-       dbfunc_psql_die --command="${permissions}"
+       dbfunc_common_restore_permissions "${permissions}"
 }
 
 # gets the configuration value of the given option name and version.


-- 
To view, visit http://gerrit.ovirt.org/27860
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5368388764576a2900a772b82f84d0b366f106c7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-dwh
Gerrit-Branch: master
Gerrit-Owner: Yedidyah Bar David <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to