From c166743272c7e703be62060f63181b7dfb829593 Mon Sep 17 00:00:00 2001 From: Nikhita Raghunath Date: Mon, 16 Jul 2018 11:39:32 +0530 Subject: [PATCH] scheduler: fix panic while removing node from imageStates cache --- pkg/scheduler/cache/cache.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/scheduler/cache/cache.go b/pkg/scheduler/cache/cache.go index a7fd4bdfd0a..fd04a044c60 100644 --- a/pkg/scheduler/cache/cache.go +++ b/pkg/scheduler/cache/cache.go @@ -506,12 +506,12 @@ func (cache *schedulerCache) removeNodeImageStates(node *v1.Node) { state, ok := cache.imageStates[name] if ok { state.nodes.Delete(node.Name) - } - if len(state.nodes) == 0 { - // Remove the unused image to make sure the length of - // imageStates represents the total number of different - // images on all nodes - delete(cache.imageStates, name) + if len(state.nodes) == 0 { + // Remove the unused image to make sure the length of + // imageStates represents the total number of different + // images on all nodes + delete(cache.imageStates, name) + } } } }