mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #29093 from wojtek-t/fix_scheduler_crash
Automatic merge from submit-queue Fix crashes in schedulercache Fix #29090 @davidopp
This commit is contained in:
commit
450a71cd2a
@ -149,6 +149,7 @@ func (cache *schedulerCache) ForgetPod(pod *api.Pod) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
delete(cache.assumedPods, key)
|
||||||
delete(cache.podStates, key)
|
delete(cache.podStates, key)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("pod state wasn't assumed but get forgotten. Pod key: %v", key)
|
return fmt.Errorf("pod state wasn't assumed but get forgotten. Pod key: %v", key)
|
||||||
|
@ -457,6 +457,36 @@ func TestRemovePod(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestForgetPod(t *testing.T) {
|
||||||
|
nodeName := "node"
|
||||||
|
basePod := makeBasePod(nodeName, "test", "100m", "500", []api.ContainerPort{{HostPort: 80}})
|
||||||
|
tests := []struct {
|
||||||
|
pods []*api.Pod
|
||||||
|
}{{
|
||||||
|
pods: []*api.Pod{basePod},
|
||||||
|
}}
|
||||||
|
now := time.Now()
|
||||||
|
ttl := 10 * time.Second
|
||||||
|
|
||||||
|
for i, tt := range tests {
|
||||||
|
cache := newSchedulerCache(ttl, time.Second, nil)
|
||||||
|
for _, pod := range tt.pods {
|
||||||
|
if err := cache.assumePod(pod, now); err != nil {
|
||||||
|
t.Fatalf("assumePod failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, pod := range tt.pods {
|
||||||
|
if err := cache.ForgetPod(pod); err != nil {
|
||||||
|
t.Fatalf("ForgetPod failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cache.cleanupAssumedPods(now.Add(2 * ttl))
|
||||||
|
if n := cache.nodes[nodeName]; n != nil {
|
||||||
|
t.Errorf("#%d: expecting pod deleted and nil node info, get=%s", i, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkList1kNodes30kPods(b *testing.B) {
|
func BenchmarkList1kNodes30kPods(b *testing.B) {
|
||||||
cache := setupCacheOf1kNodes30kPods(b)
|
cache := setupCacheOf1kNodes30kPods(b)
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
Loading…
Reference in New Issue
Block a user