feat(system-info): add stale instance cleanup actions (#5953)
This commit is contained in:
@@ -75,6 +75,16 @@ func ListSystemInstances() ([]*SystemInstance, error) {
|
||||
return instances, err
|
||||
}
|
||||
|
||||
func DeleteStaleSystemInstances(now int64) (int64, error) {
|
||||
result := DB.Where("last_seen_at < ?", now-SystemInstanceStaleAfterSeconds).Delete(&SystemInstance{})
|
||||
return result.RowsAffected, result.Error
|
||||
}
|
||||
|
||||
func DeleteStaleSystemInstance(nodeName string, now int64) (bool, error) {
|
||||
result := DB.Where("node_name = ? AND last_seen_at < ?", nodeName, now-SystemInstanceStaleAfterSeconds).Delete(&SystemInstance{})
|
||||
return result.RowsAffected > 0, result.Error
|
||||
}
|
||||
|
||||
func (instance *SystemInstance) ToResponse(now int64) SystemInstanceResponse {
|
||||
status := SystemInstanceStatusOnline
|
||||
if now-instance.LastSeenAt > SystemInstanceStaleAfterSeconds {
|
||||
|
||||
Reference in New Issue
Block a user