Documentation
¶
Index ¶
- Constants
- Variables
- func AddAnnotation(obj metav1.Object, key, value string)
- func AddFinalizer(obj metav1.Object, name string)
- func AddImportVolumeMounts() []corev1.VolumeMount
- func AddLabel(obj metav1.Object, key, value string)
- func AddVolumeDevices() []v1.VolumeDevice
- func CreateClient(objs ...runtime.Object) client.Client
- func CreateCloneSourcePodName(targetPvc *corev1.PersistentVolumeClaim) string
- func CreateImporterTestPod(pvc *corev1.PersistentVolumeClaim, dvname string, ...) *corev1.Pod
- func CreatePvc(name, ns string, annotations, labels map[string]string) *v1.PersistentVolumeClaim
- func CreatePvcInStorageClass(name, ns string, storageClassName *string, ...) *v1.PersistentVolumeClaim
- func CreateStorageClass(name string, annotations map[string]string) *storagev1.StorageClass
- func CreateStorageClassWithProvisioner(name string, annotations, labels map[string]string, provisioner string) *storagev1.StorageClass
- func ErrQuotaExceeded(err error) bool
- func GetAPIServerKey() *rsa.PrivateKey
- func GetActiveCDI(c client.Client) (*cdiv1.CDI, error)
- func GetCloneSourceNameAndNamespace(dv *cdiv1.DataVolume) (name, namespace string)
- func GetContentType(pvc *corev1.PersistentVolumeClaim) string
- func GetDataVolumeTTLSeconds(config *cdiv1.CDIConfig) int32
- func GetDefaultPodResourceRequirements(client client.Client) (*v1.ResourceRequirements, error)
- func GetDefaultStorageClass(client client.Client) (*storagev1.StorageClass, error)
- func GetEndpoint(pvc *corev1.PersistentVolumeClaim) (string, error)
- func GetFilesystemOverheadForStorageClass(client client.Client, storageClassName *string) (cdiv1.Percent, error)
- func GetNamespace(namespace, defaultNamespace string) string
- func GetPodsUsingPVCs(c client.Client, namespace string, names sets.String, allowReadOnly bool) ([]v1.Pod, error)
- func GetPreallocation(client client.Client, dataVolume *cdiv1.DataVolume) bool
- func GetPriorityClass(pvc *v1.PersistentVolumeClaim) string
- func GetRequestedImageSize(pvc *v1.PersistentVolumeClaim) (string, error)
- func GetSource(pvc *corev1.PersistentVolumeClaim) string
- func GetStorageClassByName(client client.Client, name *string) (*storagev1.StorageClass, error)
- func GetVolumeMode(pvc *v1.PersistentVolumeClaim) v1.PersistentVolumeMode
- func GetWorkloadNodePlacement(c client.Client) (*sdkapi.NodePlacement, error)
- func HandleFailedPod(err error, podName string, pvc *v1.PersistentVolumeClaim, ...) error
- func HasFinalizer(object metav1.Object, value string) bool
- func IgnoreIsNoMatchError(err error) error
- func IgnoreNotFound(err error) error
- func IsErrCacheNotStarted(err error) bool
- func IsPVCComplete(pvc *v1.PersistentVolumeClaim) bool
- func IsPopulated(pvc *v1.PersistentVolumeClaim, c client.Client) (bool, error)
- func MakeEmptyCDICR() *cdiv1.CDI
- func MakeEmptyCDIConfigSpec(name string) *cdiv1.CDIConfig
- func NewCloneTokenValidator(issuer string, key *rsa.PublicKey) token.Validator
- func NewImportDataVolume(name string) *cdiv1.DataVolume
- func RemoveFinalizer(obj metav1.Object, name string)
- func SetRestrictedSecurityContext(podSpec *v1.PodSpec)
- func ShouldDeletePod(pvc *v1.PersistentVolumeClaim) bool
- func ValidateClone(sourcePVC *v1.PersistentVolumeClaim, spec *cdiv1.DataVolumeSpec) error
- func ValidateCloneTokenDV(validator token.Validator, dv *cdiv1.DataVolume) error
- func ValidateCloneTokenPVC(t string, v token.Validator, source, target *v1.PersistentVolumeClaim) error
- func ValidateRequestedCloneSize(sourceResources corev1.ResourceRequirements, ...) error
- func ValidateSnapshotClone(sourceSnapshot *snapshotv1.VolumeSnapshot, spec *cdiv1.DataVolumeSpec) error
- type FakeValidator
Constants ¶
const ( // DataVolName provides a const to use for creating volumes in pod specs DataVolName = "cdi-data-vol" // ScratchVolName provides a const to use for creating scratch pvc volumes in pod specs ScratchVolName = "cdi-scratch-vol" // AnnAPIGroup is the APIGroup for CDI AnnAPIGroup = "cdi.kubevirt.io" // AnnCreatedBy is a pod annotation indicating if the pod was created by the PVC AnnCreatedBy = AnnAPIGroup + "/storage.createdByController" // AnnPodPhase is a PVC annotation indicating the related pod progress (phase) AnnPodPhase = AnnAPIGroup + "/storage.pod.phase" // AnnPodReady tells whether the pod is ready AnnPodReady = AnnAPIGroup + "/storage.pod.ready" // AnnPodRestarts is a PVC annotation that tells how many times a related pod was restarted AnnPodRestarts = AnnAPIGroup + "/storage.pod.restarts" // AnnPopulatedFor is a PVC annotation telling the datavolume controller that the PVC is already populated AnnPopulatedFor = AnnAPIGroup + "/storage.populatedFor" // AnnPrePopulated is a PVC annotation telling the datavolume controller that the PVC is already populated AnnPrePopulated = AnnAPIGroup + "/storage.prePopulated" // AnnPriorityClassName is PVC annotation to indicate the priority class name for importer, cloner and uploader pod AnnPriorityClassName = AnnAPIGroup + "/storage.pod.priorityclassname" // AnnExternalPopulation annotation marks a PVC as "externally populated", allowing the import-controller to skip it AnnExternalPopulation = AnnAPIGroup + "/externalPopulation" // AnnDeleteAfterCompletion is PVC annotation for deleting DV after completion AnnDeleteAfterCompletion = AnnAPIGroup + "/storage.deleteAfterCompletion" // AnnPodRetainAfterCompletion is PVC annotation for retaining transfer pods after completion AnnPodRetainAfterCompletion = AnnAPIGroup + "/storage.pod.retainAfterCompletion" // AnnPreviousCheckpoint provides a const to indicate the previous snapshot for a multistage import AnnPreviousCheckpoint = AnnAPIGroup + "/storage.checkpoint.previous" // AnnCurrentCheckpoint provides a const to indicate the current snapshot for a multistage import AnnCurrentCheckpoint = AnnAPIGroup + "/storage.checkpoint.current" // AnnFinalCheckpoint provides a const to indicate whether the current checkpoint is the last one AnnFinalCheckpoint = AnnAPIGroup + "/storage.checkpoint.final" // AnnCheckpointsCopied is a prefix for recording which checkpoints have already been copied AnnCheckpointsCopied = AnnAPIGroup + "/storage.checkpoint.copied" // AnnCurrentPodID keeps track of the latest pod servicing this PVC AnnCurrentPodID = AnnAPIGroup + "/storage.checkpoint.pod.id" // AnnMultiStageImportDone marks a multi-stage import as totally finished AnnMultiStageImportDone = AnnAPIGroup + "/storage.checkpoint.done" // AnnPreallocationRequested provides a const to indicate whether preallocation should be performed on the PV AnnPreallocationRequested = AnnAPIGroup + "/storage.preallocation.requested" // AnnPreallocationApplied provides a const for PVC preallocation annotation AnnPreallocationApplied = AnnAPIGroup + "/storage.preallocation" // AnnRunningCondition provides a const for the running condition AnnRunningCondition = AnnAPIGroup + "/storage.condition.running" // AnnRunningConditionMessage provides a const for the running condition AnnRunningConditionMessage = AnnAPIGroup + "/storage.condition.running.message" // AnnRunningConditionReason provides a const for the running condition AnnRunningConditionReason = AnnAPIGroup + "/storage.condition.running.reason" // AnnBoundCondition provides a const for the running condition AnnBoundCondition = AnnAPIGroup + "/storage.condition.bound" // AnnBoundConditionMessage provides a const for the running condition AnnBoundConditionMessage = AnnAPIGroup + "/storage.condition.bound.message" // AnnBoundConditionReason provides a const for the running condition AnnBoundConditionReason = AnnAPIGroup + "/storage.condition.bound.reason" // AnnSourceRunningCondition provides a const for the running condition AnnSourceRunningCondition = AnnAPIGroup + "/storage.condition.source.running" // AnnSourceRunningConditionMessage provides a const for the running condition AnnSourceRunningConditionMessage = AnnAPIGroup + "/storage.condition.source.running.message" // AnnSourceRunningConditionReason provides a const for the running condition AnnSourceRunningConditionReason = AnnAPIGroup + "/storage.condition.source.running.reason" // AnnVddkVersion shows the last VDDK library version used by a DV's importer pod AnnVddkVersion = AnnAPIGroup + "/storage.pod.vddk.version" // AnnVddkHostConnection shows the last ESX host that serviced a DV's importer pod AnnVddkHostConnection = AnnAPIGroup + "/storage.pod.vddk.host" // AnnVddkInitImageURL saves a per-DV VDDK image URL on the PVC AnnVddkInitImageURL = AnnAPIGroup + "/storage.pod.vddk.initimageurl" // AnnRequiresScratch provides a const for our PVC requires scratch annotation AnnRequiresScratch = AnnAPIGroup + "/storage.import.requiresScratch" // AnnContentType provides a const for the PVC content-type AnnContentType = AnnAPIGroup + "/storage.contentType" // AnnSource provide a const for our PVC import source annotation AnnSource = AnnAPIGroup + "/storage.import.source" // AnnEndpoint provides a const for our PVC endpoint annotation AnnEndpoint = AnnAPIGroup + "/storage.import.endpoint" // AnnSecret provides a const for our PVC secretName annotation AnnSecret = AnnAPIGroup + "/storage.import.secretName" // AnnCertConfigMap is the name of a configmap containing tls certs AnnCertConfigMap = AnnAPIGroup + "/storage.import.certConfigMap" // AnnRegistryImportMethod provides a const for registry import method annotation AnnRegistryImportMethod = AnnAPIGroup + "/storage.import.registryImportMethod" // AnnRegistryImageStream provides a const for registry image stream annotation AnnRegistryImageStream = AnnAPIGroup + "/storage.import.registryImageStream" // AnnImportPod provides a const for our PVC importPodName annotation AnnImportPod = AnnAPIGroup + "/storage.import.importPodName" // AnnDiskID provides a const for our PVC diskId annotation AnnDiskID = AnnAPIGroup + "/storage.import.diskId" // AnnUUID provides a const for our PVC uuid annotation AnnUUID = AnnAPIGroup + "/storage.import.uuid" // AnnBackingFile provides a const for our PVC backing file annotation AnnBackingFile = AnnAPIGroup + "/storage.import.backingFile" // AnnThumbprint provides a const for our PVC backing thumbprint annotation AnnThumbprint = AnnAPIGroup + "/storage.import.vddk.thumbprint" // AnnExtraHeaders provides a const for our PVC extraHeaders annotation AnnExtraHeaders = AnnAPIGroup + "/storage.import.extraHeaders" // AnnSecretExtraHeaders provides a const for our PVC secretExtraHeaders annotation AnnSecretExtraHeaders = AnnAPIGroup + "/storage.import.secretExtraHeaders" // AnnCloneToken is the annotation containing the clone token AnnCloneToken = AnnAPIGroup + "/storage.clone.token" // AnnExtendedCloneToken is the annotation containing the long term clone token AnnExtendedCloneToken = AnnAPIGroup + "/storage.extended.clone.token" // AnnPermissiveClone annotation allows the clone-controller to skip the clone size validation AnnPermissiveClone = AnnAPIGroup + "/permissiveClone" // AnnOwnerUID annotation has the owner UID AnnOwnerUID = AnnAPIGroup + "/ownerUID" // AnnUploadRequest marks that a PVC should be made available for upload AnnUploadRequest = AnnAPIGroup + "/storage.upload.target" //AnnDefaultStorageClass is the annotation indicating that a storage class is the default one. AnnDefaultStorageClass = "storageclass.kubernetes.io/is-default-class" // AnnOpenShiftImageLookup is the annotation for OpenShift image stream lookup AnnOpenShiftImageLookup = "alpha.image.policy.openshift.io/resolve-names" // AnnCloneRequest sets our expected annotation for a CloneRequest AnnCloneRequest = "k8s.io/CloneRequest" // AnnCloneOf is used to indicate that cloning was complete AnnCloneOf = "k8s.io/CloneOf" // AnnPodNetwork is used for specifying Pod Network AnnPodNetwork = "k8s.v1.cni.cncf.io/networks" // AnnPodMultusDefaultNetwork is used for specifying default Pod Network AnnPodMultusDefaultNetwork = "v1.multus-cni.io/default-network" // AnnPodSidecarInjection is used for enabling/disabling Pod istio/AspenMesh sidecar injection AnnPodSidecarInjection = "sidecar.istio.io/inject" // AnnPodSidecarInjectionDefault is the default value passed for AnnPodSidecarInjection AnnPodSidecarInjectionDefault = "false" // CloneUniqueID is used as a special label to be used when we search for the pod CloneUniqueID = "cdi.kubevirt.io/storage.clone.cloneUniqeId" // CloneSourceInUse is reason for event created when clone source pvc is in use CloneSourceInUse = "CloneSourceInUse" // CloneComplete message CloneComplete = "Clone Complete" // ErrStartingPod provides a const to indicate that a pod wasn't able to start without providing sensitive information (reason) ErrStartingPod = "ErrStartingPod" // MessageErrStartingPod provides a const to indicate that a pod wasn't able to start without providing sensitive information (message) MessageErrStartingPod = "Error starting pod '%s': For more information, request access to cdi-deploy logs from your sysadmin" // ErrClaimNotValid provides a const to indicate a claim is not valid ErrClaimNotValid = "ErrClaimNotValid" // ErrExceededQuota provides a const to indicate the claim has exceeded the quota ErrExceededQuota = "ErrExceededQuota" // ErrIncompatiblePVC provides a const to indicate a clone is not possible due to an incompatible PVC ErrIncompatiblePVC = "ErrIncompatiblePVC" // SourceHTTP is the source type HTTP, if unspecified or invalid, it defaults to SourceHTTP SourceHTTP = "http" // SourceS3 is the source type S3 SourceS3 = "s3" // SourceGlance is the source type of glance SourceGlance = "glance" // SourceNone means there is no source. SourceNone = "none" // SourceRegistry is the source type of Registry SourceRegistry = "registry" // SourceImageio is the source type ovirt-imageio SourceImageio = "imageio" // SourceVDDK is the source type of VDDK SourceVDDK = "vddk" // ClaimLost reason const ClaimLost = "ClaimLost" // NotFound reason const NotFound = "NotFound" // LabelDefaultInstancetype provides a default VirtualMachine{ClusterInstancetype,Instancetype} that can be used by a VirtualMachine booting from a given PVC LabelDefaultInstancetype = "instancetype.kubevirt.io/default-instancetype" // LabelDefaultInstancetypeKind provides a default kind of either VirtualMachineClusterInstancetype or VirtualMachineInstancetype LabelDefaultInstancetypeKind = "instancetype.kubevirt.io/default-instancetype-kind" // LabelDefaultPreference provides a default VirtualMachine{ClusterPreference,Preference} that can be used by a VirtualMachine booting from a given PVC LabelDefaultPreference = "instancetype.kubevirt.io/default-preference" // LabelDefaultPreferenceKind provides a default kind of either VirtualMachineClusterPreference or VirtualMachinePreference LabelDefaultPreferenceKind = "instancetype.kubevirt.io/default-preference-kind" )
const ( NoErr int = iota ErrBadArguments ErrInvalidFile ErrInvalidPath ErrBadTermFile ErrUnknown )
Size-detection pod error codes
Variables ¶
var ( // BlockMode is raw block device mode BlockMode = corev1.PersistentVolumeBlock // FilesystemMode is filesystem device mode FilesystemMode = corev1.PersistentVolumeFilesystem )
Functions ¶
func AddAnnotation ¶
AddAnnotation adds an annotation to an object
func AddFinalizer ¶
AddFinalizer adds a finalizer to a resource
func AddImportVolumeMounts ¶
func AddImportVolumeMounts() []corev1.VolumeMount
AddImportVolumeMounts is being called for pods using PV with filesystem volume mode
func AddVolumeDevices ¶
func AddVolumeDevices() []v1.VolumeDevice
AddVolumeDevices returns VolumeDevice slice with one block device for pods using PV with block volume mode
func CreateClient ¶
CreateClient creates a fake client
func CreateCloneSourcePodName ¶
func CreateCloneSourcePodName(targetPvc *corev1.PersistentVolumeClaim) string
CreateCloneSourcePodName creates clone source pod name
func CreateImporterTestPod ¶
func CreateImporterTestPod(pvc *corev1.PersistentVolumeClaim, dvname string, scratchPvc *corev1.PersistentVolumeClaim) *corev1.Pod
CreateImporterTestPod creates importer test pod CR
func CreatePvc ¶
func CreatePvc(name, ns string, annotations, labels map[string]string) *v1.PersistentVolumeClaim
CreatePvc creates PVC
func CreatePvcInStorageClass ¶
func CreatePvcInStorageClass(name, ns string, storageClassName *string, annotations, labels map[string]string, phase v1.PersistentVolumeClaimPhase) *v1.PersistentVolumeClaim
CreatePvcInStorageClass creates PVC with storgae class
func CreateStorageClass ¶
func CreateStorageClass(name string, annotations map[string]string) *storagev1.StorageClass
CreateStorageClass creates storage class CR
func CreateStorageClassWithProvisioner ¶
func CreateStorageClassWithProvisioner(name string, annotations, labels map[string]string, provisioner string) *storagev1.StorageClass
CreateStorageClassWithProvisioner creates CR of storage class with provisioner
func ErrQuotaExceeded ¶
ErrQuotaExceeded checked is the error is of exceeded quota
func GetAPIServerKey ¶
func GetAPIServerKey() *rsa.PrivateKey
GetAPIServerKey returns API server RSA key
func GetActiveCDI ¶
GetActiveCDI returns the active CDI CR
func GetCloneSourceNameAndNamespace ¶
func GetCloneSourceNameAndNamespace(dv *cdiv1.DataVolume) (name, namespace string)
GetCloneSourceNameAndNamespace returns the name and namespace of the cloning source
func GetContentType ¶
func GetContentType(pvc *corev1.PersistentVolumeClaim) string
GetContentType returns the content type of the source image. If invalid or not set, default to kubevirt
func GetDataVolumeTTLSeconds ¶
GetDataVolumeTTLSeconds gets the current DataVolume TTL in seconds if GC is enabled, or < 0 if GC is disabled
func GetDefaultPodResourceRequirements ¶
func GetDefaultPodResourceRequirements(client client.Client) (*v1.ResourceRequirements, error)
GetDefaultPodResourceRequirements gets default pod resource requirements from cdi config status
func GetDefaultStorageClass ¶
func GetDefaultStorageClass(client client.Client) (*storagev1.StorageClass, error)
GetDefaultStorageClass returns the default storage class or nil if none found
func GetEndpoint ¶
func GetEndpoint(pvc *corev1.PersistentVolumeClaim) (string, error)
GetEndpoint returns the endpoint string which contains the full path URI of the target object to be copied.
func GetFilesystemOverheadForStorageClass ¶
func GetFilesystemOverheadForStorageClass(client client.Client, storageClassName *string) (cdiv1.Percent, error)
GetFilesystemOverheadForStorageClass determines the filesystem overhead defined in CDIConfig for the storageClass.
func GetNamespace ¶
GetNamespace returns the given namespace if not empty, otherwise the default namespace
func GetPodsUsingPVCs ¶
func GetPodsUsingPVCs(c client.Client, namespace string, names sets.String, allowReadOnly bool) ([]v1.Pod, error)
GetPodsUsingPVCs returns Pods currently using PVCs
func GetPreallocation ¶
func GetPreallocation(client client.Client, dataVolume *cdiv1.DataVolume) bool
GetPreallocation retuns the preallocation setting for DV, falling back to StorageClass and global setting (in this order)
func GetPriorityClass ¶
func GetPriorityClass(pvc *v1.PersistentVolumeClaim) string
GetPriorityClass gets PVC priority class
func GetRequestedImageSize ¶
func GetRequestedImageSize(pvc *v1.PersistentVolumeClaim) (string, error)
GetRequestedImageSize returns the PVC requested size
func GetSource ¶
func GetSource(pvc *corev1.PersistentVolumeClaim) string
GetSource returns the source string which determines the type of source. If no source or invalid source found, default to http
func GetStorageClassByName ¶
GetStorageClassByName looks up the storage class based on the name. If no storage class is found returns nil
func GetVolumeMode ¶
func GetVolumeMode(pvc *v1.PersistentVolumeClaim) v1.PersistentVolumeMode
GetVolumeMode returns the volumeMode from PVC handling default empty value
func GetWorkloadNodePlacement ¶
func GetWorkloadNodePlacement(c client.Client) (*sdkapi.NodePlacement, error)
GetWorkloadNodePlacement extracts the workload-specific nodeplacement values from the CDI CR
func HandleFailedPod ¶
func HandleFailedPod(err error, podName string, pvc *v1.PersistentVolumeClaim, recorder record.EventRecorder, c client.Client) error
HandleFailedPod handles pod-creation errors and updates the pod's PVC without providing sensitive information
func HasFinalizer ¶
HasFinalizer returns true if a resource has a specific finalizer
func IgnoreIsNoMatchError ¶
IgnoreIsNoMatchError returns nil if the error is a IsNoMatchError. We will want to ignore this error for optional CRDs, if it is not found, just ignore it.
func IgnoreNotFound ¶
IgnoreNotFound returns nil if the error is a NotFound error. We generally want to ignore (not requeue) NotFound errors, since we'll get a reconciliation request once the object exists, and requeuing in the meantime won't help.
func IsErrCacheNotStarted ¶
IsErrCacheNotStarted checked is the error is of cache not started
func IsPVCComplete ¶
func IsPVCComplete(pvc *v1.PersistentVolumeClaim) bool
IsPVCComplete returns true if a PVC is in 'Succeeded' phase, false if not
func IsPopulated ¶
IsPopulated returns if the passed in PVC has been populated according to the rules outlined in pkg/apis/core/<version>/utils.go
func MakeEmptyCDICR ¶
MakeEmptyCDICR creates CDI CustomResouce manifest
func MakeEmptyCDIConfigSpec ¶
MakeEmptyCDIConfigSpec creates cdi config manifest
func NewCloneTokenValidator ¶
NewCloneTokenValidator returns a new token validator
func NewImportDataVolume ¶
func NewImportDataVolume(name string) *cdiv1.DataVolume
NewImportDataVolume returns new import DataVolume CR
func RemoveFinalizer ¶
RemoveFinalizer removes a finalizer from a resource
func SetRestrictedSecurityContext ¶
SetRestrictedSecurityContext sets the pod security params to be compatible with restricted PSA
func ShouldDeletePod ¶
func ShouldDeletePod(pvc *v1.PersistentVolumeClaim) bool
ShouldDeletePod returns whether the PVC workload pod should be deleted
func ValidateClone ¶
func ValidateClone(sourcePVC *v1.PersistentVolumeClaim, spec *cdiv1.DataVolumeSpec) error
ValidateClone compares a clone spec against its source PVC to validate its creation
func ValidateCloneTokenDV ¶
func ValidateCloneTokenDV(validator token.Validator, dv *cdiv1.DataVolume) error
ValidateCloneTokenDV validates clone token for DV
func ValidateCloneTokenPVC ¶
func ValidateCloneTokenPVC(t string, v token.Validator, source, target *v1.PersistentVolumeClaim) error
ValidateCloneTokenPVC validates clone token for source and target PVCs
func ValidateRequestedCloneSize ¶
func ValidateRequestedCloneSize(sourceResources corev1.ResourceRequirements, targetResources corev1.ResourceRequirements) error
ValidateRequestedCloneSize validates the clone size requirements on block
func ValidateSnapshotClone ¶
func ValidateSnapshotClone(sourceSnapshot *snapshotv1.VolumeSnapshot, spec *cdiv1.DataVolumeSpec) error
ValidateSnapshotClone compares a snapshot clone spec against its source snapshot to validate its creation