SLURM Periodic Usage Policy Configuration Guide
Overview
The SlurmPeriodicUsagePolicy enables automatic management of SLURM resource allocations with:
- Periodic usage tracking (monthly, quarterly, annual, or total)
- Automatic QoS adjustments based on usage thresholds
- Automatic period boundary reset (daily Celery beat task clears stale pauses/downscales when a new period starts)
- Carryover of unused allocations with configurable cap
- Grace periods for temporary overconsumption
- Integration with site agent for SLURM account management
Available Actions
Core Actions (Inherited from OfferingPolicy)
notify_organization_owners- Send email notifications to organization ownersnotify_external_user- Send notifications to external email addressesblock_creation_of_new_resources- Block creation of new SLURM resources
SLURM-Specific Actions
request_slurm_resource_downscaling- Apply slowdown QoS (setsresource.downscaled = True)request_slurm_resource_pausing- Apply blocked QoS (setsresource.paused = True)
How It Works
Threshold Triggers
The policy checks usage percentages and triggers actions at different thresholds:
- 80%: Notification threshold (hardcoded)
- 100%: Normal threshold - triggers
request_slurm_resource_downscaling - 120% (with 20% grace): Grace limit - triggers
request_slurm_resource_pausing
Site Agent Integration
When actions are triggered:
request_slurm_resource_downscaling→ Site agent appliesqos_downscaled(e.g., "limited")request_slurm_resource_pausing→ Site agent appliesqos_paused(e.g., "paused")- Normal state → Site agent applies
qos_default(e.g., "normal")
Evaluation Lifecycle and Concurrency
Each new or updated ComponentUsage queues an asynchronous evaluation of the
affected resource against every applicable policy. Staff-triggered
evaluate / force-period-reset API calls and the daily period-boundary task
queue evaluations too. As a result, several evaluations of the same resource
can run on different Celery workers at the same time — for example, one fired
by a high-usage report and another fired moments later by a corrected,
lower-usage report.
A single evaluation of one resource performs the following steps:
- Re-reads the resource's live usage for the current period (no value is cached from when the task was queued).
- Decides the target
paused/downscaledstate from that usage and the policy thresholds. - Applies the change and, if the state actually changed, publishes a STOMP message to the site agent.
To keep concurrent evaluations from interfering, evaluations of the same resource are serialized: each one locks the resource row and recomputes usage under the lock before deciding. This guarantees that the most recently committed usage wins — a slow evaluation that started from an old, high usage reading cannot overwrite a newer evaluation that has already restored the resource based on lower usage. Evaluations of different resources still run fully in parallel.
Note
Because the decision is always recomputed from live usage under the lock, re-running an evaluation is safe and idempotent. If usage has not changed, the re-run is a no-op and emits no STOMP message.
Configuration Examples
1. Basic Notification Policy
Send notifications when usage reaches 80%:
1 2 3 4 5 6 7 8 9 | |
2. Progressive QoS Management
Apply slowdown at 100% usage with notifications:
1 2 3 4 5 6 7 | |
3. Full Enforcement Policy
Complete enforcement with notifications, slowdown, and blocking:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
4. Organization-Specific Policy
Apply policy only to specific organization groups:
1 2 3 4 5 6 7 8 9 10 | |
Site Agent Configuration
Configure the site agent to handle QoS changes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Policy Parameters
Core Parameters
apply_to_all:Truefor all customers,Falsefor specific groupsorganization_groups: Specific groups if not applying to allactions: Comma-separated list of actions to trigger
SLURM-Specific Parameters
period: Billing period length —MONTH_1(monthly, default),MONTH_3(quarterly),MONTH_12(annual), orTOTAL(cumulative, never resets). Controls how_get_current_period()computes the billing window for usage calculations and carryover. Note: if the offering's components have alimit_periodset, it takes precedence over this field.limit_type:"GrpTRESMins","MaxTRESMins", or"GrpTRES"tres_billing_enabled: Use TRES billing units vs raw valuestres_billing_weights: Weight configuration for billing unitsgrace_ratio: Grace period ratio (0.2 = 20% overconsumption). The pause threshold is(1 + grace_ratio) * 100%. For example,grace_ratio=0.2means resources are paused at 120% usage.carryover_enabled: Allow unused allocation carryover between periodscarryover_factor: Maximum percentage of base allocation that can carry over from unused previous period (integer, 0-100, default: 50). For example,carryover_factor=50means up to 50% of the base limit can be carried over. Unused allocation from the previous period ismax(0, base - prev_usage), capped at(carryover_factor / 100) * base.raw_usage_reset: Reset SLURM raw usage at period transitionsqos_strategy:"threshold"or"progressive"
Usage Scenarios
Scenario 1: Academic Institution with Quarterly Allocations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Scenario 2: Commercial Cloud with Strict Limits
1 2 3 4 5 6 7 8 | |
Scenario 3: Research Consortium with Flexible Limits
1 2 3 4 5 6 7 8 9 | |
Worked Examples
The configuration snippets above define policies; the timelines below show how
a policy behaves as real usage evolves. They assume a monthly policy with a
1000 node-hour limit, grace_ratio=0.2 (pause at 120%), and
actions="notify_organization_owners,request_slurm_resource_downscaling,request_slurm_resource_pausing".
Example A: A project that overshoots mid-month, then is topped up
A research project burns through its monthly allocation early, gets throttled, and is restored after the owner buys more node-hours.
| Day | Usage | % of limit | Evaluation result | Resource state | Site agent QoS |
|---|---|---|---|---|---|
| 1 | 200 | 20% | below thresholds | normal | normal |
| 8 | 820 | 82% | notify owners | normal | normal |
| 14 | 1010 | 101% | downscale | downscaled | slowdown |
| 18 | 1250 | 125% | downscale + pause | downscaled + paused | blocked |
| 20 | limit raised to 2000 → 1250/2000 = 63% | 63% | clear pause + downscale | normal | normal |
Each row is the state after that day's usage report is evaluated. Note that raising the limit on day 20 drops the percentage below all thresholds, so the next evaluation restores the resource — no manual QoS change is needed.
Example B: A corrected usage report (concurrency-safe restore)
Accounting first reports a usage spike, then immediately corrects it down. Two evaluations race, but the resource still ends in the correct, restored state.
| Time | Event | Usage seen | Evaluation outcome |
|---|---|---|---|
| 10:00:00 | Usage reported as 1500 (150%) | 150% | evaluation A queued → pause + downscale |
| 10:00:03 | Correction: usage overwritten to 0 | 0% | evaluation B queued → clear all |
| 10:00:04 | Evaluation B commits first | 0% | resource restored to normal |
| 10:00:07 | Evaluation A finally runs | 0% (re-read under lock) | no-op — usage is now 0%, nothing to pause |
Because evaluation A recomputes usage under the row lock, it sees the corrected
0% rather than the stale 150% it was triggered with, and leaves the restored
state untouched. The final state is normal / qos_default. See
Evaluation Lifecycle and Concurrency.
Example C: Carryover across a period boundary
A monthly policy with carryover_enabled=True and carryover_factor=50
(limit 1000) lets an under-using month lift the next month's effective ceiling.
| Period | Base limit | Prev-period usage | Carryover | Effective limit | 700 node-hours used → % |
|---|---|---|---|---|---|
| January | 1000 | — | 0 | 1000 | 70% → normal |
| February | 1000 | 300 (Jan) | min(700, 500) = 500 | 1500 | 700/1500 = 47% → normal |
| March | 1000 | 1400 (Feb, over) | 0 | 1000 | 700/1000 = 70% → normal |
January's unused 700 node-hours carries into February capped at 50% of the base (500), raising February's ceiling to 1500. February overshoots, so March starts fresh at the base limit with no carryover. See Debug Carryover Calculations for the formula.
API Usage
Create Policy via API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Check Policy Status
1 2 | |
Evaluation and Testing
Staff-Only API Actions
Three staff-only API actions allow testing and managing policy evaluation directly from the frontend or API without waiting for automatic triggers.
Dry Run
Calculate usage percentages and show what actions would be triggered without applying any changes.
1 2 3 4 | |
Optionally scope to a single resource:
1 2 3 4 | |
Response includes per-resource: usage_percentage, current paused/downscaled state, and would_trigger actions.
Evaluate (Synchronous)
Run the full evaluation: calculate usage, apply actions (pause/downscale/notify), and create evaluation log entries.
1 2 3 4 | |
Response includes per-resource: usage_percentage, actions_taken, previous_state, and new_state.
Force Period Reset (Staff-Only)
Force-trigger a period boundary reset for a specific policy. This is useful after a Celery beat outage, or to immediately unblock resources that are still paused/downscaled from a previous period.
The action finds all active resources under the policy's offering that are currently paused or downscaled and have usage below 100% in the current period, then re-evaluates them synchronously — which removes the stale pause/downscale flags and sends STOMP messages to the site agent.
1 2 3 4 5 | |
Optionally scope to a single resource:
1 2 3 4 | |
Response includes per-resource: usage_percentage, actions_taken, previous_state, and new_state.
Frontend
Staff users see an Evaluate button on the SLURM policy configuration panel. This opens a dialog with:
- Dry run — read-only preview of what would happen
- Evaluate now — runs the full evaluation synchronously and shows results
Management Commands
Three management commands are available for CLI-based testing and monitoring:
evaluate_slurm_policy
1 2 3 4 5 6 7 8 9 10 11 | |
slurm_policy_status
1 2 3 4 5 6 7 8 | |
cleanup_slurm_logs
1 2 | |
Monitoring and Observability
Evaluation Log
Every policy evaluation creates a SlurmPolicyEvaluationLog record with:
usage_percentage— resource usage at the time of evaluationgrace_limit_percentage— the grace threshold that was appliedactions_taken— list of actions triggered (e.g.["downscale", "notify"])previous_state/new_state—pausedanddownscaledflags before and afterstomp_message_sent— whether a STOMP message was published to the site agentsite_agent_confirmed— whether the site agent reported success (null = pending)site_agent_response— full response from the site agent
Command History
When STOMP messages are sent to the site agent, each generated SLURM command is recorded in SlurmCommandHistory:
command_type— e.g.fairshare,limits,qos,reset_usageshell_command— the actualsacctmgrcommandexecution_mode—productionoremulatorsuccess/error_message— filled in by site agent report-back
API Endpoints
1 2 3 4 5 6 7 8 | |
Frontend Execution Log
The SLURM policy panel includes:
- Status summary — inline card showing last evaluation timestamp, count of paused/downscaled resources, and site agent confirmation status
- Execution log dialog with two tabs:
- Evaluation History — table with timestamps, resource names, usage percentages (colour-coded), action badges, and state transitions
- Command History — table with command types, shell commands, execution mode, and success/failure status
Structured Events
Policy evaluations emit a SLURM_POLICY_EVALUATION event type, visible in the Waldur events system.
Automatic Period Boundary Reset
A daily Celery beat task (reset-slurm-policy-periods, runs at 01:00) ensures that resources paused or downscaled in a previous period are automatically unblocked when the new period starts with zero usage.
For each SlurmPeriodicUsagePolicy (except those with period=TOTAL), the task:
- Finds active resources that are still
paused=Trueordownscaled=True - Checks if their usage in the current period is below 100%
- If so, queues
evaluate_resource_against_policywhich clears the stale flags and sends STOMP messages to the site agent
This is idempotent — safe to re-run and catches up automatically after Celery beat outages. For immediate manual intervention, use the staff-only force-period-reset API action.
Log Retention
Evaluation logs are automatically cleaned up by a daily Celery beat task (cleanup-slurm-evaluation-logs, runs at 03:00). The retention period is configurable via:
- Constance setting:
SLURM_POLICY_EVALUATION_LOG_RETENTION_DAYS(default: 90 days) - HomePort admin: Administration > Marketplace > SLURM policy
Check Resource Usage (Django Shell)
1 2 3 4 5 | |
Debug Carryover Calculations
Carryover allows unused allocation from the previous period to increase the current period's effective limit. The formula is:
unused = max(0, base_limit - previous_period_usage)cap = (carryover_factor / 100) * base_limitcarryover = min(unused, cap)effective_limit = base_limit + carryover
Example: base limit 1000, previous usage 400, carryover_factor 50 (i.e. 50%):
unused = max(0, 1000 - 400) = 600cap = (50 / 100) * 1000 = 500carryover = min(600, 500) = 500effective_limit = 1000 + 500 = 1500
If the previous period was fully used (e.g., usage 1200), carryover is 0.
1 2 3 | |
Site Agent Feedback Loop
After the site agent applies SLURM commands, it reports results back to Waldur:
- Site agent receives STOMP message with
action: apply_periodic_settings - Site agent executes
sacctmgrcommands via the backend - Site agent POSTs the result to
/api/marketplace-slurm-periodic-usage-policies/{policy_uuid}/report-command-result/ - Waldur updates
SlurmCommandHistory.successandSlurmPolicyEvaluationLog.site_agent_confirmed
The STOMP message payload includes policy_uuid so the site agent knows which policy endpoint to report to.
Best Practices
- Start with Notifications: Begin with notification-only policies to understand usage patterns
- Use Dry Run First: Run
waldur evaluate_slurm_policy --dry-runor the frontend Dry Run button before enabling enforcement - Test in Staging: Validate policies in a test environment first
- Monitor Grace Periods: Ensure grace ratios align with user needs
- Review Evaluation Logs: Check the execution log regularly for unexpected actions
- Regular Review: Review carryover and decay settings quarterly
- Clear Communication: Inform users about thresholds and consequences
Troubleshooting Common Issues
Policy Not Triggering
- Check that
apply_to_all=Trueor resource's customer is inorganization_groups - Verify component usage data exists for the current period
- Ensure resource is not in TERMINATED state
- Run
waldur evaluate_slurm_policy --policy <UUID> --dry-runto see current usage percentages
QoS Not Changing
- Verify site agent configuration has correct QoS names
- Check site agent logs for SLURM command execution
- Ensure resource backend_id matches SLURM account name
- Check the command history endpoint or
waldur slurm_policy_statusfor sent commands and site agent responses
Incorrect Usage Calculations
- Review carryover settings and carryover factor
- Check billing period alignment — the
periodfield controls boundaries:MONTH_1(monthly, default),MONTH_3(quarterly),MONTH_12(annual),TOTAL(cumulative). Note that offering componentlimit_periodoverrides this field if set. - Verify component type matches between policy and usage data
Resources Still Paused After New Period Starts
- The
reset-slurm-policy-periodstask runs at 01:00 daily and should clear stale pauses. Check Celery worker logs for errors. - Use the staff
force-period-resetendpoint to manually trigger a reset:POST /api/marketplace-slurm-periodic-usage-policies/POLICY_UUID/force-period-reset/ - Verify that the policy's
periodis not set toTOTAL(total-period policies never auto-reset)
No Evaluation Logs Appearing
- Confirm the evaluation was triggered (check Celery worker logs)
- Verify the policy has resources in the offering
- Use the staff Evaluate button or
waldur evaluate_slurm_policy --syncto run synchronously and see immediate results
Site Agent Not Reporting Back
- Check that
policy_uuidis present in the STOMP message payload - Verify the site agent has network access to the Waldur API
- Check site agent logs for HTTP errors when POSTing to
report-command-result
Migration from Manual Management
For organisations transitioning from manual SLURM management:
- Audit Current Allocations: Document existing quotas and QoS settings
- Create Initial Policies: Start with generous grace periods
- Enable Notifications First: Monitor before enforcing — use the execution log to verify calculations
- Dry Run Testing: Use the staff dry-run feature to validate policy behaviour before enabling enforcement actions
- Gradual Enforcement: Phase in QoS changes over 2-3 quarters
- User Training: Educate users about automatic management