Commit 3b0a6dac authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #25571 from gmarek/nodecontroller

Automatic merge from submit-queue NodeController doesn't evict Pods if no Nodes are Ready Fix #13412 #24597 When NodeControllers don't see any Ready Node it goes into "network segmentation mode". In this mode it cancels all evictions and don't evict any Pods. It leaves network segmentation mode when it sees at least one Ready Node. When leaving it resets all timers, so each Node has full grace period to reconnect to the cluster. cc @lavalamp @davidopp @mml @wojtek-t @fgrzadkowski
parents 2c038e38 6d27009d
...@@ -133,6 +133,18 @@ func (q *UniqueQueue) Head() (TimedValue, bool) { ...@@ -133,6 +133,18 @@ func (q *UniqueQueue) Head() (TimedValue, bool) {
return *result, true return *result, true
} }
// Clear removes all items from the queue and duplication preventing set.
func (q *UniqueQueue) Clear() {
q.lock.Lock()
defer q.lock.Unlock()
if q.queue.Len() > 0 {
q.queue = make(TimedQueue, 0)
}
if len(q.set) > 0 {
q.set = sets.NewString()
}
}
// RateLimitedTimedQueue is a unique item priority queue ordered by the expected next time // RateLimitedTimedQueue is a unique item priority queue ordered by the expected next time
// of execution. It is also rate limited. // of execution. It is also rate limited.
type RateLimitedTimedQueue struct { type RateLimitedTimedQueue struct {
...@@ -199,3 +211,8 @@ func (q *RateLimitedTimedQueue) Add(value string) bool { ...@@ -199,3 +211,8 @@ func (q *RateLimitedTimedQueue) Add(value string) bool {
func (q *RateLimitedTimedQueue) Remove(value string) bool { func (q *RateLimitedTimedQueue) Remove(value string) bool {
return q.queue.Remove(value) return q.queue.Remove(value)
} }
// Removes all items from the queue
func (q *RateLimitedTimedQueue) Clear() {
q.queue.Clear()
}
...@@ -261,3 +261,16 @@ func TestTryRemovingWhileTry(t *testing.T) { ...@@ -261,3 +261,16 @@ func TestTryRemovingWhileTry(t *testing.T) {
t.Fatalf("unexpected iterations: %d", count) t.Fatalf("unexpected iterations: %d", count)
} }
} }
func TestClear(t *testing.T) {
evictor := NewRateLimitedTimedQueue(flowcontrol.NewFakeAlwaysRateLimiter())
evictor.Add("first")
evictor.Add("second")
evictor.Add("third")
evictor.Clear()
if len(evictor.queue.queue) != 0 {
t.Fatalf("Clear should remove all elements from the queue.")
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment