Revert "Execute all db-schema scripts in sequential order sorted by ID revision number"

This reverts commit 22bbf6c4bc.

See https://bugtracker.sipwise.com/view.php?id=3963
agranig/peering-route
Michael Prokop 12 years ago
parent 19b397dde3
commit ab99c45a9c

@ -107,36 +107,44 @@ apply_revision() {
}
# execute the rev script iff there's no entry for *any* host yet
apply_revs() {
apply_generic_revs() {
[ -n "$1" ] || return 1
revs="$1"
for missing_revision in $(ngcp-check-rev-applied --schema db_schema --revision $revs | awk '/^No match for revision/ {print $5}') ; do
revision_file="$(find /usr/share/ngcp-db-schema/ -name "$missing_revision")"
# execute the rev script iff there's no entry for the *current* host yet
case "$revision_file" in
*_not_replicated.up)
if ngcp-check-rev-applied --schema db_schema --revision $revs --node "$hostname" | grep 'already executed' ; then
continue
fi
;;
esac
if [ -r "$revision_file" ] ; then
apply_revision "$revision_file"
else
echo "Warning: missing revision $missing_revision identified but could not find according db-schema file."
fi
done
}
# execute the rev script iff there's no entry for the *current* host yet
apply_host_specific_revs() {
[ -n "$1" ] || return 1
revs="$1"
for missing_revision in $(ngcp-check-rev-applied --schema db_schema --revision $revs --node "$hostname" | awk '/^No match for revision/ {print $5}') ; do
revision_file="$(find /usr/share/ngcp-db-schema/ -name "$missing_revision")"
if [ -r "$revision_file" ] ; then
apply_revision "$revision_file"
else
echo "Warning: missing revision $missing_revision identified but could not find according file."
fi
done
}
revision_wrapper() {
[ -n "$1" ] || return 1
local revlist
local host_specific_revs;
local generic_revs;
for rev in $* ; do
@ -152,23 +160,22 @@ revision_wrapper() {
case "$revname" in
# the scripts that should be executed on *all* hosts, no matter whether
# they are active or inactive, since the script's content doesn't get replicated
# NOTE: the actual logic is inside the apply_revs to avoid *_not_replicated.up
# scripts being executed independent from the other ones
*_not_replicated.up)
revlist="$revlist $(basename $rev)"
host_specific_revs="$host_specific_revs $(basename $rev)"
;;
*)
if running_on_active_node ; then
echo "Replication script ${revname} noted, nothing to do on active node"
else
revlist="$revlist $(basename $rev)"
generic_revs="$generic_revs $(basename $rev)"
fi
;;
esac
done
apply_revs "$revlist"
apply_generic_revs "$generic_revs"
apply_host_specific_revs "$host_specific_revs"
}
# make sure we get sorted 10XXX after 9XXX

Loading…
Cancel
Save