mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #66106 from cofyc/fix64626
Automatic merge from submit-queue (batch tested with PRs 66011, 66111, 66106, 66039, 65745). 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>. Fix TestVolumeBinding out of sync errors **What this PR does / why we need it**: Invalidate `CheckVolumeBinding` predicate cache on PV update. CheckVolumeBinding predicate calls SchedulerVolumeBinder.FindPodVolumes which will cache PVs in PodBindingCache. When PV got updated, we should invalidate cache, otherwise PVAssumeCache.Assume will fail with out of sync error. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #64626 **Special notes for your reviewer**: When a PV is created, these operations happen asynchronously: - [pvcontroller.1] pv controller will update PV status from empty to `Available` - [scheduler.1] scheduler will find matching PVs and cache them in PodBindingCache in `CheckVolumeBinding` predicate - [scheduler.2] scheduler will assume matching PVs from PodBindingCache If [pvcontroller.1] happens between [scheduler.1] and [scheduler.2], and `CheckVolumeBinding` predicate result is cached in [scheduler.1], then scheduler will always use stale PodBindingCache in [scheduler.2] which [will cause out-of-sync error](https://github.com/kubernetes/kubernetes/blob/v1.12.0-alpha.0/pkg/controller/volume/persistentvolume/scheduler_assume_cache.go#L277) because resource version is old. **Release note**: ```release-note NONE ```
This commit is contained in:
commit
cc1d0e2021
@ -404,6 +404,11 @@ func (c *configFactory) onPvUpdate(old, new interface{}) {
|
||||
|
||||
func (c *configFactory) invalidatePredicatesForPvUpdate(oldPV, newPV *v1.PersistentVolume) {
|
||||
invalidPredicates := sets.NewString()
|
||||
// CheckVolumeBinding predicate calls SchedulerVolumeBinder.FindPodVolumes
|
||||
// which will cache PVs in PodBindingCache. When PV got updated, we should
|
||||
// invalidate cache, otherwise PVAssumeCache.Assume will fail with out of sync
|
||||
// error.
|
||||
invalidPredicates.Insert(predicates.CheckVolumeBindingPred)
|
||||
for k, v := range newPV.Labels {
|
||||
// If PV update modifies the zone/region labels.
|
||||
if isZoneRegionLabel(k) && !reflect.DeepEqual(v, oldPV.Labels[k]) {
|
||||
|
Loading…
Reference in New Issue
Block a user