feat(limits): add delete_limits_set API#3493
Conversation
Add delete_limits_set(name) to remove a limits set from all telemetry items, the limits_sets hash, and current_limits_settings. Guards against deleting the DEFAULT and currently active sets. Batches the current_limits_settings cleanup into a single hmset to avoid a Redis round trip per item. Adds Ruby and Python implementations, script disconnect wrappers, JS API binding, docs, and tests. Closes #3464 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3493 +/- ##
==========================================
- Coverage 79.25% 79.24% -0.01%
==========================================
Files 689 689
Lines 57293 57358 +65
Branches 728 728
==========================================
+ Hits 45406 45452 +46
- Misses 11809 11828 +19
Partials 78 78
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
clayandgen
left a comment
There was a problem hiding this comment.
SonarQube findings should be easy to address
| if limits_set not in LimitsEventTopic.sets(scope=scope): | ||
| raise RuntimeError(f"Limits set '{limits_set}' does not exist") | ||
|
|
||
| # Remove the limits set from every telemetry item definition |
There was a problem hiding this comment.
I wouldn't bother deleting from the TargetModel. Leave that for an updated plugin install. Just remove from list of limits sets.
| end | ||
|
|
||
| # Remove the limits set from every telemetry item definition | ||
| TargetModel.names(scope: scope).each do |target_name| |
There was a problem hiding this comment.
I wouldn't bother deleting from the TargetModel. Leave that for an updated plugin install. Just remove from list of limits sets.




Summary
Adds a
delete_limits_set(name)API (Ruby + Python) to remove a limits set, as requested in #3464.Cleanup performed:
TargetModelpackets<scope>__current_limits_settingshdelthe set from<scope>__limits_setsopenc3_limits_eventsneeds no cleanup (append-only, capped at 1000)Guards: refuses to delete
DEFAULT, the currently active set, or a non-existent set.Design decisions (the open questions in the issue)
TargetModelpacket item definitions too (not justcurrent_limits_settings) for a complete removal.LIMITS_DELETE_SETevent type. That would require newLimits#remove_setinfrastructure; a deleted (non-active) set lingering in a running microservice's memory is harmless and is cleared on the next restart/resync fromcurrent_limits_settings.Performance
hsetcalls).current_limits_settingscleanup is batched into a singlehmset/hset mappingrather than one Redis round trip per item — important since this hash can be large (e.g. 100 packets × 1000 items).Changes
openc3/lib/openc3/api/limits_api.rbopenc3/lib/openc3/topics/limits_event_topic.rbopenc3/lib/openc3/script/limits.rbopenc3/python/openc3/api/limits_api.pyopenc3/python/openc3/topics/limits_event_topic.pyopenc3/python/openc3/script/limits.pyopenc3-js-common/src/services/openc3Api.jsdocs.openc3.com/docs/guides/scripting-api.mdTesting
Closes #3464
🤖 Generated with Claude Code