mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-30 21:30:16 +00:00 
			
		
		
		
	mark volume.beta.kubernetes.io/mount-options as deprecated
This commit is contained in:
		| @@ -27,10 +27,6 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/features" | 	"k8s.io/kubernetes/pkg/features" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( |  | ||||||
| 	deprecatedStorageClassAnnotationsMsg = `deprecated since v1.8; use "storageClassName" attribute instead` |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| // DropDisabledSpecFields removes disabled fields from the pv spec. | // DropDisabledSpecFields removes disabled fields from the pv spec. | ||||||
| // This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pv spec. | // This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pv spec. | ||||||
| func DropDisabledSpecFields(pvSpec *api.PersistentVolumeSpec, oldPVSpec *api.PersistentVolumeSpec) { | func DropDisabledSpecFields(pvSpec *api.PersistentVolumeSpec, oldPVSpec *api.PersistentVolumeSpec) { | ||||||
| @@ -56,17 +52,28 @@ func GetWarningsForPersistentVolume(pv *api.PersistentVolume) []string { | |||||||
| 	return warningsForPersistentVolumeSpecAndMeta(nil, &pv.Spec, &pv.ObjectMeta) | 	return warningsForPersistentVolumeSpecAndMeta(nil, &pv.Spec, &pv.ObjectMeta) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | var deprecatedAnnotations = []struct { | ||||||
|  | 	key     string | ||||||
|  | 	message string | ||||||
|  | }{ | ||||||
|  | 	{ | ||||||
|  | 		key:     `volume.beta.kubernetes.io/storage-class`, | ||||||
|  | 		message: `deprecated since v1.8; use "storageClassName" attribute instead`, | ||||||
|  | 	}, | ||||||
|  | 	{ | ||||||
|  | 		key:     `volume.beta.kubernetes.io/mount-options`, | ||||||
|  | 		message: `deprecated since v1.31; use "mountOptions" attribute instead`, | ||||||
|  | 	}, | ||||||
|  | } | ||||||
|  |  | ||||||
| func warningsForPersistentVolumeSpecAndMeta(fieldPath *field.Path, pvSpec *api.PersistentVolumeSpec, pvMeta *metav1.ObjectMeta) []string { | func warningsForPersistentVolumeSpecAndMeta(fieldPath *field.Path, pvSpec *api.PersistentVolumeSpec, pvMeta *metav1.ObjectMeta) []string { | ||||||
| 	var warnings []string | 	var warnings []string | ||||||
|  |  | ||||||
| 	if _, ok := pvMeta.Annotations[api.BetaStorageClassAnnotation]; ok { | 	// use of deprecated annotations | ||||||
| 		warnings = append(warnings, | 	for _, deprecated := range deprecatedAnnotations { | ||||||
| 			fmt.Sprintf( | 		if _, exists := pvMeta.Annotations[deprecated.key]; exists { | ||||||
| 				"%s: %s", | 			warnings = append(warnings, fmt.Sprintf("%s: %s", fieldPath.Child("metadata", "annotations").Key(deprecated.key), deprecated.message)) | ||||||
| 				fieldPath.Child("metadata", "annotations").Key(api.BetaStorageClassAnnotation), | 		} | ||||||
| 				deprecatedStorageClassAnnotationsMsg, |  | ||||||
| 			), |  | ||||||
| 		) |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if pvSpec.PersistentVolumeReclaimPolicy == api.PersistentVolumeReclaimRecycle { | 	if pvSpec.PersistentVolumeReclaimPolicy == api.PersistentVolumeReclaimRecycle { | ||||||
|   | |||||||
| @@ -146,6 +146,7 @@ func TestWarnings(t *testing.T) { | |||||||
| 					Name: "foo", | 					Name: "foo", | ||||||
| 					Annotations: map[string]string{ | 					Annotations: map[string]string{ | ||||||
| 						api.BetaStorageClassAnnotation: "", | 						api.BetaStorageClassAnnotation: "", | ||||||
|  | 						api.MountOptionAnnotation:      "", | ||||||
| 					}, | 					}, | ||||||
| 				}, | 				}, | ||||||
| 				Spec: api.PersistentVolumeSpec{ | 				Spec: api.PersistentVolumeSpec{ | ||||||
| @@ -171,6 +172,7 @@ func TestWarnings(t *testing.T) { | |||||||
| 			}, | 			}, | ||||||
| 			expected: []string{ | 			expected: []string{ | ||||||
| 				`metadata.annotations[volume.beta.kubernetes.io/storage-class]: deprecated since v1.8; use "storageClassName" attribute instead`, | 				`metadata.annotations[volume.beta.kubernetes.io/storage-class]: deprecated since v1.8; use "storageClassName" attribute instead`, | ||||||
|  | 				`metadata.annotations[volume.beta.kubernetes.io/mount-options]: deprecated since v1.31; use "mountOptions" attribute instead`, | ||||||
| 				`spec.nodeAffinity.required.nodeSelectorTerms[0].matchExpressions[0].key: beta.kubernetes.io/os is deprecated since v1.14; use "kubernetes.io/os" instead`, | 				`spec.nodeAffinity.required.nodeSelectorTerms[0].matchExpressions[0].key: beta.kubernetes.io/os is deprecated since v1.14; use "kubernetes.io/os" instead`, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user