Skip to main content
Configure automated cleanup jobs to maintain database health by removing old data. Astro Private Cloud (APC) includes several cleanup jobs that run as CronJobs on configurable schedules to manage storage growth and query performance.

Cleanup jobs summary

cleanupDeployments

Permanently removes deployments that have been soft-deleted after the retention period.

What gets cleaned

  • Deployment database records marked with deletedAt
  • Associated Docker registry images
  • Deployment metadata database

Configuration

Manual trigger

Run this command from a machine with access to the underlying Kubernetes cluster:

cleanupDeployRevisions

Removes old deployment revision records to reduce database size.

What gets cleaned

  • deployRevision records older than retention period
  • Historical deployment configuration snapshots

Configuration

Manual trigger

Run this command from a machine with access to the underlying Kubernetes cluster:

Per-deployment cleanup

Run this command from a machine with access to the underlying Kubernetes cluster to clean revisions for a specific deployment:

cleanupTaskUsageData

Purges task usage metrics and audit logs.

What gets cleaned

  • TaskUsage records (daily aggregated metrics)
  • TaskUsageAuditLog records (raw task data)

Configuration

Manual trigger

Run this command from a machine with access to the underlying Kubernetes cluster:

GraphQL trigger

Use the cleanupTaskUsageDataJob query to manually trigger a purge of task usage metrics and audit logs:
Minimum retention is 90 days and can’t be reduced.

cleanupClusterAudits

Removes cluster audit log entries.

What gets cleaned

  • ClusterAudit records tracking cluster configuration changes
  • Historical cluster state snapshots

Configuration

Manual trigger

Run this command from a machine with access to the underlying Kubernetes cluster:

Filter by cluster

Run this command from a machine with access to the underlying Kubernetes cluster to clean audits for specific clusters:

cleanupAirflowDb

Cleans Airflow metadata from individual Deployment databases.
This job is disabled by default due to potential impact on running Deployments.

What gets cleaned

Default tables:
  • callback_request - Task callback requests
  • celery_taskmeta, celery_tasksetmeta - Celery metadata
  • dag - Dag definitions
  • dag_run - Dag execution history
  • dataset_event - Dataset events
  • import_error - Import errors
  • job - Job records
  • log - Task execution logs
  • session - Session data
  • sla_miss - SLA violations
  • task_fail - Task failures
  • task_instance - Task execution records
  • task_reschedule - Reschedule events
  • trigger - Trigger records
  • xcom - Cross-communication data

Configuration

Cloud storage export

Export archived data to cloud storage:

Specific tables only

Clean only specific tables:

Manual trigger

Run this command from a machine with access to the underlying Kubernetes cluster:

Schedule reference

Default schedules are staggered to avoid simultaneous execution:

Common configuration options

All cleanup jobs share these options:

Kubernetes CronJob behavior

All cleanup CronJobs use:
  • Concurrency policy: Forbid (prevents overlapping runs)
  • Backoff limit: 1 retry on failure
  • Restart policy: Never

Monitor cleanup jobs

Check job status

Verify data cleanup

Troubleshooting

Job not running

  1. Check CronJob exists:
  2. Check job is enabled in Helm values.
  3. Verify schedule syntax is valid cron expression.

Job failing

  1. Check job logs:
  2. Database connectivity: Ensure the APC API can reach the database.
  3. Permissions: Verify service account has required database permissions.

Data not being cleaned

  1. Check retention period: Data younger than olderThan won’t be deleted.
  2. Verify timestamps: Check createdAt/deletedAt values in database.
  3. Run with dry-run: Preview what would be deleted.

Best practices

  1. Monitor database size before and after cleanup jobs
  2. Start with dry-run when adjusting retention periods
  3. Stagger schedules if adding custom cleanup jobs
  4. Archive before delete for cleanupAirflowDb in production
  5. Set alerts for failed cleanup jobs