Fix SERIAL sync in DNS cluster

This commit is contained in:
Serghey Rodin 2015-10-21 15:54:07 +03:00
commit bdc8111b06
14 changed files with 298 additions and 670 deletions

View file

@ -22,26 +22,19 @@ source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
echo "Error: dns-cluster.conf doesn't exist"
log_event "$E_NOTEXIST $EVENT"
exit $E_NOTEXIST
check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
fi
number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
if [ "$number_of_proc" -gt 2 ]; then
echo "Error: another sync process already exists"
log_event "$E_EXISTS $EVENT"
exit $E_EXISTS
if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
check_result $E_EXISTS "another sync process already running"
fi
remote_dns_health_check
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
old_ifs="$IFS"
IFS=$'\n'
if [ -z $host ]; then
@ -51,65 +44,18 @@ else
fi
# Starting cluster loop
for cluster_str in $hosts; do
for cluster in $hosts; do
# Get host values
eval $cluster_str
# Parsing remote host parameters
eval $cluster
# Check connection type
if [ -z "TYPE" ]; then
TYPE='api'
fi
# Deleting source records
cluster_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME 'no'
check_result $? "$HOST connection failed (cleanup)" $E_CONNECT
# Print hostname
if [ ! -z "$verbose" ]; then
echo "HOSTNAME: $HOSTNAME"
echo "TYPE: $TYPE"
fi
# Switch on connection type
case $TYPE in
ssh) send_cmd="send_ssh_cmd" ;;
*) send_cmd="send_api_cmd" ;;
esac
# Check host connection
$send_cmd v-list-sys-config
if [ $? -ne 0 ]; then
echo "Error: $TYPE connection to $HOST failed"
log_event "$E_CONNECT $EVENT"
exit $E_CONNECT
fi
# Check recipient dns user
if [ -z "$DNS_USER" ]; then
DNS_USER='dns-cluster'
fi
if [ ! -z "$verbose" ]; then
echo "DNS_USER: $DNS_USER"
fi
$send_cmd v-list-user $DNS_USER
if [ $? -ne 0 ]; then
echo "Error: dns user $DNS_USER doesn't exist"
log_event "$E_NOTEXIST $EVENT"
exit $E_NOTEXIST
fi
# Clean source records
$send_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME 'no'
if [ $? -ne 0 ]; then
echo "Error: $TYPE connection to $HOST failed (cleanup)"
log_event "$E_CONNECT $EVENT"
exit $E_CONNECT
fi
# Rebuild dns zones
$send_cmd v-rebuild-dns-domains $DNS_USER 'scheduled'
if [ $? -ne 0 ]; then
echo "Error: $TYPE connection to $HOST failed (rebuild)"
log_event "$E_CONNECT $EVENT"
exit $E_CONNECT
fi
# Rebuilding dns zones
$send_cmd v-rebuild-dns-domains $DNS_USER 'yes'
check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
done
@ -118,4 +64,11 @@ done
# Vesta #
#----------------------------------------------------------#
# Updating pipe
pipe="$VESTA/data/queue/dns-cluster.pipe"
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
if [ ! -z "$str" ]; then
sed -i "$str d" $pipe
fi
exit