From af2a89ab7a6ff1c9bf60dec2f1c16ac2ebc93795 Mon Sep 17 00:00:00 2001 From: Matous Jobanek Date: Mon, 22 Dec 2025 16:04:01 +0100 Subject: [PATCH 1/3] verify that DataVolume is idled --- deploy/crds/cdi.kubevirt.io_datavolumes.yaml | 659 +++++++++++++++++++ test/e2e/parallel/user_workloads_test.go | 88 +++ testsupport/wait/member.go | 16 + 3 files changed, 763 insertions(+) create mode 100644 deploy/crds/cdi.kubevirt.io_datavolumes.yaml diff --git a/deploy/crds/cdi.kubevirt.io_datavolumes.yaml b/deploy/crds/cdi.kubevirt.io_datavolumes.yaml new file mode 100644 index 000000000..0ce498967 --- /dev/null +++ b/deploy/crds/cdi.kubevirt.io_datavolumes.yaml @@ -0,0 +1,659 @@ +kind: CustomResourceDefinition +apiVersion: apiextensions.k8s.io/v1 +metadata: + name: datavolumes.cdi.kubevirt.io +spec: + group: cdi.kubevirt.io + names: + plural: datavolumes + singular: datavolume + shortNames: + - dv + - dvs + kind: DataVolume + listKind: DataVolumeList + categories: + - all + scope: Namespaced + versions: + - name: v1beta1 + served: true + storage: true + schema: + openAPIV3Schema: + description: DataVolume is an abstraction on top of PersistentVolumeClaims to allow easy population of those PersistentVolumeClaims with relation to VirtualMachines + type: object + required: + - spec + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: DataVolumeSpec defines the DataVolume type specification + type: object + properties: + preallocation: + description: Preallocation controls whether storage for DataVolumes should be allocated in advance. + type: boolean + checkpoints: + description: 'Checkpoints is a list of DataVolumeCheckpoints, representing stages in a multistage import.' + type: array + items: + description: DataVolumeCheckpoint defines a stage in a warm migration. + type: object + required: + - current + - previous + properties: + current: + description: Current is the identifier of the snapshot created for this checkpoint. + type: string + previous: + description: Previous is the identifier of the snapshot from the previous checkpoint. + type: string + contentType: + description: 'DataVolumeContentType options: "kubevirt", "archive"' + type: string + enum: + - kubevirt + - archive + sourceRef: + description: SourceRef is an indirect reference to the source of data for the requested DataVolume + type: object + required: + - kind + - name + properties: + kind: + description: 'The kind of the source reference, currently only "DataSource" is supported' + type: string + name: + description: The name of the source reference + type: string + namespace: + description: 'The namespace of the source reference, defaults to the DataVolume namespace' + type: string + source: + description: Source is the src of the data for the requested DataVolume + type: object + properties: + s3: + description: DataVolumeSourceS3 provides the parameters to create a Data Volume from an S3 source + type: object + required: + - url + properties: + certConfigMap: + description: 'CertConfigMap is a configmap reference, containing a Certificate Authority(CA) public key, and a base64 encoded pem certificate' + type: string + secretRef: + description: SecretRef provides the secret reference needed to access the S3 source + type: string + url: + description: URL is the url of the S3 source + type: string + upload: + description: DataVolumeSourceUpload provides the parameters to create a Data Volume by uploading the source + type: object + imageio: + description: DataVolumeSourceImageIO provides the parameters to create a Data Volume from an imageio source + type: object + required: + - diskId + - url + properties: + certConfigMap: + description: CertConfigMap provides a reference to the CA cert + type: string + diskId: + description: DiskID provides id of a disk to be imported + type: string + secretRef: + description: SecretRef provides the secret reference needed to access the ovirt-engine + type: string + url: + description: URL is the URL of the ovirt-engine + type: string + snapshot: + description: DataVolumeSourceSnapshot provides the parameters to create a Data Volume from an existing VolumeSnapshot + type: object + required: + - name + - namespace + properties: + name: + description: The name of the source VolumeSnapshot + type: string + namespace: + description: The namespace of the source VolumeSnapshot + type: string + http: + description: 'DataVolumeSourceHTTP can be either an http or https endpoint, with an optional basic auth user name and password, and an optional configmap containing additional CAs' + type: object + required: + - url + properties: + certConfigMap: + description: 'CertConfigMap is a configmap reference, containing a Certificate Authority(CA) public key, and a base64 encoded pem certificate' + type: string + extraHeaders: + description: ExtraHeaders is a list of strings containing extra headers to include with HTTP transfer requests + type: array + items: + type: string + secretExtraHeaders: + description: 'SecretExtraHeaders is a list of Secret references, each containing an extra HTTP header that may include sensitive information' + type: array + items: + type: string + secretRef: + description: 'SecretRef A Secret reference, the secret should contain accessKeyId (user name) base64 encoded, and secretKey (password) also base64 encoded' + type: string + url: + description: URL is the URL of the http(s) endpoint + type: string + blank: + description: DataVolumeBlankImage provides the parameters to create a new raw blank image for the PVC + type: object + vddk: + description: DataVolumeSourceVDDK provides the parameters to create a Data Volume from a Vmware source + type: object + properties: + backingFile: + description: BackingFile is the path to the virtual hard disk to migrate from vCenter/ESXi + type: string + extraArgs: + description: ExtraArgs is a reference to a ConfigMap containing extra arguments to pass directly to the VDDK library + type: string + initImageURL: + description: 'InitImageURL is an optional URL to an image containing an extracted VDDK library, overrides v2v-vmware config map' + type: string + secretRef: + description: SecretRef provides a reference to a secret containing the username and password needed to access the vCenter or ESXi host + type: string + thumbprint: + description: Thumbprint is the certificate thumbprint of the vCenter or ESXi host + type: string + url: + description: URL is the URL of the vCenter or ESXi host with the VM to migrate + type: string + uuid: + description: UUID is the UUID of the virtual machine that the backing file is attached to in vCenter/ESXi + type: string + gcs: + description: DataVolumeSourceGCS provides the parameters to create a Data Volume from an GCS source + type: object + required: + - url + properties: + secretRef: + description: SecretRef provides the secret reference needed to access the GCS source + type: string + url: + description: URL is the url of the GCS source + type: string + registry: + description: DataVolumeSourceRegistry provides the parameters to create a Data Volume from an registry source + type: object + properties: + certConfigMap: + description: CertConfigMap provides a reference to the Registry certs + type: string + imageStream: + description: ImageStream is the name of image stream for import + type: string + platform: + description: Platform describes the minimum runtime requirements of the image + type: object + properties: + architecture: + description: Architecture specifies the image target CPU architecture + type: string + pullMethod: + description: 'PullMethod can be either "pod" (default import), or "node" (node docker cache based import)' + type: string + secretRef: + description: SecretRef provides the secret reference needed to access the Registry source + type: string + url: + description: 'URL is the url of the registry source (starting with the scheme: docker, oci-archive)' + type: string + pvc: + description: DataVolumeSourcePVC provides the parameters to create a Data Volume from an existing PVC + type: object + required: + - name + - namespace + properties: + name: + description: The name of the source PVC + type: string + namespace: + description: The namespace of the source PVC + type: string + storage: + description: Storage is the requested storage specification + type: object + properties: + accessModes: + description: |- + AccessModes contains the desired access modes the volume should have. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1 + type: array + items: + type: string + dataSource: + description: |- + This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) * An existing custom resource that implements data population (Alpha) In order to use custom resource types that implement data population, the AnyVolumeDataSource feature gate must be enabled. If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. + If the AnyVolumeDataSource feature gate is enabled, this field will always have the same contents as the DataSourceRef field. + type: object + required: + - kind + - name + properties: + apiGroup: + description: |- + APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in the core API group. + For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + x-kubernetes-map-type: atomic + dataSourceRef: + description: |- + Specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any local object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. + This field will replace the functionality of the DataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, both fields (DataSource and DataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. + There are two important differences between DataSource and DataSourceRef: + * While DataSource only allows two specific types of objects, DataSourceRef allows any non-core object, as well as PersistentVolumeClaim objects. + * While DataSource ignores disallowed values (dropping them), DataSourceRef preserves all values, and generates an error if a disallowed value is specified. + (Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled. + type: object + required: + - kind + - name + properties: + apiGroup: + description: |- + APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in the core API group. + For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + namespace: + description: |- + Namespace is the namespace of resource being referenced + Note that when a namespace is specified, a gateway.networking.k8s.io/ReferenceGrant object is required in the referent namespace to allow that namespace's owner to accept the reference. See the ReferenceGrant documentation for details. + (Alpha) This field requires the CrossNamespaceVolumeDataSource feature gate to be enabled. + type: string + resources: + description: |- + Resources represents the minimum resources the volume should have. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources + type: object + properties: + limits: + description: |- + Limits describes the maximum amount of compute resources allowed. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + additionalProperties: + pattern: '^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$' + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + requests: + description: |- + Requests describes the minimum amount of compute resources required. + If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + otherwise to an implementation-defined value. Requests cannot exceed Limits. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + additionalProperties: + pattern: '^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$' + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + selector: + description: A label query over volumes to consider for binding. + type: object + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + type: array + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + type: object + required: + - key + - operator + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + type: array + items: + type: string + x-kubernetes-list-type: atomic + x-kubernetes-list-type: atomic + matchLabels: + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + additionalProperties: + type: string + x-kubernetes-map-type: atomic + storageClassName: + description: |- + Name of the StorageClass required by the claim. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 + type: string + volumeMode: + description: |- + volumeMode defines what type of volume is required by the claim. + Value of Filesystem is implied when not included in claim spec. + type: string + volumeName: + description: VolumeName is the binding reference to the PersistentVolume backing this claim. + type: string + pvc: + description: PVC is the PVC specification + type: object + properties: + dataSource: + description: |- + dataSource field can be used to specify either: + * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) + * An existing PVC (PersistentVolumeClaim) + If the provisioner or an external controller can support the specified data source, + it will create a new volume based on the contents of the specified data source. + When the AnyVolumeDataSource feature gate is enabled, dataSource contents will be copied to dataSourceRef, + and dataSourceRef contents will be copied to dataSource when dataSourceRef.namespace is not specified. + If the namespace is specified, then dataSourceRef will not be copied to dataSource. + type: object + required: + - kind + - name + properties: + apiGroup: + description: |- + APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in the core API group. + For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + x-kubernetes-map-type: atomic + volumeName: + description: volumeName is the binding reference to the PersistentVolume backing this claim. + type: string + resources: + description: |- + resources represents the minimum resources the volume should have. + If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements + that are lower than previous value but must still be higher than capacity recorded in the + status field of the claim. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources + type: object + properties: + limits: + description: |- + Limits describes the maximum amount of compute resources allowed. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + additionalProperties: + pattern: '^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$' + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + requests: + description: |- + Requests describes the minimum amount of compute resources required. + If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + otherwise to an implementation-defined value. Requests cannot exceed Limits. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + additionalProperties: + pattern: '^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$' + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + storageClassName: + description: |- + storageClassName is the name of the StorageClass required by the claim. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 + type: string + accessModes: + description: |- + accessModes contains the desired access modes the volume should have. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1 + type: array + items: + type: string + x-kubernetes-list-type: atomic + dataSourceRef: + description: |- + dataSourceRef specifies the object from which to populate the volume with data, if a non-empty + volume is desired. This may be any object from a non-empty API group (non + core object) or a PersistentVolumeClaim object. + When this field is specified, volume binding will only succeed if the type of + the specified object matches some installed volume populator or dynamic + provisioner. + This field will replace the functionality of the dataSource field and as such + if both fields are non-empty, they must have the same value. For backwards + compatibility, when namespace isn't specified in dataSourceRef, + both fields (dataSource and dataSourceRef) will be set to the same + value automatically if one of them is empty and the other is non-empty. + When namespace is specified in dataSourceRef, + dataSource isn't set to the same value and must be empty. + There are three important differences between dataSource and dataSourceRef: + * While dataSource only allows two specific types of objects, dataSourceRef + allows any non-core object, as well as PersistentVolumeClaim objects. + * While dataSource ignores disallowed values (dropping them), dataSourceRef + preserves all values, and generates an error if a disallowed value is + specified. + * While dataSource only allows local objects, dataSourceRef allows objects + in any namespaces. + (Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled. + (Alpha) Using the namespace field of dataSourceRef requires the CrossNamespaceVolumeDataSource feature gate to be enabled. + type: object + required: + - kind + - name + properties: + apiGroup: + description: |- + APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in the core API group. + For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + namespace: + description: |- + Namespace is the namespace of resource being referenced + Note that when a namespace is specified, a gateway.networking.k8s.io/ReferenceGrant object is required in the referent namespace to allow that namespace's owner to accept the reference. See the ReferenceGrant documentation for details. + (Alpha) This field requires the CrossNamespaceVolumeDataSource feature gate to be enabled. + type: string + volumeAttributesClassName: + description: |- + volumeAttributesClassName may be used to set the VolumeAttributesClass used by this claim. + If specified, the CSI driver will create or update the volume with the attributes defined + in the corresponding VolumeAttributesClass. This has a different purpose than storageClassName, + it can be changed after the claim is created. An empty string value means that no VolumeAttributesClass + will be applied to the claim but it's not allowed to reset this field to empty string once it is set. + If unspecified and the PersistentVolumeClaim is unbound, the default VolumeAttributesClass + will be set by the persistentvolume controller if it exists. + If the resource referred to by volumeAttributesClass does not exist, this PersistentVolumeClaim will be + set to a Pending state, as reflected by the modifyVolumeStatus field, until such as a resource + exists. + More info: https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/ + (Alpha) Using this field requires the VolumeAttributesClass feature gate to be enabled. + type: string + volumeMode: + description: |- + volumeMode defines what type of volume is required by the claim. + Value of Filesystem is implied when not included in claim spec. + type: string + selector: + description: selector is a label query over volumes to consider for binding. + type: object + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + type: array + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + type: object + required: + - key + - operator + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + type: array + items: + type: string + x-kubernetes-list-type: atomic + x-kubernetes-list-type: atomic + matchLabels: + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + additionalProperties: + type: string + x-kubernetes-map-type: atomic + finalCheckpoint: + description: FinalCheckpoint indicates whether the current DataVolumeCheckpoint is the final checkpoint. + type: boolean + priorityClassName: + description: 'PriorityClassName for Importer, Cloner and Uploader pod' + type: string + status: + description: DataVolumeStatus contains the current status of the DataVolume + type: object + properties: + claimName: + description: ClaimName is the name of the underlying PVC used by the DataVolume. + type: string + conditions: + type: array + items: + description: DataVolumeCondition represents the state of a data volume condition. + type: object + required: + - status + - type + properties: + lastHeartbeatTime: + type: string + format: date-time + lastTransitionTime: + type: string + format: date-time + message: + type: string + reason: + type: string + status: + type: string + type: + description: DataVolumeConditionType is the string representation of known condition types + type: string + phase: + description: Phase is the current phase of the data volume + type: string + progress: + description: 'DataVolumeProgress is the current progress of the DataVolume transfer operation. Value between 0 and 100 inclusive, N/A if not available' + type: string + restartCount: + description: RestartCount is the number of times the pod populating the DataVolume has restarted + type: integer + format: int32 + subresources: + status: {} + additionalPrinterColumns: + - name: Phase + type: string + description: The phase the data volume is in + jsonPath: .status.phase + - name: Progress + type: string + description: 'Transfer progress in percentage if known, N/A otherwise' + jsonPath: .status.progress + - name: Restarts + type: integer + description: The number of times the transfer has been restarted. + jsonPath: .status.restartCount + - name: Age + type: date + jsonPath: .metadata.creationTimestamp + conversion: + strategy: None diff --git a/test/e2e/parallel/user_workloads_test.go b/test/e2e/parallel/user_workloads_test.go index 689823fa2..8abe5354f 100644 --- a/test/e2e/parallel/user_workloads_test.go +++ b/test/e2e/parallel/user_workloads_test.go @@ -2,6 +2,7 @@ package parallel import ( "context" + "os" "testing" "time" @@ -27,6 +28,13 @@ import ( func TestIdlerAndPriorityClass(t *testing.T) { t.Parallel() + os.Setenv("KUBECONFIG", "/home/mjobanek/.kube/config") + os.Setenv("MEMBER_NS", "toolchain-member-22141926") + os.Setenv("MEMBER_NS_2", "toolchain-member2-22141926") + os.Setenv("SECOND_MEMBER_MODE", "true") + os.Setenv("HOST_NS", "toolchain-host-22141926") + os.Setenv("REGISTRATION_SERVICE_NS", "toolchain-host-22141926") + await := WaitForDeployments(t) hostAwait := await.Host() memberAwait := await.Member1() @@ -107,6 +115,10 @@ func TestIdlerAndPriorityClass(t *testing.T) { // the idler idles the second-top-owner when the pod is still running err = memberAwait.WaitUntilInferenceServiceDeleted(t, "test-idler-kserve", idler.Name, clnt.Resource(inferenceServiceRes)) require.NoError(t, err) + + // Wait for the DataVolume to be deleted + err = memberAwait.WaitUntilDataVolumeDeleted(t, "test-idler-datavolume", idler.Name, clnt.Resource(dataVolumeRes)) + require.NoError(t, err) } func prepareIdlerUser(t *testing.T, await wait.Awaitilities, name string) (*toolchainv1alpha1.Idler, *toolchainv1alpha1.Idler) { @@ -162,6 +174,10 @@ func prepareWorkloads(t *testing.T, memberAwait *wait.MemberAwaitility, namespac aapDeployment := createAAP(t, memberAwait, "test-idler-aap", namespace) n = n + int(*aapDeployment.Spec.Replicas) + // Create a DataVolume resource with manual PVC and Pod + createDataVolume(t, memberAwait, "test-idler-datavolume", namespace) + n = n + 1 + servingRuntimeDeployment := createKServeWorkloads(t, memberAwait, "test-idler-kserve", namespace) n = n + int(*servingRuntimeDeployment.Spec.Replicas) @@ -194,6 +210,7 @@ func createDeployment(t *testing.T, memberAwait *wait.MemberAwaitility, namespac var aapRes = schema.GroupVersionResource{Group: "aap.ansible.com", Version: "v1alpha1", Resource: "ansibleautomationplatforms"} var servingRuntimeRes = schema.GroupVersionResource{Group: "serving.kserve.io", Version: "v1alpha1", Resource: "servingruntimes"} var inferenceServiceRes = schema.GroupVersionResource{Group: "serving.kserve.io", Version: "v1beta1", Resource: "inferenceservices"} +var dataVolumeRes = schema.GroupVersionResource{Group: "cdi.kubevirt.io", Version: "v1beta1", Resource: "datavolumes"} // createAAP creates an instance of ansibleautomationplatforms.aap.ansible.com with one deployment owned by this instance // returns the underlying deployment @@ -387,6 +404,77 @@ func aapResource(name string) *unstructured.Unstructured { } } +// createDataVolume creates an instance of datavolumes.cdi.kubevirt.io with one PVC and Pod owned in chain +func createDataVolume(t *testing.T, memberAwait *wait.MemberAwaitility, name, namespace string) *corev1.Pod { + cl, err := dynamic.NewForConfig(memberAwait.RestConfig) + require.NoError(t, err) + + // Create a DataVolume instance + dataVolume := dataVolumeResource(name) + createdDataVolume, err := cl.Resource(dataVolumeRes).Namespace(namespace).Create(context.TODO(), dataVolume, metav1.CreateOptions{}) + require.NoError(t, err) + + // Manually create PVC (simulating CDI controller behavior) with DataVolume as owner + return createPvcWithPod(t, memberAwait, name, namespace, createdDataVolume) +} + +func createPvcWithPod(t *testing.T, memberAwait *wait.MemberAwaitility, name, namespace string, owner client.Object) *corev1.Pod { + pvc := &corev1.PersistentVolumeClaim{} + pvc.SetName(name + "-pvc") + pvc.SetNamespace(namespace) + pvc.Spec.AccessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce} + pvc.Spec.Resources.Requests = corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("1Gi")} + + if owner != nil { + require.NoError(t, controllerutil.SetOwnerReference(owner, pvc, scheme.Scheme)) + } + require.NoError(t, memberAwait.CreateWithCleanup(t, pvc)) + + // Create a Pod with PVC as owner and mount the PVC + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: name + "-pod", + Namespace: namespace, + Labels: map[string]string{"idler": "idler", "app": name}, + }, + Spec: podSpec(), + } + // Add volume mount to the pod + pod.Spec.Volumes = []corev1.Volume{ + { + Name: "data-volume", + VolumeSource: corev1.VolumeSource{ + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ + ClaimName: pvc.Name, + }, + }, + }, + } + pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{ + { + Name: "data-volume", + MountPath: "/data", + }, + } + require.NoError(t, controllerutil.SetOwnerReference(pvc, pod, scheme.Scheme)) + require.NoError(t, memberAwait.CreateWithCleanup(t, pod)) + + return pod +} + +func dataVolumeResource(name string) *unstructured.Unstructured { + return &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "cdi.kubevirt.io/v1beta1", + "kind": "DataVolume", + "metadata": map[string]interface{}{ + "name": name, + }, + "spec": map[string]interface{}{}, + }, + } +} + // createKServeWorkloads creates ServingRuntime and InferenceService instances with one deployment owned by ServingRuntime // returns the underlying deployment func createKServeWorkloads(t *testing.T, memberAwait *wait.MemberAwaitility, name, namespace string) *appsv1.Deployment { diff --git a/testsupport/wait/member.go b/testsupport/wait/member.go index 09380d35c..6046acf77 100644 --- a/testsupport/wait/member.go +++ b/testsupport/wait/member.go @@ -1557,6 +1557,22 @@ func (a *MemberAwaitility) WaitUntilInferenceServiceDeleted(t *testing.T, name, return err } +// WaitUntilDataVolumeDeleted waits for the DataVolume resource to be deleted (idled) +func (a *MemberAwaitility) WaitUntilDataVolumeDeleted(t *testing.T, name, namespace string, dataVolumeRes dynamic.NamespaceableResourceInterface) error { + t.Logf("waiting for DataVolume '%s' to be deleted in namespace '%s'", name, namespace) + err := wait.PollUntilContextTimeout(context.TODO(), a.RetryInterval, a.Timeout, true, func(ctx context.Context) (bool, error) { + _, err := dataVolumeRes.Namespace(namespace).Get(ctx, name, metav1.GetOptions{}) + if err != nil { + if errors.IsNotFound(err) { + return true, nil + } + return false, err + } + return false, nil + }) + return err +} + // WaitForPods waits until "n" number of pods exist in the given namespace func (a *MemberAwaitility) WaitForPods(t *testing.T, namespace string, n int, criteria ...PodWaitCriterion) ([]corev1.Pod, error) { t.Logf("waiting for Pods in namespace '%s' with matching criteria", namespace) From b1e4e1cae76a08ed19bccba28bf75b5927a67c6c Mon Sep 17 00:00:00 2001 From: Matous Jobanek Date: Mon, 22 Dec 2025 16:10:08 +0100 Subject: [PATCH 2/3] local tests cleanup --- test/e2e/parallel/user_workloads_test.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/e2e/parallel/user_workloads_test.go b/test/e2e/parallel/user_workloads_test.go index 8abe5354f..98248a56a 100644 --- a/test/e2e/parallel/user_workloads_test.go +++ b/test/e2e/parallel/user_workloads_test.go @@ -2,7 +2,6 @@ package parallel import ( "context" - "os" "testing" "time" @@ -28,13 +27,6 @@ import ( func TestIdlerAndPriorityClass(t *testing.T) { t.Parallel() - os.Setenv("KUBECONFIG", "/home/mjobanek/.kube/config") - os.Setenv("MEMBER_NS", "toolchain-member-22141926") - os.Setenv("MEMBER_NS_2", "toolchain-member2-22141926") - os.Setenv("SECOND_MEMBER_MODE", "true") - os.Setenv("HOST_NS", "toolchain-host-22141926") - os.Setenv("REGISTRATION_SERVICE_NS", "toolchain-host-22141926") - await := WaitForDeployments(t) hostAwait := await.Host() memberAwait := await.Member1() From 2e80a3748cc3997d4b86962646361e10efe2af6b Mon Sep 17 00:00:00 2001 From: Matous Jobanek Date: Fri, 9 Jan 2026 12:08:31 +0100 Subject: [PATCH 3/3] update README --- deploy/crds/README.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/deploy/crds/README.adoc b/deploy/crds/README.adoc index 489b9d447..0425ed29f 100644 --- a/deploy/crds/README.adoc +++ b/deploy/crds/README.adoc @@ -3,8 +3,11 @@ == appstudio CRDs Copy/paste relevant definitions from https://raw.githubusercontent.com/redhat-appstudio/application-api/main/manifests/application-api-customresourcedefinitions.yaml -== virtualmachines CRD +== virtualmachines & datavolumes CRD Copy from a cluster with CNV operator installed == ansibleautomationplatforms CRD -Copy from a cluster with Ansible Automation Platform operator installed \ No newline at end of file +Copy from a cluster with Ansible Automation Platform operator installed + +== serving CRDs +Copy from a cluster with Serverless operator installed \ No newline at end of file