Merge pull request #53322 from jsafrane/pv-mismatch-event

Automatic merge from submit-queue (batch tested with PRs 52395, 53322). 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>.

Send VolumeMismatch event to PVC

PV controller should send events to PVCs and not PVs when a PVC requests a PV that's either too small or has mismatching StorageClass.

Regular users can't see events on PVs so `kubectl describe pvc` is the only way how to tell user that something is wrong.

**Release note**:

```release-note
NONE
```

/sig storage
@kubernetes/sig-storage-pr-reviews
This commit is contained in:
Kubernetes Submit Queue 2017-10-02 08:36:15 -07:00 committed by GitHub
commit cf92925a20

View File

@ -319,7 +319,7 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(claim *v1.PersistentVol
if err = checkVolumeSatisfyClaim(volume, claim); err != nil {
glog.V(4).Infof("Can't bind the claim to volume %q: %v", volume.Name, err)
//send a event
ctrl.eventRecorder.Event(volume, v1.EventTypeWarning, events.VolumeMismatch, "Volume's size is smaller than requested or volume's class does not match with claim")
ctrl.eventRecorder.Event(claim, v1.EventTypeWarning, events.VolumeMismatch, "Volume's size is smaller than requested or volume's class does not match with claim")
//volume does not satisfy the requirements of the claim
if _, err = ctrl.updateClaimStatus(claim, v1.ClaimPending, nil); err != nil {
return err