Add functions for storing volume as failed with final error
This commit is contained in:
		| @@ -27,6 +27,7 @@ import ( | |||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/api/resource" | 	"k8s.io/apimachinery/pkg/api/resource" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
|  | 	"k8s.io/apimachinery/pkg/util/sets" | ||||||
| 	utilfeature "k8s.io/apiserver/pkg/util/feature" | 	utilfeature "k8s.io/apiserver/pkg/util/feature" | ||||||
| 	"k8s.io/klog/v2" | 	"k8s.io/klog/v2" | ||||||
| 	"k8s.io/kubernetes/pkg/features" | 	"k8s.io/kubernetes/pkg/features" | ||||||
| @@ -215,6 +216,7 @@ func NewActualStateOfWorld( | |||||||
| 		attachedVolumes:                 make(map[v1.UniqueVolumeName]attachedVolume), | 		attachedVolumes:                 make(map[v1.UniqueVolumeName]attachedVolume), | ||||||
| 		foundDuringReconstruction:       make(map[v1.UniqueVolumeName]map[volumetypes.UniquePodName]types.UID), | 		foundDuringReconstruction:       make(map[v1.UniqueVolumeName]map[volumetypes.UniquePodName]types.UID), | ||||||
| 		volumePluginMgr:                 volumePluginMgr, | 		volumePluginMgr:                 volumePluginMgr, | ||||||
|  | 		volumesWithFinalExpansionErrors: sets.New[string](), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -247,6 +249,8 @@ type actualStateOfWorld struct { | |||||||
| 	// from kubelet root directory when kubelet was restarted. | 	// from kubelet root directory when kubelet was restarted. | ||||||
| 	foundDuringReconstruction map[v1.UniqueVolumeName]map[volumetypes.UniquePodName]types.UID | 	foundDuringReconstruction map[v1.UniqueVolumeName]map[volumetypes.UniquePodName]types.UID | ||||||
|  |  | ||||||
|  | 	volumesWithFinalExpansionErrors sets.Set[v1.UniqueVolumeName] | ||||||
|  |  | ||||||
| 	// volumePluginMgr is the volume plugin manager used to create volume | 	// volumePluginMgr is the volume plugin manager used to create volume | ||||||
| 	// plugin objects. | 	// plugin objects. | ||||||
| 	volumePluginMgr *volume.VolumePluginMgr | 	volumePluginMgr *volume.VolumePluginMgr | ||||||
| @@ -396,6 +400,27 @@ func (asw *actualStateOfWorld) MarkVolumeAsDetached( | |||||||
| 	asw.DeleteVolume(volumeName) | 	asw.DeleteVolume(volumeName) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (asw *actualStateOfWorld) MarkVolumeExpansionFailedWithFinalError(volumeName v1.UniqueVolumeName) { | ||||||
|  | 	asw.Lock() | ||||||
|  | 	defer asw.Unlock() | ||||||
|  |  | ||||||
|  | 	asw.volumesWithFinalExpansionErrors.Insert(volumeName) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (asw *actualStateOfWorld) RemoveVolumeFromFailedWithFinalErrors(volumeName v1.UniqueVolumeName) { | ||||||
|  | 	asw.Lock() | ||||||
|  | 	defer asw.Unlock() | ||||||
|  |  | ||||||
|  | 	asw.volumesWithFinalExpansionErrors.Delete(volumeName) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (asw *actualStateOfWorld) CheckVolumeInFailedExpansionWithFinalErrors(volumeName v1.UniqueVolumeName) bool { | ||||||
|  | 	asw.RLock() | ||||||
|  | 	defer asw.RUnlock() | ||||||
|  |  | ||||||
|  | 	return asw.volumesWithFinalExpansionErrors.Has(volumeName) | ||||||
|  | } | ||||||
|  |  | ||||||
| func (asw *actualStateOfWorld) IsVolumeReconstructed(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName) bool { | func (asw *actualStateOfWorld) IsVolumeReconstructed(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName) bool { | ||||||
| 	volumeState := asw.GetVolumeMountState(volumeName, podName) | 	volumeState := asw.GetVolumeMountState(volumeName, podName) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -233,6 +233,18 @@ type ActualStateOfWorldMounterUpdater interface { | |||||||
| 	// IsVolumeDeviceReconstructed returns true if volume device identified by volumeName has been | 	// IsVolumeDeviceReconstructed returns true if volume device identified by volumeName has been | ||||||
| 	// found during reconstruction. | 	// found during reconstruction. | ||||||
| 	IsVolumeDeviceReconstructed(volumeName v1.UniqueVolumeName) bool | 	IsVolumeDeviceReconstructed(volumeName v1.UniqueVolumeName) bool | ||||||
|  |  | ||||||
|  | 	// MarkVolumeExpansionFailedWithFinalError marks volume as failed with a final error, so as | ||||||
|  | 	// this state doesn't have to be recorded in the API server | ||||||
|  | 	MarkVolumeExpansionFailedWithFinalError(volumeName v1.UniqueVolumeName) | ||||||
|  |  | ||||||
|  | 	// RemoveVolumeFromFailedWithFinalErrors removes volume from list that indicates that volume | ||||||
|  | 	// has failed expansion with a final error | ||||||
|  | 	RemoveVolumeFromFailedWithFinalErrors(volumeName v1.UniqueVolumeName) | ||||||
|  |  | ||||||
|  | 	// CheckVolumeInFailedExpansionWithFinalErrors verifies if volume expansion has failed with a final | ||||||
|  | 	// error | ||||||
|  | 	CheckVolumeInFailedExpansionWithFinalErrors(volumeName v1.UniqueVolumeName) bool | ||||||
| } | } | ||||||
|  |  | ||||||
| // ActualStateOfWorldAttacherUpdater defines a set of operations updating the | // ActualStateOfWorldAttacherUpdater defines a set of operations updating the | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Hemant Kumar
					Hemant Kumar