mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Fixed persistent volume claim controllers processing an old claim.
Fixes #19860 (it may be easier to look at the issue to see exact sequence to reproduce the bug and understand the fix). When PersistentVolumeProvisionerController.reconcileClaim() is called with the same claim in short succession (e.g. the claim is created by an user and at the same time periodic check of all claims is scheduled), the second reconcileClaim() call gets an old copy of the claim as its parameter. The method should always reload the claim to get a fresh copy with all annotations, possibly added by previous reconcileClaim() call. The same applies to PersistentVolumeClaimBinder.syncClaim(). Also update all the test to store claims in "fake" API server before calling syncClaim and reconcileClaim.
This commit is contained in:
@@ -329,7 +329,15 @@ func syncVolume(volumeIndex *persistentVolumeOrderedIndex, binderClient binderCl
|
||||
}
|
||||
|
||||
func syncClaim(volumeIndex *persistentVolumeOrderedIndex, binderClient binderClient, claim *api.PersistentVolumeClaim) (err error) {
|
||||
glog.V(5).Infof("Synchronizing PersistentVolumeClaim[%s]\n", claim.Name)
|
||||
glog.V(5).Infof("Synchronizing PersistentVolumeClaim[%s] for binding", claim.Name)
|
||||
|
||||
// The claim may have been modified by parallel call to syncClaim, load
|
||||
// the current version.
|
||||
newClaim, err := binderClient.GetPersistentVolumeClaim(claim.Namespace, claim.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Cannot reload claim %s/%s: %v", claim.Namespace, claim.Name, err)
|
||||
}
|
||||
claim = newClaim
|
||||
|
||||
switch claim.Status.Phase {
|
||||
case api.ClaimPending:
|
||||
|
||||
Reference in New Issue
Block a user