Management Commands
Selected Django management commands of the Polycrate API for operations, maintenance and occasional data cleanup: alerts, artifacts, endpoints, IPAM, notifications, system configuration, pricing and workspaces.
Management Commands
This page describes selected Django management commands of the Polycrate API for operations, maintenance and occasional data cleanup. They are typically executed in the backend container:
docker compose exec backend python manage.py <command> [options]
The following sections do not replace the full --help output; they summarize purpose and typical options.
Alerts
delete_old_firing_alerts
Removes firing alerts that are older than a given threshold (in seconds). Useful for cleaning up old "stuck" firing states.
python manage.py delete_old_firing_alerts 86400 --dry-run
python manage.py delete_old_firing_alerts 86400
| Argument / option | Meaning |
|---|---|
age_seconds (positional) |
Alerts older than this number of seconds are considered |
--dry-run |
Only show, do not delete |
--batch-size |
Batch size (default: 500) |
fix_alert_states
Sets alert status from DEGRADED to READY (repair after inconsistent states), in batches.
python manage.py fix_alert_states --dry-run
python manage.py fix_alert_states
| Option | Meaning |
|---|---|
--dry-run |
Preview without changes |
--batch-size |
Batch size (default: 500) |
Artifacts
delete_repository_artifacts
Deletes all artifacts in a given artifact repository (UUID). Destructive; check with --dry-run first.
python manage.py delete_repository_artifacts <repository-uuid> --dry-run
python manage.py delete_repository_artifacts <repository-uuid> --yes
| Option | Meaning |
|---|---|
--dry-run |
Listing only |
--yes |
Skip confirmation prompt |
--verbose |
Details per artifact |
Endpoints
cleanup_duplicate_endpoints
Finds duplicate endpoints (same workspace + remote_address) and keeps the oldest entry. Requires an explicit preview or deletion flag.
python manage.py cleanup_duplicate_endpoints --dry-run
python manage.py cleanup_duplicate_endpoints --delete
python manage.py cleanup_duplicate_endpoints --dry-run --workspace <workspace-name>
| Option | Meaning |
|---|---|
--dry-run |
Only show |
--delete |
Actually delete duplicates |
--workspace |
Only one workspace |
Note: analyze_endpoint_results
Not required for regular operation. The command evaluates stored EndpointCheckResult data (PoP-based monitoring): filters by workspace, organization, PoP, time range; output as table, JSON or CSV. Useful for support, capacity questions or when the web UI is not sufficient for an evaluation. Details and all flags: python manage.py analyze_endpoint_results --help.
IPAM
cleanup_orphaned_ip_addresses
Cleans up IPAM IP addresses that have no meaningful managed_by relationship (including empty references or orphaned assignments). Typical workflow: first --dry-run, then --delete.
python manage.py cleanup_orphaned_ip_addresses --dry-run
python manage.py cleanup_orphaned_ip_addresses --delete
LoadBalancer-specific cleanup is performed when needed via the domain logic on the model (LoadbalancerInstance.cleanup_orphaned_ip_addresses), not via a separate management command.
Notifications
setup_notification_sink
Creates or updates the system-wide default notification sink (is_system_default). Supported kinds: mattermost, slack, msteams, email.
python manage.py setup_notification_sink --kind mattermost --webhook-url https://...
python manage.py setup_notification_sink --kind email --smtp-host mail.example.com --from-email noreply@example.com --to-emails ops@example.com
Required options depend on --kind (e.g. --webhook-url for chat integrations; for email, among others, SMTP and recipients). Further options include --organization, --test, --disable. Full parameters: --help.
test_mattermost_sink
Tests the Mattermost Native API integration (listing, test messages, notifications for downtime/maintenance/notes). For diagnosing and verifying notification sinks.
python manage.py test_mattermost_sink --list
python manage.py test_mattermost_sink --sink <name-or-id> --send-message
For further modes see python manage.py test_mattermost_sink --help.
System configuration
assign_system_owner
Sets or clears the system owner organization and/or the host K8s cluster in the SystemConfig.
python manage.py assign_system_owner --organization <name-or-uuid>
python manage.py assign_system_owner --cluster <name-or-uuid>
python manage.py assign_system_owner --clear-organization
python manage.py assign_system_owner --clear-cluster
Pricing
match_host_products
Assigns hosts to matching products (kind=host): first via provider_type_id, otherwise via the CPU/RAM specification in the product configuration.
python manage.py match_host_products --dry-run
python manage.py match_host_products
python manage.py match_host_products --force --reconcile
| Option | Meaning |
|---|---|
--dry-run |
Preview without saving |
--force |
Also reassign hosts that already have a product set |
--reconcile |
Additionally trigger reconcile_organization_product |
More context: Pricing & Business Layer.
Workspaces
cleanup_offline_agents
Performs the same cleanup as the background task: removes agents that have been offline longer than the configured retention (retention configured, among others, via SystemConfig, key AGENT_RETENTION_DAYS).
python manage.py cleanup_offline_agents --dry-run
python manage.py cleanup_offline_agents
run_action
Starts an ActionRun by its numeric ID (re-executes the associated action). Without --force, it aborts if the run is already running, success or failed.
python manage.py run_action <action_run_id>
python manage.py run_action <action_run_id> --force
See also
- Preconfigured data (seed) –
seed/seed_resyncfor providers, PoPs and DataSources - Endpoint Monitoring – functional context for endpoint checks