Implement mcp purge command for registry cleanup
Add PurgeComponent RPC to the agent service that removes stale registry entries for components that are both gone (observed state is removed, unknown, or exited) and unwanted (not in any current service definition). Refuses to purge components with running or stopped containers. When all components of a service are purged, the service row is deleted too. Supports --dry-run to preview without modifying the database. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,15 @@ func CountEvents(db *sql.DB, service, component string, since time.Time) (int, e
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// DeleteComponentEvents deletes all events for a specific component.
|
||||
func DeleteComponentEvents(db *sql.DB, service, component string) error {
|
||||
_, err := db.Exec("DELETE FROM events WHERE service = ? AND component = ?", service, component)
|
||||
if err != nil {
|
||||
return fmt.Errorf("delete events %q/%q: %w", service, component, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PruneEvents deletes events older than the given time.
|
||||
func PruneEvents(db *sql.DB, before time.Time) (int64, error) {
|
||||
res, err := db.Exec(
|
||||
|
||||
Reference in New Issue
Block a user