flock-agent: GC orphaned allocations; retry birdc on socket-not-ready (#5)
flock / release (push) Successful in 1m7s
flock / release (push) Successful in 1m7s
flock-agent: GC orphaned allocations; retry birdc on socket-not-ready
This commit was merged in pull request #5.
This commit is contained in:
@@ -330,3 +330,34 @@ func anycastStrings(ips []net.IP) []string {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// orphanedCommitted returns committed allocations whose owner pod is no
|
||||
// longer running on this node. An allocation is orphaned when:
|
||||
// - lookupUID cannot find the pod by namespace+name (pod deleted or
|
||||
// rescheduled to another node), OR
|
||||
// - the pod is found but its UID doesn't match the allocation's OwnerUID
|
||||
// (pod was replaced — name reuse after deletion).
|
||||
//
|
||||
// Allocations with an empty OwnerUID are only considered orphaned if the
|
||||
// pod is absent; an empty UID prevents a false-positive on legacy entries
|
||||
// that predate the UID field.
|
||||
//
|
||||
// lookupUID returns the current pod UID and found=true when the pod is on
|
||||
// this node; found=false when absent. Callers plug in the live PodCache.
|
||||
func orphanedCommitted(allocations []Allocation, lookupUID func(ns, name string) (uid string, found bool)) []Allocation {
|
||||
var out []Allocation
|
||||
for _, a := range allocations {
|
||||
if a.State != StateCommitted {
|
||||
continue
|
||||
}
|
||||
uid, found := lookupUID(a.Namespace, a.PodName)
|
||||
if !found {
|
||||
out = append(out, a)
|
||||
continue
|
||||
}
|
||||
if a.OwnerUID != "" && uid != a.OwnerUID {
|
||||
out = append(out, a)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user