|
When a disk fills up on a database server, it is useful to have an option for reducing the disk space used without deleting data used by catalog compilation or requiring an increase in disk space. Disk increases can be infeasible or may require a long change cycle during which the Puppet infrastructure is inoperative.
Historical Context
In PuppetDB 2.x disk usage could be reduced by truncating the reports table, which is often the largest table in the database by several orders of magnitude. This would return large amounts of space to the operating system, enabling further maintenance operations, while keeping exported resources intact for catalog compilation:
# PE 3.8.x
|
|
# sudo -u pe-postgres /opt/puppet/bin/psql -d pe-puppetdb
|
could not change directory to "/root"
|
psql (9.2.14)
|
Type "help" for help.
|
|
pe-puppetdb=# SELECT count(*) FROM catalog_resources WHERE exported = true;
|
count
|
-------
|
5
|
(1 row)
|
|
pe-puppetdb=# TRUNCATE TABLE reports CASCADE;
|
NOTICE: truncate cascades to table "resource_events"
|
NOTICE: truncate cascades to table "latest_reports"
|
TRUNCATE TABLE
|
pe-puppetdb=# SELECT count(*) FROM catalog_resources WHERE exported = true;
|
count
|
-------
|
5
|
(1 row)
|
In 2015.3.x, the TRUNCATE operation now cascades beyond the tables related to reporting and wipes out exported resources, which negatively impacts catalog compilation:
# PE 2015.x
|
|
# sudo -u pe-postgres /opt/puppetlabs/server/bin/psql -d pe-puppetdb
|
could not change directory to "/root": Permission denied
|
psql (9.4.5)
|
Type "help" for help.
|
|
pe-puppetdb=# SELECT count(*) FROM catalog_resources WHERE exported = true;
|
count
|
-------
|
6
|
(1 row)
|
|
pe-puppetdb=# TRUNCATE TABLE reports CASCADE;
|
NOTICE: truncate cascades to table "certnames"
|
NOTICE: truncate cascades to table "resource_events"
|
NOTICE: truncate cascades to table "factsets"
|
NOTICE: truncate cascades to table "catalogs"
|
NOTICE: truncate cascades to table "facts"
|
NOTICE: truncate cascades to table "catalog_resources"
|
TRUNCATE TABLE
|
pe-puppetdb=# SELECT count(*) FROM catalog_resources WHERE exported = true;
|
count
|
-------
|
0
|
(1 row)
|
Desired Functionality
PuppetDB should allow for emergency removal of historical data without impacting catalog compilation or requiring changes to disk space allocation.
|