mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 18:28:13 +00:00 
			
		
		
		
	Move PV/PVC annotations to PV/PVC types.
They aren't part of storage.k8s.io/v1 or v1beta1 API. Also move associated *GetClass functions.
This commit is contained in:
		| @@ -557,3 +557,42 @@ func PodAnnotationsFromSysctls(sysctls []Sysctl) string { | |||||||
| 	} | 	} | ||||||
| 	return strings.Join(kvs, ",") | 	return strings.Join(kvs, ",") | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GetPersistentVolumeClass returns StorageClassName. | ||||||
|  | func GetPersistentVolumeClass(volume *PersistentVolume) string { | ||||||
|  | 	// Use beta annotation first | ||||||
|  | 	if class, found := volume.Annotations[BetaStorageClassAnnotation]; found { | ||||||
|  | 		return class | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return volume.Spec.StorageClassName | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPersistentVolumeClaimClass returns StorageClassName. If no storage class was | ||||||
|  | // requested, it returns "". | ||||||
|  | func GetPersistentVolumeClaimClass(claim *PersistentVolumeClaim) string { | ||||||
|  | 	// Use beta annotation first | ||||||
|  | 	if class, found := claim.Annotations[BetaStorageClassAnnotation]; found { | ||||||
|  | 		return class | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if claim.Spec.StorageClassName != nil { | ||||||
|  | 		return *claim.Spec.StorageClassName | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // PersistentVolumeClaimHasClass returns true if given claim has set StorageClassName field. | ||||||
|  | func PersistentVolumeClaimHasClass(claim *PersistentVolumeClaim) bool { | ||||||
|  | 	// Use beta annotation first | ||||||
|  | 	if _, found := claim.Annotations[BetaStorageClassAnnotation]; found { | ||||||
|  | 		return true | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if claim.Spec.StorageClassName != nil { | ||||||
|  | 		return true | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return false | ||||||
|  | } | ||||||
|   | |||||||
| @@ -375,6 +375,12 @@ type PersistentVolumeClaimVolumeSource struct { | |||||||
| 	ReadOnly bool | 	ReadOnly bool | ||||||
| } | } | ||||||
|  |  | ||||||
|  | const ( | ||||||
|  | 	// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation. | ||||||
|  | 	// It's currently still used and will be held for backwards compatibility | ||||||
|  | 	BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" | ||||||
|  | ) | ||||||
|  |  | ||||||
| // +genclient=true | // +genclient=true | ||||||
| // +nonNamespaced=true | // +nonNamespaced=true | ||||||
|  |  | ||||||
|   | |||||||
| @@ -591,3 +591,42 @@ func GetAffinityFromPodAnnotations(annotations map[string]string) (*Affinity, er | |||||||
| 	} | 	} | ||||||
| 	return nil, nil | 	return nil, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // GetPersistentVolumeClass returns StorageClassName. | ||||||
|  | func GetPersistentVolumeClass(volume *PersistentVolume) string { | ||||||
|  | 	// Use beta annotation first | ||||||
|  | 	if class, found := volume.Annotations[BetaStorageClassAnnotation]; found { | ||||||
|  | 		return class | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return volume.Spec.StorageClassName | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // GetPersistentVolumeClaimClass returns StorageClassName. If no storage class was | ||||||
|  | // requested, it returns "". | ||||||
|  | func GetPersistentVolumeClaimClass(claim *PersistentVolumeClaim) string { | ||||||
|  | 	// Use beta annotation first | ||||||
|  | 	if class, found := claim.Annotations[BetaStorageClassAnnotation]; found { | ||||||
|  | 		return class | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if claim.Spec.StorageClassName != nil { | ||||||
|  | 		return *claim.Spec.StorageClassName | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // PersistentVolumeClaimHasClass returns true if given claim has set StorageClassName field. | ||||||
|  | func PersistentVolumeClaimHasClass(claim *PersistentVolumeClaim) bool { | ||||||
|  | 	// Use beta annotation first | ||||||
|  | 	if _, found := claim.Annotations[BetaStorageClassAnnotation]; found { | ||||||
|  | 		return true | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if claim.Spec.StorageClassName != nil { | ||||||
|  | 		return true | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return false | ||||||
|  | } | ||||||
|   | |||||||
| @@ -421,6 +421,17 @@ type PersistentVolumeSource struct { | |||||||
| 	PortworxVolume *PortworxVolumeSource `json:"portworxVolume,omitempty" protobuf:"bytes,18,opt,name=portworxVolume"` | 	PortworxVolume *PortworxVolumeSource `json:"portworxVolume,omitempty" protobuf:"bytes,18,opt,name=portworxVolume"` | ||||||
| } | } | ||||||
|  |  | ||||||
|  | const ( | ||||||
|  | 	// AlphaStorageClassAnnotation represents the previous alpha storage class | ||||||
|  | 	// annotation.  It's currently still used and will be held for backwards | ||||||
|  | 	// compatibility | ||||||
|  | 	AlphaStorageClassAnnotation = "volume.alpha.kubernetes.io/storage-class" | ||||||
|  |  | ||||||
|  | 	// BetaStorageClassAnnotation represents the beta/previous StorageClass annotation. | ||||||
|  | 	// It's currently still used and will be held for backwards compatibility | ||||||
|  | 	BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" | ||||||
|  | ) | ||||||
|  |  | ||||||
| // +genclient=true | // +genclient=true | ||||||
| // +nonNamespaced=true | // +nonNamespaced=true | ||||||
|  |  | ||||||
|   | |||||||
| @@ -44,7 +44,6 @@ import ( | |||||||
| 	utilpod "k8s.io/kubernetes/pkg/api/pod" | 	utilpod "k8s.io/kubernetes/pkg/api/pod" | ||||||
| 	apiservice "k8s.io/kubernetes/pkg/api/service" | 	apiservice "k8s.io/kubernetes/pkg/api/service" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/capabilities" | 	"k8s.io/kubernetes/pkg/capabilities" | ||||||
| 	"k8s.io/kubernetes/pkg/features" | 	"k8s.io/kubernetes/pkg/features" | ||||||
| 	"k8s.io/kubernetes/pkg/security/apparmor" | 	"k8s.io/kubernetes/pkg/security/apparmor" | ||||||
| @@ -1267,7 +1266,8 @@ func ValidatePersistentVolumeClaimUpdate(newPvc, oldPvc *api.PersistentVolumeCla | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// storageclass annotation should be immutable after creation | 	// storageclass annotation should be immutable after creation | ||||||
| 	allErrs = append(allErrs, ValidateImmutableAnnotation(newPvc.ObjectMeta.Annotations[storageutil.StorageClassAnnotation], oldPvc.ObjectMeta.Annotations[storageutil.StorageClassAnnotation], storageutil.StorageClassAnnotation, field.NewPath("metadata"))...) | 	// TODO: remove Beta when no longer needed | ||||||
|  | 	allErrs = append(allErrs, ValidateImmutableAnnotation(newPvc.ObjectMeta.Annotations[v1.BetaStorageClassAnnotation], oldPvc.ObjectMeta.Annotations[v1.BetaStorageClassAnnotation], v1.BetaStorageClassAnnotation, field.NewPath("metadata"))...) | ||||||
|  |  | ||||||
| 	newPvc.Status = oldPvc.Status | 	newPvc.Status = oldPvc.Status | ||||||
| 	return allErrs | 	return allErrs | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ import ( | |||||||
| 	"k8s.io/apimachinery/pkg/util/validation/field" | 	"k8s.io/apimachinery/pkg/util/validation/field" | ||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	"k8s.io/kubernetes/pkg/api/service" | 	"k8s.io/kubernetes/pkg/api/service" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/util" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	"k8s.io/kubernetes/pkg/capabilities" | 	"k8s.io/kubernetes/pkg/capabilities" | ||||||
| 	"k8s.io/kubernetes/pkg/security/apparmor" | 	"k8s.io/kubernetes/pkg/security/apparmor" | ||||||
| 	"k8s.io/kubernetes/pkg/volume" | 	"k8s.io/kubernetes/pkg/volume" | ||||||
| @@ -253,7 +253,7 @@ func testVolumeClaim(name string, namespace string, spec api.PersistentVolumeCla | |||||||
|  |  | ||||||
| func testVolumeClaimStorageClass(name string, namespace string, annval string, spec api.PersistentVolumeClaimSpec) *api.PersistentVolumeClaim { | func testVolumeClaimStorageClass(name string, namespace string, annval string, spec api.PersistentVolumeClaimSpec) *api.PersistentVolumeClaim { | ||||||
| 	annotations := map[string]string{ | 	annotations := map[string]string{ | ||||||
| 		storageutil.StorageClassAnnotation: annval, | 		v1.BetaStorageClassAnnotation: annval, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return &api.PersistentVolumeClaim{ | 	return &api.PersistentVolumeClaim{ | ||||||
|   | |||||||
| @@ -16,10 +16,7 @@ limitations under the License. | |||||||
|  |  | ||||||
| package util | package util | ||||||
|  |  | ||||||
| import ( | import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |  | ||||||
| 	"k8s.io/kubernetes/pkg/api" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| // IsDefaultStorageClassAnnotation represents a StorageClass annotation that | // IsDefaultStorageClassAnnotation represents a StorageClass annotation that | ||||||
| // marks a class as the default StorageClass | // marks a class as the default StorageClass | ||||||
| @@ -27,87 +24,6 @@ import ( | |||||||
| const IsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | const IsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | ||||||
| const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | ||||||
|  |  | ||||||
| // AlphaStorageClassAnnotation represents the previous alpha storage class |  | ||||||
| // annotation.  it's no longer used and held here for posterity. |  | ||||||
| const AlphaStorageClassAnnotation = "volume.alpha.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // BetaStorageClassAnnotation represents the beta/previous StorageClass annotation. |  | ||||||
| // It's currently still used and will be held for backwards compatibility |  | ||||||
| const BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // StorageClassAnnotation represents the storage class associated with a resource. |  | ||||||
| // It currently matches the Beta value and can change when official is set. |  | ||||||
| // - in PersistentVolumeClaim it represents required class to match. |  | ||||||
| //   Only PersistentVolumes with the same class (i.e. annotation with the same |  | ||||||
| //   value) can be bound to the claim. In case no such volume exists, the |  | ||||||
| //   controller will provision a new one using StorageClass instance with |  | ||||||
| //   the same name as the annotation value. |  | ||||||
| // - in PersistentVolume it represents storage class to which the persistent |  | ||||||
| //   volume belongs. |  | ||||||
| //TODO: Update this to final annotation value as it matches BetaStorageClassAnnotation for now |  | ||||||
| const StorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // GetVolumeStorageClass returns value of StorageClassAnnotation or empty string in case |  | ||||||
| // the annotation does not exist. |  | ||||||
| // TODO: change to PersistentVolume.Spec.Class value when this attribute is |  | ||||||
| // introduced. |  | ||||||
| func GetVolumeStorageClass(volume *api.PersistentVolume) string { |  | ||||||
| 	if class, found := volume.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// 'nil' is interpreted as "", i.e. the volume does not belong to any class. |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // GetClaimStorageClass returns name of class that is requested by given claim. |  | ||||||
| // Request for `nil` class is interpreted as request for class "", |  | ||||||
| // i.e. for a classless PV. |  | ||||||
| // TODO: change to PersistentVolumeClaim.Spec.Class value when this |  | ||||||
| // attribute is introduced. |  | ||||||
| func GetClaimStorageClass(claim *api.PersistentVolumeClaim) string { |  | ||||||
| 	if class, found := claim.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // GetStorageClassAnnotation returns the StorageClass value |  | ||||||
| // if the annotation is set, empty string if not |  | ||||||
| // TODO: remove Alpha and Beta when no longer used or needed |  | ||||||
| func GetStorageClassAnnotation(obj metav1.ObjectMeta) string { |  | ||||||
| 	if class, ok := obj.Annotations[StorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
| 	if class, ok := obj.Annotations[BetaStorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
| 	if class, ok := obj.Annotations[AlphaStorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // HasStorageClassAnnotation returns a boolean |  | ||||||
| // if the annotation is set |  | ||||||
| // TODO: remove Alpha and Beta when no longer used or needed |  | ||||||
| func HasStorageClassAnnotation(obj metav1.ObjectMeta) bool { |  | ||||||
| 	if _, found := obj.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
| 	if _, found := obj.Annotations[BetaStorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
| 	if _, found := obj.Annotations[AlphaStorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return false |  | ||||||
|  |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // IsDefaultAnnotationText returns a pretty Yes/No String if | // IsDefaultAnnotationText returns a pretty Yes/No String if | ||||||
| // the annotation is set | // the annotation is set | ||||||
| // TODO: remove Beta when no longer needed | // TODO: remove Beta when no longer needed | ||||||
|   | |||||||
| @@ -16,10 +16,7 @@ limitations under the License. | |||||||
|  |  | ||||||
| package util | package util | ||||||
|  |  | ||||||
| import ( | import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |  | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| // IsDefaultStorageClassAnnotation represents a StorageClass annotation that | // IsDefaultStorageClassAnnotation represents a StorageClass annotation that | ||||||
| // marks a class as the default StorageClass | // marks a class as the default StorageClass | ||||||
| @@ -27,87 +24,6 @@ import ( | |||||||
| const IsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | const IsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | ||||||
| const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | ||||||
|  |  | ||||||
| // AlphaStorageClassAnnotation represents the previous alpha storage class |  | ||||||
| // annotation.  it's no longer used and held here for posterity. |  | ||||||
| const AlphaStorageClassAnnotation = "volume.alpha.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // BetaStorageClassAnnotation represents the beta/previous StorageClass annotation. |  | ||||||
| // It's currently still used and will be held for backwards compatibility |  | ||||||
| const BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // StorageClassAnnotation represents the storage class associated with a resource. |  | ||||||
| // It currently matches the Beta value and can change when official is set. |  | ||||||
| // - in PersistentVolumeClaim it represents required class to match. |  | ||||||
| //   Only PersistentVolumes with the same class (i.e. annotation with the same |  | ||||||
| //   value) can be bound to the claim. In case no such volume exists, the |  | ||||||
| //   controller will provision a new one using StorageClass instance with |  | ||||||
| //   the same name as the annotation value. |  | ||||||
| // - in PersistentVolume it represents storage class to which the persistent |  | ||||||
| //   volume belongs. |  | ||||||
| //TODO: Update this to final annotation value as it matches BetaStorageClassAnnotation for now |  | ||||||
| const StorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // GetVolumeStorageClass returns value of StorageClassAnnotation or empty string in case |  | ||||||
| // the annotation does not exist. |  | ||||||
| // TODO: change to PersistentVolume.Spec.Class value when this attribute is |  | ||||||
| // introduced. |  | ||||||
| func GetVolumeStorageClass(volume *v1.PersistentVolume) string { |  | ||||||
| 	if class, found := volume.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// 'nil' is interpreted as "", i.e. the volume does not belong to any class. |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // GetClaimStorageClass returns name of class that is requested by given claim. |  | ||||||
| // Request for `nil` class is interpreted as request for class "", |  | ||||||
| // i.e. for a classless PV. |  | ||||||
| // TODO: change to PersistentVolumeClaim.Spec.Class value when this |  | ||||||
| // attribute is introduced. |  | ||||||
| func GetClaimStorageClass(claim *v1.PersistentVolumeClaim) string { |  | ||||||
| 	if class, found := claim.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // GetStorageClassAnnotation returns the StorageClass value |  | ||||||
| // if the annotation is set, empty string if not |  | ||||||
| // TODO: remove Alpha and Beta when no longer used or needed |  | ||||||
| func GetStorageClassAnnotation(obj metav1.ObjectMeta) string { |  | ||||||
| 	if class, ok := obj.Annotations[StorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
| 	if class, ok := obj.Annotations[BetaStorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
| 	if class, ok := obj.Annotations[AlphaStorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // HasStorageClassAnnotation returns a boolean |  | ||||||
| // if the annotation is set |  | ||||||
| // TODO: remove Alpha and Beta when no longer used or needed |  | ||||||
| func HasStorageClassAnnotation(obj metav1.ObjectMeta) bool { |  | ||||||
| 	if _, found := obj.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
| 	if _, found := obj.Annotations[BetaStorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
| 	if _, found := obj.Annotations[AlphaStorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return false |  | ||||||
|  |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // IsDefaultAnnotationText returns a pretty Yes/No String if | // IsDefaultAnnotationText returns a pretty Yes/No String if | ||||||
| // the annotation is set | // the annotation is set | ||||||
| // TODO: remove Beta when no longer needed | // TODO: remove Beta when no longer needed | ||||||
|   | |||||||
| @@ -16,10 +16,7 @@ limitations under the License. | |||||||
|  |  | ||||||
| package util | package util | ||||||
|  |  | ||||||
| import ( | import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |  | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| // IsDefaultStorageClassAnnotation represents a StorageClass annotation that | // IsDefaultStorageClassAnnotation represents a StorageClass annotation that | ||||||
| // marks a class as the default StorageClass | // marks a class as the default StorageClass | ||||||
| @@ -27,87 +24,6 @@ import ( | |||||||
| const IsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | const IsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | ||||||
| const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | ||||||
|  |  | ||||||
| // AlphaStorageClassAnnotation represents the previous alpha storage class |  | ||||||
| // annotation.  it's no longer used and held here for posterity. |  | ||||||
| const AlphaStorageClassAnnotation = "volume.alpha.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // BetaStorageClassAnnotation represents the beta/previous StorageClass annotation. |  | ||||||
| // It's currently still used and will be held for backwards compatibility |  | ||||||
| const BetaStorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // StorageClassAnnotation represents the storage class associated with a resource. |  | ||||||
| // It currently matches the Beta value and can change when official is set. |  | ||||||
| // - in PersistentVolumeClaim it represents required class to match. |  | ||||||
| //   Only PersistentVolumes with the same class (i.e. annotation with the same |  | ||||||
| //   value) can be bound to the claim. In case no such volume exists, the |  | ||||||
| //   controller will provision a new one using StorageClass instance with |  | ||||||
| //   the same name as the annotation value. |  | ||||||
| // - in PersistentVolume it represents storage class to which the persistent |  | ||||||
| //   volume belongs. |  | ||||||
| //TODO: Update this to final annotation value as it matches BetaStorageClassAnnotation for now |  | ||||||
| const StorageClassAnnotation = "volume.beta.kubernetes.io/storage-class" |  | ||||||
|  |  | ||||||
| // GetVolumeStorageClass returns value of StorageClassAnnotation or empty string in case |  | ||||||
| // the annotation does not exist. |  | ||||||
| // TODO: change to PersistentVolume.Spec.Class value when this attribute is |  | ||||||
| // introduced. |  | ||||||
| func GetVolumeStorageClass(volume *v1.PersistentVolume) string { |  | ||||||
| 	if class, found := volume.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// 'nil' is interpreted as "", i.e. the volume does not belong to any class. |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // GetClaimStorageClass returns name of class that is requested by given claim. |  | ||||||
| // Request for `nil` class is interpreted as request for class "", |  | ||||||
| // i.e. for a classless PV. |  | ||||||
| // TODO: change to PersistentVolumeClaim.Spec.Class value when this |  | ||||||
| // attribute is introduced. |  | ||||||
| func GetClaimStorageClass(claim *v1.PersistentVolumeClaim) string { |  | ||||||
| 	if class, found := claim.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // GetStorageClassAnnotation returns the StorageClass value |  | ||||||
| // if the annotation is set, empty string if not |  | ||||||
| // TODO: remove Alpha and Beta when no longer used or needed |  | ||||||
| func GetStorageClassAnnotation(obj metav1.ObjectMeta) string { |  | ||||||
| 	if class, ok := obj.Annotations[StorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
| 	if class, ok := obj.Annotations[BetaStorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
| 	if class, ok := obj.Annotations[AlphaStorageClassAnnotation]; ok { |  | ||||||
| 		return class |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return "" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // HasStorageClassAnnotation returns a boolean |  | ||||||
| // if the annotation is set |  | ||||||
| // TODO: remove Alpha and Beta when no longer used or needed |  | ||||||
| func HasStorageClassAnnotation(obj metav1.ObjectMeta) bool { |  | ||||||
| 	if _, found := obj.Annotations[StorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
| 	if _, found := obj.Annotations[BetaStorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
| 	if _, found := obj.Annotations[AlphaStorageClassAnnotation]; found { |  | ||||||
| 		return found |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return false |  | ||||||
|  |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // IsDefaultAnnotationText returns a pretty Yes/No String if | // IsDefaultAnnotationText returns a pretty Yes/No String if | ||||||
| // the annotation is set | // the annotation is set | ||||||
| // TODO: remove Beta when no longer needed | // TODO: remove Beta when no longer needed | ||||||
|   | |||||||
| @@ -21,7 +21,6 @@ import ( | |||||||
|  |  | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Test single call to syncClaim and syncVolume methods. | // Test single call to syncClaim and syncVolume methods. | ||||||
| @@ -435,14 +434,14 @@ func TestSync(t *testing.T) { | |||||||
| 			"13-1 - binding to class", | 			"13-1 - binding to class", | ||||||
| 			[]*v1.PersistentVolume{ | 			[]*v1.PersistentVolume{ | ||||||
| 				newVolume("volume13-1-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | 				newVolume("volume13-1-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | ||||||
| 				newVolume("volume13-1-2", "10Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, storageutil.StorageClassAnnotation), | 				newVolume("volume13-1-2", "10Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, v1.BetaStorageClassAnnotation), | ||||||
| 			}, | 			}, | ||||||
| 			[]*v1.PersistentVolume{ | 			[]*v1.PersistentVolume{ | ||||||
| 				newVolume("volume13-1-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | 				newVolume("volume13-1-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | ||||||
| 				newVolume("volume13-1-2", "10Gi", "uid13-1", "claim13-1", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, annBoundByController, storageutil.StorageClassAnnotation), | 				newVolume("volume13-1-2", "10Gi", "uid13-1", "claim13-1", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, annBoundByController, v1.BetaStorageClassAnnotation), | ||||||
| 			}, | 			}, | ||||||
| 			newClaimArray("claim13-1", "uid13-1", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim13-1", "uid13-1", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			withExpectedCapacity("10Gi", newClaimArray("claim13-1", "uid13-1", "1Gi", "volume13-1-2", v1.ClaimBound, annBoundByController, storageutil.StorageClassAnnotation, annBindCompleted)), | 			withExpectedCapacity("10Gi", newClaimArray("claim13-1", "uid13-1", "1Gi", "volume13-1-2", v1.ClaimBound, annBoundByController, v1.BetaStorageClassAnnotation, annBindCompleted)), | ||||||
| 			noevents, noerrors, testSyncClaim, | 			noevents, noerrors, testSyncClaim, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| @@ -450,11 +449,11 @@ func TestSync(t *testing.T) { | |||||||
| 			// smaller PV with a class available | 			// smaller PV with a class available | ||||||
| 			"13-2 - binding without a class", | 			"13-2 - binding without a class", | ||||||
| 			[]*v1.PersistentVolume{ | 			[]*v1.PersistentVolume{ | ||||||
| 				newVolume("volume13-2-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, storageutil.StorageClassAnnotation), | 				newVolume("volume13-2-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, v1.BetaStorageClassAnnotation), | ||||||
| 				newVolume("volume13-2-2", "10Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | 				newVolume("volume13-2-2", "10Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | ||||||
| 			}, | 			}, | ||||||
| 			[]*v1.PersistentVolume{ | 			[]*v1.PersistentVolume{ | ||||||
| 				newVolume("volume13-2-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, storageutil.StorageClassAnnotation), | 				newVolume("volume13-2-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, v1.BetaStorageClassAnnotation), | ||||||
| 				newVolume("volume13-2-2", "10Gi", "uid13-2", "claim13-2", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, annBoundByController), | 				newVolume("volume13-2-2", "10Gi", "uid13-2", "claim13-2", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, annBoundByController), | ||||||
| 			}, | 			}, | ||||||
| 			newClaimArray("claim13-2", "uid13-2", "1Gi", "", v1.ClaimPending), | 			newClaimArray("claim13-2", "uid13-2", "1Gi", "", v1.ClaimPending), | ||||||
| @@ -467,14 +466,14 @@ func TestSync(t *testing.T) { | |||||||
| 			"13-3 - binding to specific a class", | 			"13-3 - binding to specific a class", | ||||||
| 			volumeWithClass("silver", []*v1.PersistentVolume{ | 			volumeWithClass("silver", []*v1.PersistentVolume{ | ||||||
| 				newVolume("volume13-3-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | 				newVolume("volume13-3-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | ||||||
| 				newVolume("volume13-3-2", "10Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, storageutil.StorageClassAnnotation), | 				newVolume("volume13-3-2", "10Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, v1.BetaStorageClassAnnotation), | ||||||
| 			}), | 			}), | ||||||
| 			volumeWithClass("silver", []*v1.PersistentVolume{ | 			volumeWithClass("silver", []*v1.PersistentVolume{ | ||||||
| 				newVolume("volume13-3-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | 				newVolume("volume13-3-1", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | ||||||
| 				newVolume("volume13-3-2", "10Gi", "uid13-3", "claim13-3", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, annBoundByController, storageutil.StorageClassAnnotation), | 				newVolume("volume13-3-2", "10Gi", "uid13-3", "claim13-3", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, annBoundByController, v1.BetaStorageClassAnnotation), | ||||||
| 			}), | 			}), | ||||||
| 			newClaimArray("claim13-3", "uid13-3", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim13-3", "uid13-3", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			withExpectedCapacity("10Gi", newClaimArray("claim13-3", "uid13-3", "1Gi", "volume13-3-2", v1.ClaimBound, annBoundByController, annBindCompleted, storageutil.StorageClassAnnotation)), | 			withExpectedCapacity("10Gi", newClaimArray("claim13-3", "uid13-3", "1Gi", "volume13-3-2", v1.ClaimBound, annBoundByController, annBindCompleted, v1.BetaStorageClassAnnotation)), | ||||||
| 			noevents, noerrors, testSyncClaim, | 			noevents, noerrors, testSyncClaim, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
|   | |||||||
| @@ -43,7 +43,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/api/testapi" | 	"k8s.io/kubernetes/pkg/api/testapi" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake" | ||||||
| 	informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions" | 	informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions" | ||||||
| @@ -658,7 +657,7 @@ func newVolume(name, capacity, boundToClaimUID, boundToClaimName string, phase v | |||||||
| 			switch a { | 			switch a { | ||||||
| 			case annDynamicallyProvisioned: | 			case annDynamicallyProvisioned: | ||||||
| 				volume.Annotations[a] = mockPluginName | 				volume.Annotations[a] = mockPluginName | ||||||
| 			case storageutil.StorageClassAnnotation: | 			case v1.BetaStorageClassAnnotation: | ||||||
| 				volume.Annotations[a] = "gold" | 				volume.Annotations[a] = "gold" | ||||||
| 			default: | 			default: | ||||||
| 				volume.Annotations[a] = "yes" | 				volume.Annotations[a] = "yes" | ||||||
| @@ -711,9 +710,9 @@ func withMessage(message string, volumes []*v1.PersistentVolume) []*v1.Persisten | |||||||
| // Meant to be used to compose claims specified inline in a test. | // Meant to be used to compose claims specified inline in a test. | ||||||
| func volumeWithClass(className string, volumes []*v1.PersistentVolume) []*v1.PersistentVolume { | func volumeWithClass(className string, volumes []*v1.PersistentVolume) []*v1.PersistentVolume { | ||||||
| 	if volumes[0].Annotations == nil { | 	if volumes[0].Annotations == nil { | ||||||
| 		volumes[0].Annotations = map[string]string{storageutil.StorageClassAnnotation: className} | 		volumes[0].Annotations = map[string]string{v1.BetaStorageClassAnnotation: className} | ||||||
| 	} else { | 	} else { | ||||||
| 		volumes[0].Annotations[storageutil.StorageClassAnnotation] = className | 		volumes[0].Annotations[v1.BetaStorageClassAnnotation] = className | ||||||
| 	} | 	} | ||||||
| 	return volumes | 	return volumes | ||||||
| } | } | ||||||
| @@ -755,7 +754,7 @@ func newClaim(name, claimUID, capacity, boundToVolume string, phase v1.Persisten | |||||||
| 		claim.Annotations = make(map[string]string) | 		claim.Annotations = make(map[string]string) | ||||||
| 		for _, a := range annotations { | 		for _, a := range annotations { | ||||||
| 			switch a { | 			switch a { | ||||||
| 			case storageutil.StorageClassAnnotation: | 			case v1.BetaStorageClassAnnotation: | ||||||
| 				claim.Annotations[a] = "gold" | 				claim.Annotations[a] = "gold" | ||||||
| 			case annStorageProvisioner: | 			case annStorageProvisioner: | ||||||
| 				claim.Annotations[a] = mockPluginName | 				claim.Annotations[a] = mockPluginName | ||||||
| @@ -788,9 +787,9 @@ func newClaimArray(name, claimUID, capacity, boundToVolume string, phase v1.Pers | |||||||
| // Meant to be used to compose claims specified inline in a test. | // Meant to be used to compose claims specified inline in a test. | ||||||
| func claimWithClass(className string, claims []*v1.PersistentVolumeClaim) []*v1.PersistentVolumeClaim { | func claimWithClass(className string, claims []*v1.PersistentVolumeClaim) []*v1.PersistentVolumeClaim { | ||||||
| 	if claims[0].Annotations == nil { | 	if claims[0].Annotations == nil { | ||||||
| 		claims[0].Annotations = map[string]string{storageutil.StorageClassAnnotation: className} | 		claims[0].Annotations = map[string]string{v1.BetaStorageClassAnnotation: className} | ||||||
| 	} else { | 	} else { | ||||||
| 		claims[0].Annotations[storageutil.StorageClassAnnotation] = className | 		claims[0].Annotations[v1.BetaStorageClassAnnotation] = className | ||||||
| 	} | 	} | ||||||
| 	return claims | 	return claims | ||||||
| } | } | ||||||
|   | |||||||
| @@ -24,7 +24,6 @@ import ( | |||||||
| 	"k8s.io/apimachinery/pkg/labels" | 	"k8s.io/apimachinery/pkg/labels" | ||||||
| 	"k8s.io/client-go/tools/cache" | 	"k8s.io/client-go/tools/cache" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // persistentVolumeOrderedIndex is a cache.Store that keeps persistent volumes | // persistentVolumeOrderedIndex is a cache.Store that keeps persistent volumes | ||||||
| @@ -93,7 +92,7 @@ func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *v1.PersistentVol | |||||||
| 	var smallestVolumeSize int64 | 	var smallestVolumeSize int64 | ||||||
| 	requestedQty := claim.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)] | 	requestedQty := claim.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)] | ||||||
| 	requestedSize := requestedQty.Value() | 	requestedSize := requestedQty.Value() | ||||||
| 	requestedClass := storageutil.GetClaimStorageClass(claim) | 	requestedClass := v1.GetPersistentVolumeClaimClass(claim) | ||||||
|  |  | ||||||
| 	var selector labels.Selector | 	var selector labels.Selector | ||||||
| 	if claim.Spec.Selector != nil { | 	if claim.Spec.Selector != nil { | ||||||
| @@ -134,7 +133,7 @@ func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *v1.PersistentVol | |||||||
| 			// with existing PVs, findByClaim must find only PVs that are | 			// with existing PVs, findByClaim must find only PVs that are | ||||||
| 			// pre-bound to the claim (by dynamic provisioning). TODO: remove in | 			// pre-bound to the claim (by dynamic provisioning). TODO: remove in | ||||||
| 			// 1.5 | 			// 1.5 | ||||||
| 			if metav1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) { | 			if metav1.HasAnnotation(claim.ObjectMeta, v1.AlphaStorageClassAnnotation) { | ||||||
| 				continue | 				continue | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| @@ -147,7 +146,7 @@ func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *v1.PersistentVol | |||||||
| 			} else if selector != nil && !selector.Matches(labels.Set(volume.Labels)) { | 			} else if selector != nil && !selector.Matches(labels.Set(volume.Labels)) { | ||||||
| 				continue | 				continue | ||||||
| 			} | 			} | ||||||
| 			if storageutil.GetVolumeStorageClass(volume) != requestedClass { | 			if v1.GetPersistentVolumeClass(volume) != requestedClass { | ||||||
| 				continue | 				continue | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,7 +25,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	"k8s.io/kubernetes/pkg/api/testapi" | 	"k8s.io/kubernetes/pkg/api/testapi" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func makePVC(size string, modfn func(*v1.PersistentVolumeClaim)) *v1.PersistentVolumeClaim { | func makePVC(size string, modfn func(*v1.PersistentVolumeClaim)) *v1.PersistentVolumeClaim { | ||||||
| @@ -113,7 +112,7 @@ func TestMatchVolume(t *testing.T) { | |||||||
| 			expectedMatch: "gce-pd-silver1", | 			expectedMatch: "gce-pd-silver1", | ||||||
| 			claim: makePVC("1G", func(pvc *v1.PersistentVolumeClaim) { | 			claim: makePVC("1G", func(pvc *v1.PersistentVolumeClaim) { | ||||||
| 				pvc.ObjectMeta.Annotations = map[string]string{ | 				pvc.ObjectMeta.Annotations = map[string]string{ | ||||||
| 					storageutil.StorageClassAnnotation: "silver", | 					v1.BetaStorageClassAnnotation: "silver", | ||||||
| 				} | 				} | ||||||
| 				pvc.Spec.Selector = &metav1.LabelSelector{ | 				pvc.Spec.Selector = &metav1.LabelSelector{ | ||||||
| 					MatchLabels: map[string]string{ | 					MatchLabels: map[string]string{ | ||||||
| @@ -127,7 +126,7 @@ func TestMatchVolume(t *testing.T) { | |||||||
| 			expectedMatch: "gce-pd-silver2", | 			expectedMatch: "gce-pd-silver2", | ||||||
| 			claim: makePVC("1G", func(pvc *v1.PersistentVolumeClaim) { | 			claim: makePVC("1G", func(pvc *v1.PersistentVolumeClaim) { | ||||||
| 				pvc.ObjectMeta.Annotations = map[string]string{ | 				pvc.ObjectMeta.Annotations = map[string]string{ | ||||||
| 					storageutil.StorageClassAnnotation: "silver", | 					v1.BetaStorageClassAnnotation: "silver", | ||||||
| 				} | 				} | ||||||
| 				pvc.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce} | 				pvc.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce} | ||||||
| 			}), | 			}), | ||||||
| @@ -543,7 +542,7 @@ func createTestVolumes() []*v1.PersistentVolume { | |||||||
| 					"should-exist": "true", | 					"should-exist": "true", | ||||||
| 				}, | 				}, | ||||||
| 				Annotations: map[string]string{ | 				Annotations: map[string]string{ | ||||||
| 					storageutil.StorageClassAnnotation: "silver", | 					v1.BetaStorageClassAnnotation: "silver", | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			Spec: v1.PersistentVolumeSpec{ | 			Spec: v1.PersistentVolumeSpec{ | ||||||
| @@ -563,7 +562,7 @@ func createTestVolumes() []*v1.PersistentVolume { | |||||||
| 				UID:  "gce-pd-silver2", | 				UID:  "gce-pd-silver2", | ||||||
| 				Name: "gce0024", | 				Name: "gce0024", | ||||||
| 				Annotations: map[string]string{ | 				Annotations: map[string]string{ | ||||||
| 					storageutil.StorageClassAnnotation: "silver", | 					v1.BetaStorageClassAnnotation: "silver", | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			Spec: v1.PersistentVolumeSpec{ | 			Spec: v1.PersistentVolumeSpec{ | ||||||
| @@ -583,7 +582,7 @@ func createTestVolumes() []*v1.PersistentVolume { | |||||||
| 				UID:  "gce-pd-gold", | 				UID:  "gce-pd-gold", | ||||||
| 				Name: "gce0025", | 				Name: "gce0025", | ||||||
| 				Annotations: map[string]string{ | 				Annotations: map[string]string{ | ||||||
| 					storageutil.StorageClassAnnotation: "gold", | 					v1.BetaStorageClassAnnotation: "gold", | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			Spec: v1.PersistentVolumeSpec{ | 			Spec: v1.PersistentVolumeSpec{ | ||||||
|   | |||||||
| @@ -23,7 +23,6 @@ import ( | |||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| var class1Parameters = map[string]string{ | var class1Parameters = map[string]string{ | ||||||
| @@ -109,10 +108,10 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			// Provision a volume (with a default class) | 			// Provision a volume (with a default class) | ||||||
| 			"11-1 - successful provision with storage class 1", | 			"11-1 - successful provision with storage class 1", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newVolumeArray("pvc-uid11-1", "1Gi", "uid11-1", "claim11-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, storageutil.StorageClassAnnotation), | 			newVolumeArray("pvc-uid11-1", "1Gi", "uid11-1", "claim11-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			// Binding will be completed in the next syncClaim | 			// Binding will be completed in the next syncClaim | ||||||
| 			newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			[]string{"Normal ProvisioningSucceeded"}, noerrors, wrapTestWithProvisionCalls([]provisionCall{provision1Success}, testSyncClaim), | 			[]string{"Normal ProvisioningSucceeded"}, noerrors, wrapTestWithProvisionCalls([]provisionCall{provision1Success}, testSyncClaim), | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| @@ -120,8 +119,8 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			"11-2 - plugin not found", | 			"11-2 - plugin not found", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newClaimArray("claim11-2", "uid11-2", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-2", "uid11-2", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-2", "uid11-2", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-2", "uid11-2", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			[]string{"Warning ProvisioningFailed"}, noerrors, | 			[]string{"Warning ProvisioningFailed"}, noerrors, | ||||||
| 			testSyncClaim, | 			testSyncClaim, | ||||||
| 		}, | 		}, | ||||||
| @@ -130,8 +129,8 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			"11-3 - newProvisioner failure", | 			"11-3 - newProvisioner failure", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newClaimArray("claim11-3", "uid11-3", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-3", "uid11-3", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-3", "uid11-3", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-3", "uid11-3", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			[]string{"Warning ProvisioningFailed"}, noerrors, | 			[]string{"Warning ProvisioningFailed"}, noerrors, | ||||||
| 			wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim), | 			wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim), | ||||||
| 		}, | 		}, | ||||||
| @@ -140,18 +139,18 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			"11-4 - provision failure", | 			"11-4 - provision failure", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newClaimArray("claim11-4", "uid11-4", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-4", "uid11-4", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-4", "uid11-4", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-4", "uid11-4", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			[]string{"Warning ProvisioningFailed"}, noerrors, | 			[]string{"Warning ProvisioningFailed"}, noerrors, | ||||||
| 			wrapTestWithProvisionCalls([]provisionCall{provision1Error}, testSyncClaim), | 			wrapTestWithProvisionCalls([]provisionCall{provision1Error}, testSyncClaim), | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			// No provisioning if there is a matching volume available | 			// No provisioning if there is a matching volume available | ||||||
| 			"11-6 - provisioning when there is a volume available", | 			"11-6 - provisioning when there is a volume available", | ||||||
| 			newVolumeArray("volume11-6", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, storageutil.StorageClassAnnotation), | 			newVolumeArray("volume11-6", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain, v1.BetaStorageClassAnnotation), | ||||||
| 			newVolumeArray("volume11-6", "1Gi", "uid11-6", "claim11-6", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, annBoundByController, storageutil.StorageClassAnnotation), | 			newVolumeArray("volume11-6", "1Gi", "uid11-6", "claim11-6", v1.VolumeBound, v1.PersistentVolumeReclaimRetain, annBoundByController, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-6", "uid11-6", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-6", "uid11-6", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-6", "uid11-6", "1Gi", "volume11-6", v1.ClaimBound, storageutil.StorageClassAnnotation, annBoundByController, annBindCompleted), | 			newClaimArray("claim11-6", "uid11-6", "1Gi", "volume11-6", v1.ClaimBound, v1.BetaStorageClassAnnotation, annBoundByController, annBindCompleted), | ||||||
| 			noevents, noerrors, | 			noevents, noerrors, | ||||||
| 			// No provisioning plugin confingure - makes the test fail when | 			// No provisioning plugin confingure - makes the test fail when | ||||||
| 			// the controller errorneously tries to provision something | 			// the controller errorneously tries to provision something | ||||||
| @@ -162,16 +161,16 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			// a volume. | 			// a volume. | ||||||
| 			"11-7 - claim is bound before provisioning", | 			"11-7 - claim is bound before provisioning", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newVolumeArray("pvc-uid11-7", "1Gi", "uid11-7", "claim11-7", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, storageutil.StorageClassAnnotation), | 			newVolumeArray("pvc-uid11-7", "1Gi", "uid11-7", "claim11-7", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-7", "uid11-7", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-7", "uid11-7", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			// The claim would be bound in next syncClaim | 			// The claim would be bound in next syncClaim | ||||||
| 			newClaimArray("claim11-7", "uid11-7", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-7", "uid11-7", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			noevents, noerrors, | 			noevents, noerrors, | ||||||
| 			wrapTestWithInjectedOperation(wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim), func(ctrl *PersistentVolumeController, reactor *volumeReactor) { | 			wrapTestWithInjectedOperation(wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim), func(ctrl *PersistentVolumeController, reactor *volumeReactor) { | ||||||
| 				// Create a volume before provisionClaimOperation starts. | 				// Create a volume before provisionClaimOperation starts. | ||||||
| 				// This similates a parallel controller provisioning the volume. | 				// This similates a parallel controller provisioning the volume. | ||||||
| 				reactor.lock.Lock() | 				reactor.lock.Lock() | ||||||
| 				volume := newVolume("pvc-uid11-7", "1Gi", "uid11-7", "claim11-7", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, storageutil.StorageClassAnnotation) | 				volume := newVolume("pvc-uid11-7", "1Gi", "uid11-7", "claim11-7", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, v1.BetaStorageClassAnnotation) | ||||||
| 				reactor.volumes[volume.Name] = volume | 				reactor.volumes[volume.Name] = volume | ||||||
| 				reactor.lock.Unlock() | 				reactor.lock.Unlock() | ||||||
| 			}), | 			}), | ||||||
| @@ -181,10 +180,10 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			// second retry succeeds | 			// second retry succeeds | ||||||
| 			"11-8 - cannot save provisioned volume", | 			"11-8 - cannot save provisioned volume", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newVolumeArray("pvc-uid11-8", "1Gi", "uid11-8", "claim11-8", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, storageutil.StorageClassAnnotation), | 			newVolumeArray("pvc-uid11-8", "1Gi", "uid11-8", "claim11-8", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			// Binding will be completed in the next syncClaim | 			// Binding will be completed in the next syncClaim | ||||||
| 			newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			[]string{"Normal ProvisioningSucceeded"}, | 			[]string{"Normal ProvisioningSucceeded"}, | ||||||
| 			[]reactorError{ | 			[]reactorError{ | ||||||
| 				// Inject error to the first | 				// Inject error to the first | ||||||
| @@ -200,8 +199,8 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			"11-9 - cannot save provisioned volume, delete succeeds", | 			"11-9 - cannot save provisioned volume, delete succeeds", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newClaimArray("claim11-9", "uid11-9", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-9", "uid11-9", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-9", "uid11-9", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-9", "uid11-9", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			[]string{"Warning ProvisioningFailed"}, | 			[]string{"Warning ProvisioningFailed"}, | ||||||
| 			[]reactorError{ | 			[]reactorError{ | ||||||
| 				// Inject error to five kubeclient.PersistentVolumes.Create() | 				// Inject error to five kubeclient.PersistentVolumes.Create() | ||||||
| @@ -225,8 +224,8 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			"11-10 - cannot save provisioned volume, no delete plugin found", | 			"11-10 - cannot save provisioned volume, no delete plugin found", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newClaimArray("claim11-10", "uid11-10", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-10", "uid11-10", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-10", "uid11-10", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-10", "uid11-10", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			[]string{"Warning ProvisioningFailed", "Warning ProvisioningCleanupFailed"}, | 			[]string{"Warning ProvisioningFailed", "Warning ProvisioningCleanupFailed"}, | ||||||
| 			[]reactorError{ | 			[]reactorError{ | ||||||
| 				// Inject error to five kubeclient.PersistentVolumes.Create() | 				// Inject error to five kubeclient.PersistentVolumes.Create() | ||||||
| @@ -246,8 +245,8 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			"11-11 - cannot save provisioned volume, deleter fails", | 			"11-11 - cannot save provisioned volume, deleter fails", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newClaimArray("claim11-11", "uid11-11", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-11", "uid11-11", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-11", "uid11-11", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-11", "uid11-11", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			[]string{"Warning ProvisioningFailed", "Warning ProvisioningCleanupFailed"}, | 			[]string{"Warning ProvisioningFailed", "Warning ProvisioningCleanupFailed"}, | ||||||
| 			[]reactorError{ | 			[]reactorError{ | ||||||
| 				// Inject error to five kubeclient.PersistentVolumes.Create() | 				// Inject error to five kubeclient.PersistentVolumes.Create() | ||||||
| @@ -276,8 +275,8 @@ func TestProvisionSync(t *testing.T) { | |||||||
| 			"11-12 - cannot save provisioned volume, delete succeeds 2nd time", | 			"11-12 - cannot save provisioned volume, delete succeeds 2nd time", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newClaimArray("claim11-12", "uid11-12", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim11-12", "uid11-12", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim11-12", "uid11-12", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim11-12", "uid11-12", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			[]string{"Warning ProvisioningFailed"}, | 			[]string{"Warning ProvisioningFailed"}, | ||||||
| 			[]reactorError{ | 			[]reactorError{ | ||||||
| 				// Inject error to five kubeclient.PersistentVolumes.Create() | 				// Inject error to five kubeclient.PersistentVolumes.Create() | ||||||
| @@ -367,9 +366,9 @@ func TestAlphaProvisionSync(t *testing.T) { | |||||||
| 			"14-1 - successful alpha provisioning", | 			"14-1 - successful alpha provisioning", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newVolumeArray("pvc-uid14-1", "1Gi", "uid14-1", "claim14-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), | 			newVolumeArray("pvc-uid14-1", "1Gi", "uid14-1", "claim14-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), | ||||||
| 			newClaimArray("claim14-1", "uid14-1", "1Gi", "", v1.ClaimPending, storageutil.AlphaStorageClassAnnotation), | 			newClaimArray("claim14-1", "uid14-1", "1Gi", "", v1.ClaimPending, v1.AlphaStorageClassAnnotation), | ||||||
| 			// Binding will be completed in the next syncClaim | 			// Binding will be completed in the next syncClaim | ||||||
| 			newClaimArray("claim14-1", "uid14-1", "1Gi", "", v1.ClaimPending, storageutil.AlphaStorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim14-1", "uid14-1", "1Gi", "", v1.ClaimPending, v1.AlphaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{provisionAlphaSuccess}, testSyncClaim), | 			noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{provisionAlphaSuccess}, testSyncClaim), | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| @@ -381,9 +380,9 @@ func TestAlphaProvisionSync(t *testing.T) { | |||||||
| 				newVolume("volume14-2", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | 				newVolume("volume14-2", "1Gi", "", "", v1.VolumePending, v1.PersistentVolumeReclaimRetain), | ||||||
| 				newVolume("pvc-uid14-2", "1Gi", "uid14-2", "claim14-2", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), | 				newVolume("pvc-uid14-2", "1Gi", "uid14-2", "claim14-2", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned), | ||||||
| 			}, | 			}, | ||||||
| 			newClaimArray("claim14-2", "uid14-2", "1Gi", "", v1.ClaimPending, storageutil.AlphaStorageClassAnnotation), | 			newClaimArray("claim14-2", "uid14-2", "1Gi", "", v1.ClaimPending, v1.AlphaStorageClassAnnotation), | ||||||
| 			// Binding will be completed in the next syncClaim | 			// Binding will be completed in the next syncClaim | ||||||
| 			newClaimArray("claim14-2", "uid14-2", "1Gi", "", v1.ClaimPending, storageutil.AlphaStorageClassAnnotation, annStorageProvisioner), | 			newClaimArray("claim14-2", "uid14-2", "1Gi", "", v1.ClaimPending, v1.AlphaStorageClassAnnotation, annStorageProvisioner), | ||||||
| 			noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{provisionAlphaSuccess}, testSyncClaim), | 			noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{provisionAlphaSuccess}, testSyncClaim), | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
| @@ -410,9 +409,9 @@ func TestProvisionMultiSync(t *testing.T) { | |||||||
| 			// Provision a volume with binding | 			// Provision a volume with binding | ||||||
| 			"12-1 - successful provision", | 			"12-1 - successful provision", | ||||||
| 			novolumes, | 			novolumes, | ||||||
| 			newVolumeArray("pvc-uid12-1", "1Gi", "uid12-1", "claim12-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, storageutil.StorageClassAnnotation), | 			newVolumeArray("pvc-uid12-1", "1Gi", "uid12-1", "claim12-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, annBoundByController, annDynamicallyProvisioned, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim12-1", "uid12-1", "1Gi", "", v1.ClaimPending, storageutil.StorageClassAnnotation), | 			newClaimArray("claim12-1", "uid12-1", "1Gi", "", v1.ClaimPending, v1.BetaStorageClassAnnotation), | ||||||
| 			newClaimArray("claim12-1", "uid12-1", "1Gi", "pvc-uid12-1", v1.ClaimBound, storageutil.StorageClassAnnotation, annBoundByController, annBindCompleted, annStorageProvisioner), | 			newClaimArray("claim12-1", "uid12-1", "1Gi", "pvc-uid12-1", v1.ClaimBound, v1.BetaStorageClassAnnotation, annBoundByController, annBindCompleted, annStorageProvisioner), | ||||||
| 			noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{provision1Success}, testSyncClaim), | 			noevents, noerrors, wrapTestWithProvisionCalls([]provisionCall{provision1Success}, testSyncClaim), | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -29,7 +29,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | ||||||
| 	corelisters "k8s.io/kubernetes/pkg/client/listers/core/v1" | 	corelisters "k8s.io/kubernetes/pkg/client/listers/core/v1" | ||||||
| 	storagelisters "k8s.io/kubernetes/pkg/client/listers/storage/v1beta1" | 	storagelisters "k8s.io/kubernetes/pkg/client/listers/storage/v1beta1" | ||||||
| @@ -244,7 +243,7 @@ func (ctrl *PersistentVolumeController) syncUnboundClaim(claim *v1.PersistentVol | |||||||
| 			glog.V(4).Infof("synchronizing unbound PersistentVolumeClaim[%s]: no volume found", claimToClaimKey(claim)) | 			glog.V(4).Infof("synchronizing unbound PersistentVolumeClaim[%s]: no volume found", claimToClaimKey(claim)) | ||||||
| 			// No PV could be found | 			// No PV could be found | ||||||
| 			// OBSERVATION: pvc is "Pending", will retry | 			// OBSERVATION: pvc is "Pending", will retry | ||||||
| 			if storageutil.GetClaimStorageClass(claim) != "" || metav1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) { | 			if v1.GetPersistentVolumeClaimClass(claim) != "" || metav1.HasAnnotation(claim.ObjectMeta, v1.AlphaStorageClassAnnotation) { | ||||||
| 				if err = ctrl.provisionClaim(claim); err != nil { | 				if err = ctrl.provisionClaim(claim); err != nil { | ||||||
| 					return err | 					return err | ||||||
| 				} | 				} | ||||||
| @@ -1224,7 +1223,7 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	claimClass := storageutil.GetClaimStorageClass(claim) | 	claimClass := v1.GetPersistentVolumeClaimClass(claim) | ||||||
| 	glog.V(4).Infof("provisionClaimOperation [%s] started, class: %q", claimToClaimKey(claim), claimClass) | 	glog.V(4).Infof("provisionClaimOperation [%s] started, class: %q", claimToClaimKey(claim), claimClass) | ||||||
|  |  | ||||||
| 	plugin, storageClass, err := ctrl.findProvisionablePlugin(claim) | 	plugin, storageClass, err := ctrl.findProvisionablePlugin(claim) | ||||||
| @@ -1332,7 +1331,7 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa | |||||||
| 	// by storage.AlphaStorageClassAnnotation | 	// by storage.AlphaStorageClassAnnotation | ||||||
| 	// TODO: remove this check in 1.5, storage.StorageClassAnnotation will be always non-empty there. | 	// TODO: remove this check in 1.5, storage.StorageClassAnnotation will be always non-empty there. | ||||||
| 	if claimClass != "" { | 	if claimClass != "" { | ||||||
| 		metav1.SetMetaDataAnnotation(&volume.ObjectMeta, storageutil.StorageClassAnnotation, claimClass) | 		metav1.SetMetaDataAnnotation(&volume.ObjectMeta, v1.BetaStorageClassAnnotation, claimClass) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Try to create the PV object several times | 	// Try to create the PV object several times | ||||||
| @@ -1439,12 +1438,12 @@ func (ctrl *PersistentVolumeController) newRecyclerEventRecorder(volume *v1.Pers | |||||||
| // provisioner is requested. | // provisioner is requested. | ||||||
| func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *v1.PersistentVolumeClaim) (vol.ProvisionableVolumePlugin, *storage.StorageClass, error) { | func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *v1.PersistentVolumeClaim) (vol.ProvisionableVolumePlugin, *storage.StorageClass, error) { | ||||||
| 	// TODO: remove this alpha behavior in 1.5 | 	// TODO: remove this alpha behavior in 1.5 | ||||||
| 	alpha := metav1.HasAnnotation(claim.ObjectMeta, storageutil.AlphaStorageClassAnnotation) | 	alpha := metav1.HasAnnotation(claim.ObjectMeta, v1.AlphaStorageClassAnnotation) | ||||||
| 	beta := metav1.HasAnnotation(claim.ObjectMeta, storageutil.BetaStorageClassAnnotation) | 	if alpha && v1.PersistentVolumeClaimHasClass(claim) { | ||||||
| 	if alpha && beta { | 		// Both Alpha annotation and storage class name is set. Use the storage | ||||||
| 		// Both Alpha and Beta annotations are set. Do beta. | 		// class name. | ||||||
| 		alpha = false | 		alpha = false | ||||||
| 		msg := fmt.Sprintf("both %q and %q annotations are present, using %q", storageutil.AlphaStorageClassAnnotation, storageutil.BetaStorageClassAnnotation, storageutil.BetaStorageClassAnnotation) | 		msg := fmt.Sprintf("both %q annotation and storageClassName are present, using storageClassName", v1.AlphaStorageClassAnnotation) | ||||||
| 		ctrl.eventRecorder.Event(claim, v1.EventTypeNormal, "ProvisioningIgnoreAlpha", msg) | 		ctrl.eventRecorder.Event(claim, v1.EventTypeNormal, "ProvisioningIgnoreAlpha", msg) | ||||||
| 	} | 	} | ||||||
| 	if alpha { | 	if alpha { | ||||||
| @@ -1454,7 +1453,7 @@ func (ctrl *PersistentVolumeController) findProvisionablePlugin(claim *v1.Persis | |||||||
|  |  | ||||||
| 	// provisionClaim() which leads here is never called with claimClass=="", we | 	// provisionClaim() which leads here is never called with claimClass=="", we | ||||||
| 	// can save some checks. | 	// can save some checks. | ||||||
| 	claimClass := storageutil.GetClaimStorageClass(claim) | 	claimClass := v1.GetPersistentVolumeClaimClass(claim) | ||||||
| 	class, err := ctrl.classLister.Get(claimClass) | 	class, err := ctrl.classLister.Get(claimClass) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, nil, err | 		return nil, nil, err | ||||||
|   | |||||||
| @@ -812,7 +812,7 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string, describerSe | |||||||
| 		w.Write(LEVEL_0, "Name:\t%s\n", pv.Name) | 		w.Write(LEVEL_0, "Name:\t%s\n", pv.Name) | ||||||
| 		printLabelsMultiline(w, "Labels", pv.Labels) | 		printLabelsMultiline(w, "Labels", pv.Labels) | ||||||
| 		printAnnotationsMultiline(w, "Annotations", pv.Annotations) | 		printAnnotationsMultiline(w, "Annotations", pv.Annotations) | ||||||
| 		w.Write(LEVEL_0, "StorageClass:\t%s\n", storageutil.GetStorageClassAnnotation(pv.ObjectMeta)) | 		w.Write(LEVEL_0, "StorageClass:\t%s\n", api.GetPersistentVolumeClass(pv)) | ||||||
| 		w.Write(LEVEL_0, "Status:\t%s\n", pv.Status.Phase) | 		w.Write(LEVEL_0, "Status:\t%s\n", pv.Status.Phase) | ||||||
| 		if pv.Spec.ClaimRef != nil { | 		if pv.Spec.ClaimRef != nil { | ||||||
| 			w.Write(LEVEL_0, "Claim:\t%s\n", pv.Spec.ClaimRef.Namespace+"/"+pv.Spec.ClaimRef.Name) | 			w.Write(LEVEL_0, "Claim:\t%s\n", pv.Spec.ClaimRef.Namespace+"/"+pv.Spec.ClaimRef.Name) | ||||||
| @@ -889,7 +889,7 @@ func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string, descri | |||||||
| 		w := &PrefixWriter{out} | 		w := &PrefixWriter{out} | ||||||
| 		w.Write(LEVEL_0, "Name:\t%s\n", pvc.Name) | 		w.Write(LEVEL_0, "Name:\t%s\n", pvc.Name) | ||||||
| 		w.Write(LEVEL_0, "Namespace:\t%s\n", pvc.Namespace) | 		w.Write(LEVEL_0, "Namespace:\t%s\n", pvc.Namespace) | ||||||
| 		w.Write(LEVEL_0, "StorageClass:\t%s\n", storageutil.GetStorageClassAnnotation(pvc.ObjectMeta)) | 		w.Write(LEVEL_0, "StorageClass:\t%s\n", api.GetPersistentVolumeClaimClass(pvc)) | ||||||
| 		w.Write(LEVEL_0, "Status:\t%v\n", pvc.Status.Phase) | 		w.Write(LEVEL_0, "Status:\t%v\n", pvc.Status.Phase) | ||||||
| 		w.Write(LEVEL_0, "Volume:\t%s\n", pvc.Spec.VolumeName) | 		w.Write(LEVEL_0, "Volume:\t%s\n", pvc.Spec.VolumeName) | ||||||
| 		printLabelsMultiline(w, "Labels", pvc.Labels) | 		printLabelsMultiline(w, "Labels", pvc.Labels) | ||||||
|   | |||||||
| @@ -1179,7 +1179,7 @@ func printPersistentVolume(pv *api.PersistentVolume, w io.Writer, options printe | |||||||
| 		aSize, modesStr, reclaimPolicyStr, | 		aSize, modesStr, reclaimPolicyStr, | ||||||
| 		pv.Status.Phase, | 		pv.Status.Phase, | ||||||
| 		claimRefUID, | 		claimRefUID, | ||||||
| 		storageutil.GetStorageClassAnnotation(pv.ObjectMeta), | 		api.GetPersistentVolumeClass(pv), | ||||||
| 		pv.Status.Reason, | 		pv.Status.Reason, | ||||||
| 		translateTimestamp(pv.CreationTimestamp), | 		translateTimestamp(pv.CreationTimestamp), | ||||||
| 	); err != nil { | 	); err != nil { | ||||||
| @@ -1222,7 +1222,7 @@ func printPersistentVolumeClaim(pvc *api.PersistentVolumeClaim, w io.Writer, opt | |||||||
| 		capacity = storage.String() | 		capacity = storage.String() | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s", name, phase, pvc.Spec.VolumeName, capacity, accessModes, storageutil.GetStorageClassAnnotation(pvc.ObjectMeta), translateTimestamp(pvc.CreationTimestamp)); err != nil { | 	if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s", name, phase, pvc.Spec.VolumeName, capacity, accessModes, api.GetPersistentVolumeClaimClass(pvc), translateTimestamp(pvc.CreationTimestamp)); err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	if _, err := fmt.Fprint(w, AppendLabels(pvc.Labels, options.ColumnLabels)); err != nil { | 	if _, err := fmt.Fprint(w, AppendLabels(pvc.Labels, options.ColumnLabels)); err != nil { | ||||||
|   | |||||||
| @@ -28,7 +28,6 @@ import ( | |||||||
| 	"k8s.io/apiserver/pkg/admission" | 	"k8s.io/apiserver/pkg/admission" | ||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	"k8s.io/kubernetes/pkg/apis/storage/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | ||||||
| 	informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions" | 	informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions" | ||||||
| 	"k8s.io/kubernetes/pkg/quota" | 	"k8s.io/kubernetes/pkg/quota" | ||||||
| @@ -105,7 +104,7 @@ func (p *pvcEvaluator) Constraints(required []api.ResourceName, item runtime.Obj | |||||||
|  |  | ||||||
| 	// these are the items that we will be handling based on the objects actual storage-class | 	// these are the items that we will be handling based on the objects actual storage-class | ||||||
| 	pvcRequiredSet := append([]api.ResourceName{}, pvcResources...) | 	pvcRequiredSet := append([]api.ResourceName{}, pvcResources...) | ||||||
| 	if storageClassRef := util.GetClaimStorageClass(pvc); len(storageClassRef) > 0 { | 	if storageClassRef := api.GetPersistentVolumeClaimClass(pvc); len(storageClassRef) > 0 { | ||||||
| 		pvcRequiredSet = append(pvcRequiredSet, ResourceByStorageClass(storageClassRef, api.ResourcePersistentVolumeClaims)) | 		pvcRequiredSet = append(pvcRequiredSet, ResourceByStorageClass(storageClassRef, api.ResourcePersistentVolumeClaims)) | ||||||
| 		pvcRequiredSet = append(pvcRequiredSet, ResourceByStorageClass(storageClassRef, api.ResourceRequestsStorage)) | 		pvcRequiredSet = append(pvcRequiredSet, ResourceByStorageClass(storageClassRef, api.ResourceRequestsStorage)) | ||||||
| 	} | 	} | ||||||
| @@ -176,7 +175,7 @@ func (p *pvcEvaluator) Usage(item runtime.Object) (api.ResourceList, error) { | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return result, err | 		return result, err | ||||||
| 	} | 	} | ||||||
| 	storageClassRef := util.GetClaimStorageClass(pvc) | 	storageClassRef := api.GetPersistentVolumeClaimClass(pvc) | ||||||
|  |  | ||||||
| 	// charge for claim | 	// charge for claim | ||||||
| 	result[api.ResourcePersistentVolumeClaims] = resource.MustParse("1") | 	result[api.ResourcePersistentVolumeClaims] = resource.MustParse("1") | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ import ( | |||||||
| 	"k8s.io/apimachinery/pkg/api/resource" | 	"k8s.io/apimachinery/pkg/api/resource" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	"k8s.io/kubernetes/pkg/apis/storage/util" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake" | ||||||
| 	"k8s.io/kubernetes/pkg/quota" | 	"k8s.io/kubernetes/pkg/quota" | ||||||
| ) | ) | ||||||
| @@ -74,7 +74,7 @@ func TestPersistentVolumeClaimsConstraintsFunc(t *testing.T) { | |||||||
| 		}, | 		}, | ||||||
| 	}) | 	}) | ||||||
| 	validClaimGoldStorageClass.Annotations = map[string]string{ | 	validClaimGoldStorageClass.Annotations = map[string]string{ | ||||||
| 		util.StorageClassAnnotation: "gold", | 		v1.BetaStorageClassAnnotation: "gold", | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	validClaimBronzeStorageClass := testVolumeClaim("foo", "ns", api.PersistentVolumeClaimSpec{ | 	validClaimBronzeStorageClass := testVolumeClaim("foo", "ns", api.PersistentVolumeClaimSpec{ | ||||||
| @@ -97,7 +97,7 @@ func TestPersistentVolumeClaimsConstraintsFunc(t *testing.T) { | |||||||
| 		}, | 		}, | ||||||
| 	}) | 	}) | ||||||
| 	validClaimBronzeStorageClass.Annotations = map[string]string{ | 	validClaimBronzeStorageClass.Annotations = map[string]string{ | ||||||
| 		util.StorageClassAnnotation: "bronze", | 		v1.BetaStorageClassAnnotation: "bronze", | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	missingStorage := testVolumeClaim("foo", "ns", api.PersistentVolumeClaimSpec{ | 	missingStorage := testVolumeClaim("foo", "ns", api.PersistentVolumeClaimSpec{ | ||||||
| @@ -136,7 +136,7 @@ func TestPersistentVolumeClaimsConstraintsFunc(t *testing.T) { | |||||||
| 		}, | 		}, | ||||||
| 	}) | 	}) | ||||||
| 	missingGoldStorage.Annotations = map[string]string{ | 	missingGoldStorage.Annotations = map[string]string{ | ||||||
| 		util.StorageClassAnnotation: "gold", | 		v1.BetaStorageClassAnnotation: "gold", | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	testCases := map[string]struct { | 	testCases := map[string]struct { | ||||||
| @@ -240,7 +240,7 @@ func TestPersistentVolumeClaimEvaluatorUsage(t *testing.T) { | |||||||
| 	}) | 	}) | ||||||
| 	storageClassName := "gold" | 	storageClassName := "gold" | ||||||
| 	validClaimByStorageClass.Annotations = map[string]string{ | 	validClaimByStorageClass.Annotations = map[string]string{ | ||||||
| 		util.StorageClassAnnotation: storageClassName, | 		v1.BetaStorageClassAnnotation: storageClassName, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	kubeClient := fake.NewSimpleClientset() | 	kubeClient := fake.NewSimpleClientset() | ||||||
|   | |||||||
| @@ -35,7 +35,6 @@ import ( | |||||||
| 	"k8s.io/apimachinery/pkg/labels" | 	"k8s.io/apimachinery/pkg/labels" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | ||||||
| 	"k8s.io/kubernetes/pkg/util/exec" | 	"k8s.io/kubernetes/pkg/util/exec" | ||||||
| 	"k8s.io/kubernetes/pkg/util/mount" | 	"k8s.io/kubernetes/pkg/util/mount" | ||||||
| @@ -471,7 +470,7 @@ func (p *glusterfsPlugin) collectGids(className string, gidTable *MinMaxAllocato | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for _, pv := range pvList.Items { | 	for _, pv := range pvList.Items { | ||||||
| 		if storageutil.GetVolumeStorageClass(&pv) != className { | 		if v1.GetPersistentVolumeClass(&pv) != className { | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -650,7 +649,7 @@ func (r *glusterfsVolumeProvisioner) Provision() (*v1.PersistentVolume, error) { | |||||||
| 		return nil, fmt.Errorf("glusterfs: not able to parse your claim Selector") | 		return nil, fmt.Errorf("glusterfs: not able to parse your claim Selector") | ||||||
| 	} | 	} | ||||||
| 	glog.V(4).Infof("glusterfs: Provison VolumeOptions %v", r.options) | 	glog.V(4).Infof("glusterfs: Provison VolumeOptions %v", r.options) | ||||||
| 	scName := storageutil.GetClaimStorageClass(r.options.PVC) | 	scName := v1.GetPersistentVolumeClaimClass(r.options.PVC) | ||||||
| 	cfg, err := parseClassParameters(r.options.Parameters, r.plugin.host.GetKubeClient()) | 	cfg, err := parseClassParameters(r.options.Parameters, r.plugin.host.GetKubeClient()) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
|   | |||||||
| @@ -96,7 +96,7 @@ func (c *claimDefaulterPlugin) Admit(a admission.Attributes) error { | |||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if storageutil.HasStorageClassAnnotation(pvc.ObjectMeta) { | 	if api.PersistentVolumeClaimHasClass(pvc) { | ||||||
| 		// The user asked for a class. | 		// The user asked for a class. | ||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
| @@ -116,7 +116,7 @@ func (c *claimDefaulterPlugin) Admit(a admission.Attributes) error { | |||||||
| 	if pvc.ObjectMeta.Annotations == nil { | 	if pvc.ObjectMeta.Annotations == nil { | ||||||
| 		pvc.ObjectMeta.Annotations = map[string]string{} | 		pvc.ObjectMeta.Annotations = map[string]string{} | ||||||
| 	} | 	} | ||||||
| 	pvc.Annotations[storageutil.StorageClassAnnotation] = def.Name | 	pvc.Annotations[api.BetaStorageClassAnnotation] = def.Name | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ import ( | |||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apiserver/pkg/admission" | 	"k8s.io/apiserver/pkg/admission" | ||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
|  | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	"k8s.io/kubernetes/pkg/apis/storage" | 	"k8s.io/kubernetes/pkg/apis/storage" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/util" | 	storageutil "k8s.io/kubernetes/pkg/apis/storage/util" | ||||||
| 	informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion" | 	informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion" | ||||||
| @@ -100,7 +101,7 @@ func TestAdmission(t *testing.T) { | |||||||
| 			Name:      "claimWithClass", | 			Name:      "claimWithClass", | ||||||
| 			Namespace: "ns", | 			Namespace: "ns", | ||||||
| 			Annotations: map[string]string{ | 			Annotations: map[string]string{ | ||||||
| 				storageutil.StorageClassAnnotation: "foo", | 				v1.BetaStorageClassAnnotation: "foo", | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
| @@ -112,7 +113,7 @@ func TestAdmission(t *testing.T) { | |||||||
| 			Name:      "claimWithEmptyClass", | 			Name:      "claimWithEmptyClass", | ||||||
| 			Namespace: "ns", | 			Namespace: "ns", | ||||||
| 			Annotations: map[string]string{ | 			Annotations: map[string]string{ | ||||||
| 				storageutil.StorageClassAnnotation: "", | 				v1.BetaStorageClassAnnotation: "", | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
| @@ -222,7 +223,7 @@ func TestAdmission(t *testing.T) { | |||||||
|  |  | ||||||
| 		class := "" | 		class := "" | ||||||
| 		if claim.Annotations != nil { | 		if claim.Annotations != nil { | ||||||
| 			if value, ok := claim.Annotations[storageutil.StorageClassAnnotation]; ok { | 			if value, ok := claim.Annotations[v1.BetaStorageClassAnnotation]; ok { | ||||||
| 				class = value | 				class = value | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -25,7 +25,6 @@ import ( | |||||||
| 	"k8s.io/apimachinery/pkg/util/intstr" | 	"k8s.io/apimachinery/pkg/util/intstr" | ||||||
| 	"k8s.io/apimachinery/pkg/util/wait" | 	"k8s.io/apimachinery/pkg/util/wait" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	"k8s.io/kubernetes/pkg/apis/storage/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | ||||||
| 	"k8s.io/kubernetes/pkg/quota/evaluator/core" | 	"k8s.io/kubernetes/pkg/quota/evaluator/core" | ||||||
| 	"k8s.io/kubernetes/test/e2e/framework" | 	"k8s.io/kubernetes/test/e2e/framework" | ||||||
| @@ -340,7 +339,7 @@ var _ = framework.KubeDescribe("ResourceQuota", func() { | |||||||
| 		By("Creating a PersistentVolumeClaim with storage class") | 		By("Creating a PersistentVolumeClaim with storage class") | ||||||
| 		pvc := newTestPersistentVolumeClaimForQuota("test-claim") | 		pvc := newTestPersistentVolumeClaimForQuota("test-claim") | ||||||
| 		pvc.Annotations = map[string]string{ | 		pvc.Annotations = map[string]string{ | ||||||
| 			util.StorageClassAnnotation: "gold", | 			v1.BetaStorageClassAnnotation: "gold", | ||||||
| 		} | 		} | ||||||
| 		pvc, err = f.ClientSet.Core().PersistentVolumeClaims(f.Namespace.Name).Create(pvc) | 		pvc, err = f.ClientSet.Core().PersistentVolumeClaims(f.Namespace.Name).Create(pvc) | ||||||
| 		Expect(err).NotTo(HaveOccurred()) | 		Expect(err).NotTo(HaveOccurred()) | ||||||
|   | |||||||
| @@ -27,7 +27,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	rbacv1beta1 "k8s.io/kubernetes/pkg/apis/rbac/v1beta1" | 	rbacv1beta1 "k8s.io/kubernetes/pkg/apis/rbac/v1beta1" | ||||||
| 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | ||||||
| 	"k8s.io/kubernetes/test/e2e/framework" | 	"k8s.io/kubernetes/test/e2e/framework" | ||||||
|  |  | ||||||
| @@ -263,11 +262,11 @@ func newClaim(ns, suffix string, alpha bool) *v1.PersistentVolumeClaim { | |||||||
|  |  | ||||||
| 	if alpha { | 	if alpha { | ||||||
| 		claim.Annotations = map[string]string{ | 		claim.Annotations = map[string]string{ | ||||||
| 			storageutil.AlphaStorageClassAnnotation: "", | 			v1.AlphaStorageClassAnnotation: "", | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		claim.Annotations = map[string]string{ | 		claim.Annotations = map[string]string{ | ||||||
| 			storageutil.StorageClassAnnotation: "myclass-" + suffix, | 			v1.BetaStorageClassAnnotation: "myclass-" + suffix, | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -29,7 +29,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | ||||||
| 	"k8s.io/kubernetes/test/integration/framework" | 	"k8s.io/kubernetes/test/integration/framework" | ||||||
| ) | ) | ||||||
| @@ -73,7 +72,7 @@ func DoTestStorageClasses(t *testing.T, client clientset.Interface, ns *v1.Names | |||||||
| 			Name:      "XXX", | 			Name:      "XXX", | ||||||
| 			Namespace: ns.Name, | 			Namespace: ns.Name, | ||||||
| 			Annotations: map[string]string{ | 			Annotations: map[string]string{ | ||||||
| 				storageutil.StorageClassAnnotation: "gold", | 				v1.BetaStorageClassAnnotation: "gold", | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		Spec: v1.PersistentVolumeClaimSpec{ | 		Spec: v1.PersistentVolumeClaimSpec{ | ||||||
|   | |||||||
| @@ -34,7 +34,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/api" | 	"k8s.io/kubernetes/pkg/api" | ||||||
| 	"k8s.io/kubernetes/pkg/api/v1" | 	"k8s.io/kubernetes/pkg/api/v1" | ||||||
| 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | 	storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1" | ||||||
| 	storageutil "k8s.io/kubernetes/pkg/apis/storage/v1beta1/util" |  | ||||||
| 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | 	"k8s.io/kubernetes/pkg/client/clientset_generated/clientset" | ||||||
| 	informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions" | 	informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions" | ||||||
| 	fakecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/fake" | 	fakecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/fake" | ||||||
| @@ -889,7 +888,7 @@ func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) { | |||||||
| 	for i := 0; i < objCount; i++ { | 	for i := 0; i < objCount; i++ { | ||||||
| 		pvc := createPVC("pvc-provision-"+strconv.Itoa(i), ns.Name, "1G", []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce}) | 		pvc := createPVC("pvc-provision-"+strconv.Itoa(i), ns.Name, "1G", []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce}) | ||||||
| 		pvc.Annotations = map[string]string{ | 		pvc.Annotations = map[string]string{ | ||||||
| 			storageutil.StorageClassAnnotation: "gold", | 			v1.BetaStorageClassAnnotation: "gold", | ||||||
| 		} | 		} | ||||||
| 		pvcs[i] = pvc | 		pvcs[i] = pvc | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jan Safranek
					Jan Safranek