Tee Ngo 7f156476f9 Prevent unlimited growth of dcorch database
In this commit:
  - completed orch request is soft deleted right away.
  - failed orch requests that have not been soft deleted
    are soft deleted at the end of the next audit cycle.
  - prior to a sync run, if the managed subcloud has any
    queued, in-progress, and/or failed requests, its
    sync status will be set to out-of-sync.
  - a cron job that runs 20 minutes in the first hour
    daily (another commit in stx-puppet repo) will purge
    all soft deleted orch requests that are 3 days old,
    their orch jobs and resources.

Tests:
  - Identity and platform config changes with and
    without proxy.
  - Database inspection after config changes and after
    soak.
  - Purge of large number of orch requests, orch jobs
    and resources.

Story: 2007267
Task: 39044
Change-Id: If5c75b9af3e1e20c010308919cb6be8f11575546
Signed-off-by: Tee Ngo <tee.ngo@windriver.com>
2020-04-30 10:55:12 -04:00

24 lines
568 B
Bash

#!/bin/bash
#
# Wrapper script to run dcorch-manage db_clean on active controller only
#
re='^[0-9]+$'
function is_active_pgserver()
{
# Determine whether we're running on the same controller as the service.
/usr/bin/sm-query service postgres | grep -q enabled-active
return $?
}
if is_active_pgserver
then
if [[ $1 =~ $re ]]
then
/usr/bin/nice -n 2 /usr/bin/dcorch-manage db_clean $1 >> /var/log/dcorch/dcorch-clean.log
else
/usr/bin/nice -n 2 /usr/bin/dcorch-manage db_clean 3 >> /var/log/dcorch/dcorch-clean.log
fi
fi