9d3ca49387
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
64 lines
2.0 KiB
Bash
64 lines
2.0 KiB
Bash
#!/bin/bash
|
|
|
|
#
|
|
# Wrapper script to run glance-manage to purge soft deleted rows on active controller only
|
|
#
|
|
GLANCE_PURGE_INFO="/var/run/glance-purge.info"
|
|
GLANCE_PURGE_CMD="/usr/bin/nice -n 2 /usr/bin/glance-manage db purge --age_in_days 1 --max_rows 1000000 >> /dev/null 2>&1"
|
|
|
|
function is_active_pgserver()
|
|
{
|
|
# Determine whether we're running on the same controller as the service.
|
|
local service=postgres
|
|
local enabledactive=$(/usr/bin/sm-query service $service| grep enabled-active)
|
|
if [ "x$enabledactive" == "x" ]
|
|
then
|
|
# enabled-active not found for that service on this controller
|
|
return 1
|
|
else
|
|
# enabled-active found for that resource
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
if is_active_pgserver
|
|
then
|
|
if [ ! -f ${GLANCE_PURGE_INFO} ]
|
|
then
|
|
echo delay_count=0 > ${GLANCE_PURGE_INFO}
|
|
fi
|
|
|
|
source ${GLANCE_PURGE_INFO}
|
|
sudo -u postgres psql -d sysinv -c "SELECT alarm_id, entity_instance_id from i_alarm;" | grep -P "^(?=.*100.101)(?=.*${HOSTNAME})" &>/dev/null
|
|
if [ $? -eq 0 ]
|
|
then
|
|
source /etc/platform/platform.conf
|
|
if [ "${system_type}" = "All-in-one" ]
|
|
then
|
|
source /etc/init.d/task_affinity_functions.sh
|
|
idle_core=$(get_most_idle_core)
|
|
if [ "$idle_core" -ne "0" ]
|
|
then
|
|
# Purge soft deleted records that are older than 1 day from glance database.
|
|
sh -c "exec taskset -c $idle_core ${GLANCE_PURGE_CMD}"
|
|
sed -i "/delay_count/s/=.*/=0/" ${GLANCE_PURGE_INFO}
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
if [ "$delay_count" -lt "3" ]
|
|
then
|
|
newval=$(($delay_count+1))
|
|
sed -i "/delay_count/s/=.*/=$newval/" ${GLANCE_PURGE_INFO}
|
|
(sleep 3600; /usr/bin/glance-purge-deleted-active) &
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Purge soft deleted records that are older than 1 day from glance database.
|
|
eval ${GLANCE_PURGE_CMD}
|
|
sed -i "/delay_count/s/=.*/=0/" ${GLANCE_PURGE_INFO}
|
|
fi
|
|
|
|
exit 0
|