mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 21:12:07 +00:00
optimize evict sandbox logic
This commit is contained in:
parent
ccf7ddacfc
commit
db5d74935e
@ -293,7 +293,7 @@ func (cgc *containerGC) evictSandboxes(ctx context.Context, evictNonDeletedPods
|
|||||||
sandboxIDs.Insert(container.PodSandboxId)
|
sandboxIDs.Insert(container.PodSandboxId)
|
||||||
}
|
}
|
||||||
|
|
||||||
sandboxesByPod := make(sandboxesByPodUID)
|
sandboxesByPod := make(sandboxesByPodUID, len(sandboxes))
|
||||||
for _, sandbox := range sandboxes {
|
for _, sandbox := range sandboxes {
|
||||||
podUID := types.UID(sandbox.Metadata.Uid)
|
podUID := types.UID(sandbox.Metadata.Uid)
|
||||||
sandboxInfo := sandboxGCInfo{
|
sandboxInfo := sandboxGCInfo{
|
||||||
@ -301,13 +301,8 @@ func (cgc *containerGC) evictSandboxes(ctx context.Context, evictNonDeletedPods
|
|||||||
createTime: time.Unix(0, sandbox.CreatedAt),
|
createTime: time.Unix(0, sandbox.CreatedAt),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set ready sandboxes to be active.
|
// Set ready sandboxes and sandboxes that still have containers to be active.
|
||||||
if sandbox.State == runtimeapi.PodSandboxState_SANDBOX_READY {
|
if sandbox.State == runtimeapi.PodSandboxState_SANDBOX_READY || sandboxIDs.Has(sandbox.Id) {
|
||||||
sandboxInfo.active = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sandboxes that still have containers to be active.
|
|
||||||
if sandboxIDs.Has(sandbox.Id) {
|
|
||||||
sandboxInfo.active = true
|
sandboxInfo.active = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user