code: func (ctrl *PersistentVolumeController) updateVolumePhaseWithEvent(volume *v1.PersistentVolume, phase v1.PersistentVolumePhase, eventtype, reason, message string) (*v1.PersistentVolume, error) {
  	klog.V(4).Infof("updating updateVolumePhaseWithEvent[%s]: set phase %s", volume.Name, phase)
  	if volume.Status.Phase == phase {
  		// Nothing to do.
  		klog.V(4).Infof("updating updateVolumePhaseWithEvent[%s]: phase %s already set", volume.Name, phase)
  		return volume, nil
  	}
  
  	newVol, err := ctrl.updateVolumePhase(volume, phase, message)
  	if err != nil {
  		return nil, err
  	}
  
  	// Emit the event only when the status change happens, not every time
  	// syncClaim is called.
  	klog.V(3).Infof("volume %q changed status to %q: %s", volume.Name, phase, message)
  	ctrl.eventRecorder.Event(newVol, eventtype, reason, message)
  
  	return newVol, nil
  }
docs: // updateVolumePhaseWithEvent saves new volume phase to API server and emits
  // given event on the volume. It saves the phase and emits the event only when
  // the phase has actually changed from the version saved in API server.