k3s/pkg/scheduler
Kubernetes Submit Queue 6251402266
Merge pull request #63040 from misterikkit/ecache-race
Automatic merge from submit-queue (batch tested with PRs 62432, 62868, 63040). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

scheduler: fix race condition in equivalence cache

**What this PR does / why we need it**:
This adds an equivalence cache test to exercise the race condition observed in https://github.com/kubernetes/kubernetes/issues/62921 and then fixes the race.

The `Cache` interface needed a new method to check whether a `NodeInfo` is stale, and `genericScheduler` needed some plumbing to make the `Cache` object available to `podFitsOnNode()`.

The solution is, right before writing to the eCache, check the scheduler cache to see if the current `NodeInfo` object is out of date. If the node is out of date, then don't write to the eCache. If the `NodeInfo` is stale, it is because of a cache update that should also invalidate the eCache entry. That invalidation either happens before `podFitsOnNode()` acquires the eCache lock (original bug, so we don't do the write) or blocks until we release that lock (removing the potentially bad entry).

Fixes #62921 

**Special notes for your reviewer**:

**Release note**:

equivalence cache is still alpha, so no release note.
```release-note
NONE
```
/sig scheduling
/assign bsalalamat
/assign resouer
2018-04-25 12:56:14 -07:00
..
algorithm Merge pull request #63067 from k82cn/k8s_63027 2018-04-25 11:53:17 -07:00
algorithmprovider Disable pod preemption by config 2018-04-12 21:11:51 -07:00
api Add Ignorable flag to extender 2018-03-30 15:10:31 -07:00
core Check for old NodeInfo when updating equiv. cache. 2018-04-25 10:18:40 -07:00
factory Fix scheduler Pod informers to receive events when pods are scheduled by other schedulers. 2018-04-23 11:07:53 -07:00
metrics Fix golint errors in `pkg/scheduler` based on golint check 2018-02-08 15:22:47 +08:00
schedulercache Add IsUpTodate() to Cache interface. 2018-04-25 10:18:40 -07:00
testing Add IsUpTodate() to Cache interface. 2018-04-25 10:18:40 -07:00
util Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
volumebinder Use provided node object in volume binding predicate 2018-04-05 14:35:55 -07:00
BUILD Use pod UID as cache key instead of namespace/name 2018-03-13 10:25:37 -07:00
OWNERS Update OWNERS labels for cluster-lifecycle and scheduling 2018-04-05 16:25:04 -05:00
scheduler.go Merge pull request #62243 from resouer/fix-62068 2018-04-19 14:50:27 -07:00
scheduler_test.go Disable pod preemption by config 2018-04-12 21:11:51 -07:00
testutil.go remove unused func in FakeConfigurator of scheduler 2018-01-25 16:08:13 +08:00