Add Floating IP scanning and a durable address registry with configurable history depth
Adds POST /api/v1/admin/ips/scan (plus an optional periodic ticker) to
discover free Floating IPs in the OpenStack project and feed them straight
into the check queue. More importantly, decouples check/event history from
ip_queue's lifecycle: a new ip_registry table (migration 0007) gives every
address ever submitted a durable identity, so deleting it from the queue no
longer destroys its history — it's still reachable via the new
GET /api/v1/admin/registry[/{ip}] endpoints and the dashboard's /registry
pages, with retention depth configurable in check cycles per address
(history_retention_cycles, 0 = unlimited).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
78b20fa5be
commit
582b44f314
47 files changed
+1781
-107
No files matched your search
+37
-3
@@ -95,12 +95,21 @@ type IPQueueItem struct {
|
||||
FIPAssociatedAt *time.Time
|
||||
AggregatedAt *time.Time
|
||||
FIPReleasedAt *time.Time
|
||||
RegistryID int64
|
||||
CycleID int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type Check struct {
|
||||
ID int64
|
||||
ID int64
|
||||
RegistryID int64
|
||||
CycleID int
|
||||
// IPID is the ip_queue row this check was originally recorded against.
|
||||
// It's cleared to 0 (SQL NULL) if that row was later deleted — history
|
||||
// stays reachable via RegistryID/CycleID regardless (see
|
||||
// migrations/0007_ip_registry.sql). 0 is never a valid ip_queue id
|
||||
// (AUTOINCREMENT starts at 1), so it unambiguously means "orphaned."
|
||||
IPID int64
|
||||
IPAddress string
|
||||
AttemptNumber int
|
||||
@@ -115,11 +124,33 @@ type Check struct {
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
// RegistryItem is a durable per-address record that survives an address
|
||||
// being removed from ip_queue and later re-added — see
|
||||
// migrations/0007_ip_registry.sql. NextCycle is the cycle_id that will be
|
||||
// assigned the next time this address is (re)submitted; it only ever
|
||||
// increases, so cycle_id stays unique for this address even across
|
||||
// ip_queue row deletion/recreation.
|
||||
type RegistryItem struct {
|
||||
ID int64
|
||||
IPAddress string
|
||||
FirstSeenAt time.Time
|
||||
LastSeenAt time.Time
|
||||
NextCycle int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
ID int64
|
||||
SourceType string
|
||||
SourceID string
|
||||
IPID *int64
|
||||
// RegistryID/CycleID are resolved from IPID at insert time (see
|
||||
// InsertEvent) and stay set even after the ip_queue row IPID pointed to
|
||||
// is later deleted, so retention pruning can cut events at the same
|
||||
// cycle boundary as checks — see migrations/0007_ip_registry.sql.
|
||||
RegistryID int64
|
||||
CycleID int
|
||||
EventType string
|
||||
Payload string
|
||||
OccurredAt time.Time
|
||||
@@ -179,8 +210,11 @@ type DeleteIPsResult struct {
|
||||
// admin-configurable at runtime (see queries_settings.go).
|
||||
type Settings struct {
|
||||
FIPSettleSeconds int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
// HistoryRetentionCycles caps how many recent check cycles are kept per
|
||||
// registry address (see PruneRegistryHistory); 0 means unlimited.
|
||||
HistoryRetentionCycles int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// InboundChecksSettings is the singleton row describing what the prober
|
||||
|
||||
Reference in new issue
Block a user