Change:
/kind bug There are several error messages in the scheduler cache that are confusing to read, at least one of these surfaced up to end users via Events. I noticed these two in particular but there may be others: Whether or not these should actually be surfacing as events, the messages should be cleaned up.
cc
Seems that these are internal or implement details in scheduler, do our end users can fully understand what the events really mean? I think it is depend on our own implement. idea?
I believe, the problem is with in the message but I am not able to reproduce it, can you please share steps to reproduce this.
No unfortunately, one of our users reported seeing it when there system was in a bad state, not in a reproducible way. The point of the issue is just that the grammar in those messages is bad, which should be fixable even if you can't get them to fire.

Discussion:
cache.mu.Lock() defer cache.mu.Unlock() if _, ok := cache.podStates[key]; ok { <del> return fmt.Errorf("pod %v state wasn't initial but get assumed", key) </del> <ins> return fmt.Errorf("pod %v is not in the cache, so can't be assumed", key) </ins> } cache.addPod(pod)

currState, ok := cache.podStates[key] if ok && currState.pod.Spec.NodeName != pod.Spec.NodeName { <del> return fmt.Errorf("pod %v state was assumed on a different node", key) </del> <ins> return fmt.Errorf("pod %v was assumed on %v but assigned to %v", key, pod.Spec.NodeName, currState.pod.Spec.NodeName) </ins> } switch {

delete(cache.assumedPods, key) delete(cache.podStates, key) default: <del> return fmt.Errorf("pod %v state wasn't assumed but get forgotten", key) </del> <ins> return fmt.Errorf("pod %v wasn't assumed so cannot be forgotten", key) </ins> } return nil }

case ok && cache.assumedPods[key]: if currState.pod.Spec.NodeName != pod.Spec.NodeName { // The pod was added to a different node than it was assumed to. <del> glog.Warningf("Pod %v assumed to a different node than added to.", key) </del> <ins> glog.Warningf("Pod %v was assumed to be on %v but got added to %v", key, pod.Spec.NodeName, currState.pod.Spec.NodeName) </ins> // Clean this up. cache.removePod(currState.pod) cache.addPod(pod)

} cache.podStates[key] = ps default: <del> return fmt.Errorf("pod was already in added state. Pod key: %v", key) </del> <ins> return fmt.Errorf("pod %v was already in added state.", key) </ins> } return nil }

return err } default: <del> return fmt.Errorf("pod %v state wasn't added but get updated", key) </del> <ins> return fmt.Errorf("pod %v is not added to scheduler cache, so cannot be updated", key) </ins> } return nil }

// before Remove event, in which case the state would change from Assumed to Added. case ok && !cache.assumedPods[key]: if currState.pod.Spec.NodeName != pod.Spec.NodeName { <del> glog.Errorf("Pod %v removed from a different node than previously added to.", key) </del> <ins> glog.Errorf("Pod %v was assumed to be on %v but got added to %v", key, pod.Spec.NodeName, currState.pod.Spec.NodeName) </ins> glog.Fatalf("Schedulercache is corrupted and can badly affect scheduling decisions") } err := cache.removePod(currState.pod)

} delete(cache.podStates, key) default: <del> return fmt.Errorf("pod state wasn't added but get removed. Pod key: %v", key) </del> <ins> return fmt.Errorf("pod %v is not found in scheduler cache, so cannot be removed from it", key) </ins> } return nil }

podState, ok := cache.podStates[key] if !ok { <del> return nil, fmt.Errorf("pod %v does not exist", key) </del> <ins> return nil, fmt.Errorf("pod %v does not exist in scheduler cache", key) </ins> } return podState.pod, nil