Merge pull request #26733 from pmorie/pv-controller-typos

Automatic merge from submit-queue

Fix typo and linewrap comments in PV controller

Fix some typos and linewrap long comments that I found while going over this code investigating something.
This commit is contained in:
k8s-merge-robot 2016-06-03 04:51:08 -07:00
commit 59e008dbcb
2 changed files with 41 additions and 27 deletions

View File

@ -78,9 +78,9 @@ const annBoundByController = "pv.kubernetes.io/bound-by-controller"
const annClass = "volume.alpha.kubernetes.io/storage-class" const annClass = "volume.alpha.kubernetes.io/storage-class"
// This annotation is added to a PV that has been dynamically provisioned by // This annotation is added to a PV that has been dynamically provisioned by
// Kubernetes. It's value is name of volume plugin that created the volume. // Kubernetes. Its value is name of volume plugin that created the volume.
// It serves both user (to show where a PV comes from) and Kubernetes (to // It serves both user (to show where a PV comes from) and Kubernetes (to
// recognize dynamically provisioned PVs in its decissions). // recognize dynamically provisioned PVs in its decisions).
const annDynamicallyProvisioned = "pv.kubernetes.io/provisioned-by" const annDynamicallyProvisioned = "pv.kubernetes.io/provisioned-by"
// Name of a tag attached to a real volume in cloud (e.g. AWS EBS or GCE PD) // Name of a tag attached to a real volume in cloud (e.g. AWS EBS or GCE PD)
@ -103,7 +103,7 @@ const createProvisionedPVInterval = 10 * time.Second
// PersistentVolumeController is a controller that synchronizes // PersistentVolumeController is a controller that synchronizes
// PersistentVolumeClaims and PersistentVolumes. It starts two // PersistentVolumeClaims and PersistentVolumes. It starts two
// framework.Controllers that watch PerstentVolume and PersistentVolumeClaim // framework.Controllers that watch PersistentVolume and PersistentVolumeClaim
// changes. // changes.
type PersistentVolumeController struct { type PersistentVolumeController struct {
volumeController *framework.Controller volumeController *framework.Controller
@ -670,8 +670,8 @@ func (ctrl *PersistentVolumeController) bindVolumeToClaim(volume *api.Persistent
return volume, nil return volume, nil
} }
// bindClaimToVolume modifes given claim to be bound to a volume and saves it to // bindClaimToVolume modifies the given claim to be bound to a volume and
// API server. The volume is not modified in this method! // saves it to API server. The volume is not modified in this method!
func (ctrl *PersistentVolumeController) bindClaimToVolume(claim *api.PersistentVolumeClaim, volume *api.PersistentVolume) (*api.PersistentVolumeClaim, error) { func (ctrl *PersistentVolumeController) bindClaimToVolume(claim *api.PersistentVolumeClaim, volume *api.PersistentVolume) (*api.PersistentVolumeClaim, error) {
glog.V(4).Infof("updating PersistentVolumeClaim[%s]: binding to %q", claimToClaimKey(claim), volume.Name) glog.V(4).Infof("updating PersistentVolumeClaim[%s]: binding to %q", claimToClaimKey(claim), volume.Name)
@ -1198,7 +1198,7 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
} }
if err != nil { if err != nil {
// Delete failed several times. There is orphaned volume and there // Delete failed several times. There is an orphaned volume and there
// is nothing we can do about it. // is nothing we can do about it.
strerr := fmt.Sprintf("Error cleaning provisioned volume for claim %s: %v. Please delete manually.", claimToClaimKey(claim), err) strerr := fmt.Sprintf("Error cleaning provisioned volume for claim %s: %v. Please delete manually.", claimToClaimKey(claim), err)
glog.V(2).Info(strerr) glog.V(2).Info(strerr)
@ -1210,7 +1210,7 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
} }
// getProvisionedVolumeNameForClaim returns PV.Name for the provisioned volume. // getProvisionedVolumeNameForClaim returns PV.Name for the provisioned volume.
// The name must be unique // The name must be unique.
func (ctrl *PersistentVolumeController) getProvisionedVolumeNameForClaim(claim *api.PersistentVolumeClaim) string { func (ctrl *PersistentVolumeController) getProvisionedVolumeNameForClaim(claim *api.PersistentVolumeClaim) string {
return "pvc-" + string(claim.UID) return "pvc-" + string(claim.UID)
} }
@ -1242,7 +1242,7 @@ func (ctrl *PersistentVolumeController) scheduleOperation(operationName string,
return return
} }
// Run the operation in separate goroutine // Run the operation in a separate goroutine
go func() { go func() {
glog.V(4).Infof("scheduleOperation[%s]: running the operation", operationName) glog.V(4).Infof("scheduleOperation[%s]: running the operation", operationName)
operation(arg) operation(arg)

View File

@ -26,7 +26,8 @@ import (
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
) )
// persistentVolumeOrderedIndex is a cache.Store that keeps persistent volumes indexed by AccessModes and ordered by storage capacity. // persistentVolumeOrderedIndex is a cache.Store that keeps persistent volumes
// indexed by AccessModes and ordered by storage capacity.
type persistentVolumeOrderedIndex struct { type persistentVolumeOrderedIndex struct {
store cache.Indexer store cache.Indexer
} }
@ -35,7 +36,8 @@ func newPersistentVolumeOrderedIndex() persistentVolumeOrderedIndex {
return persistentVolumeOrderedIndex{cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{"accessmodes": accessModesIndexFunc})} return persistentVolumeOrderedIndex{cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{"accessmodes": accessModesIndexFunc})}
} }
// accessModesIndexFunc is an indexing function that returns a persistent volume's AccessModes as a string // accessModesIndexFunc is an indexing function that returns a persistent
// volume's AccessModes as a string
func accessModesIndexFunc(obj interface{}) ([]string, error) { func accessModesIndexFunc(obj interface{}) ([]string, error) {
if pv, ok := obj.(*api.PersistentVolume); ok { if pv, ok := obj.(*api.PersistentVolume); ok {
modes := api.GetAccessModesAsString(pv.Spec.AccessModes) modes := api.GetAccessModesAsString(pv.Spec.AccessModes)
@ -44,7 +46,8 @@ func accessModesIndexFunc(obj interface{}) ([]string, error) {
return []string{""}, fmt.Errorf("object is not a persistent volume: %v", obj) return []string{""}, fmt.Errorf("object is not a persistent volume: %v", obj)
} }
// listByAccessModes returns all volumes with the given set of AccessModeTypes. The list is unsorted! // listByAccessModes returns all volumes with the given set of
// AccessModeTypes. The list is unsorted!
func (pvIndex *persistentVolumeOrderedIndex) listByAccessModes(modes []api.PersistentVolumeAccessMode) ([]*api.PersistentVolume, error) { func (pvIndex *persistentVolumeOrderedIndex) listByAccessModes(modes []api.PersistentVolumeAccessMode) ([]*api.PersistentVolume, error) {
pv := &api.PersistentVolume{ pv := &api.PersistentVolume{
Spec: api.PersistentVolumeSpec{ Spec: api.PersistentVolumeSpec{
@ -70,14 +73,19 @@ type matchPredicate func(compareThis, toThis *api.PersistentVolume) bool
// find returns the nearest PV from the ordered list or nil if a match is not found // find returns the nearest PV from the ordered list or nil if a match is not found
func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *api.PersistentVolumeClaim, matchPredicate matchPredicate) (*api.PersistentVolume, error) { func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *api.PersistentVolumeClaim, matchPredicate matchPredicate) (*api.PersistentVolume, error) {
// PVs are indexed by their access modes to allow easier searching. Each index is the string representation of a set of access modes. // PVs are indexed by their access modes to allow easier searching. Each
// There is a finite number of possible sets and PVs will only be indexed in one of them (whichever index matches the PV's modes). // index is the string representation of a set of access modes. There is a
// finite number of possible sets and PVs will only be indexed in one of
// them (whichever index matches the PV's modes).
// //
// A request for resources will always specify its desired access modes. Any matching PV must have at least that number // A request for resources will always specify its desired access modes.
// of access modes, but it can have more. For example, a user asks for ReadWriteOnce but a GCEPD is available, which is ReadWriteOnce+ReadOnlyMany. // Any matching PV must have at least that number of access modes, but it
// can have more. For example, a user asks for ReadWriteOnce but a GCEPD
// is available, which is ReadWriteOnce+ReadOnlyMany.
// //
// Searches are performed against a set of access modes, so we can attempt not only the exact matching modes but also // Searches are performed against a set of access modes, so we can attempt
// potential matches (the GCEPD example above). // not only the exact matching modes but also potential matches (the GCEPD
// example above).
allPossibleModes := pvIndex.allPossibleMatchingAccessModes(claim.Spec.AccessModes) allPossibleModes := pvIndex.allPossibleMatchingAccessModes(claim.Spec.AccessModes)
var smallestVolume *api.PersistentVolume var smallestVolume *api.PersistentVolume
@ -167,19 +175,23 @@ func matchStorageCapacity(pvA, pvB *api.PersistentVolume) bool {
return aSize <= bSize return aSize <= bSize
} }
// allPossibleMatchingAccessModes returns an array of AccessMode arrays that can satisfy a user's requested modes. // allPossibleMatchingAccessModes returns an array of AccessMode arrays that
// can satisfy a user's requested modes.
// //
// see comments in the Find func above regarding indexing. // see comments in the Find func above regarding indexing.
// //
// allPossibleMatchingAccessModes gets all stringified accessmodes from the index and returns all those that // allPossibleMatchingAccessModes gets all stringified accessmodes from the
// contain at least all of the requested mode. // index and returns all those that contain at least all of the requested
// mode.
// //
// For example, assume the index contains 2 types of PVs where the stringified accessmodes are: // For example, assume the index contains 2 types of PVs where the stringified
// accessmodes are:
// //
// "RWO,ROX" -- some number of GCEPDs // "RWO,ROX" -- some number of GCEPDs
// "RWO,ROX,RWX" -- some number of NFS volumes // "RWO,ROX,RWX" -- some number of NFS volumes
// //
// A request for RWO could be satisfied by both sets of indexed volumes, so allPossibleMatchingAccessModes returns: // A request for RWO could be satisfied by both sets of indexed volumes, so
// allPossibleMatchingAccessModes returns:
// //
// [][]api.PersistentVolumeAccessMode { // [][]api.PersistentVolumeAccessMode {
// []api.PersistentVolumeAccessMode { // []api.PersistentVolumeAccessMode {
@ -190,7 +202,8 @@ func matchStorageCapacity(pvA, pvB *api.PersistentVolume) bool {
// }, // },
// } // }
// //
// A request for RWX can be satisfied by only one set of indexed volumes, so the return is: // A request for RWX can be satisfied by only one set of indexed volumes, so
// the return is:
// //
// [][]api.PersistentVolumeAccessMode { // [][]api.PersistentVolumeAccessMode {
// []api.PersistentVolumeAccessMode { // []api.PersistentVolumeAccessMode {
@ -198,8 +211,8 @@ func matchStorageCapacity(pvA, pvB *api.PersistentVolume) bool {
// }, // },
// } // }
// //
// This func returns modes with ascending levels of modes to give the user what is closest to what they actually asked for. // This func returns modes with ascending levels of modes to give the user
// // what is closest to what they actually asked for.
func (pvIndex *persistentVolumeOrderedIndex) allPossibleMatchingAccessModes(requestedModes []api.PersistentVolumeAccessMode) [][]api.PersistentVolumeAccessMode { func (pvIndex *persistentVolumeOrderedIndex) allPossibleMatchingAccessModes(requestedModes []api.PersistentVolumeAccessMode) [][]api.PersistentVolumeAccessMode {
matchedModes := [][]api.PersistentVolumeAccessMode{} matchedModes := [][]api.PersistentVolumeAccessMode{}
keys := pvIndex.store.ListIndexFuncValues("accessmodes") keys := pvIndex.store.ListIndexFuncValues("accessmodes")
@ -210,8 +223,9 @@ func (pvIndex *persistentVolumeOrderedIndex) allPossibleMatchingAccessModes(requ
} }
} }
// sort by the number of modes in each array with the fewest number of modes coming first. // sort by the number of modes in each array with the fewest number of
// this allows searching for volumes by the minimum number of modes required of the possible matches. // modes coming first. this allows searching for volumes by the minimum
// number of modes required of the possible matches.
sort.Sort(byAccessModes{matchedModes}) sort.Sort(byAccessModes{matchedModes})
return matchedModes return matchedModes
} }