mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 12:43:32 +09:00
Immediate binding for every source fixed a real bug: a standalone disk on a WaitForFirstConsumer class has no consumer to wait for, so it never populated. It also took away the path that is correct for the other case. For a disk a VMInstance consumes, KubeVirt renders a temporary launcher pod carrying the VM's own affinity and nodeSelector, so the volume binds where the VM can actually run; with the annotation always present the CDI worker becomes the first consumer instead and the volume lands where that pod happened to be scheduled. On a node-pinned class the VM is then unschedulable against a node-affinity conflict, and storageClass is immutable, so the only exit is deleting the disk. The two cases want opposite defaults and only the operator knows which one a given disk is. bindImmediately defaults to true, so nothing moves for existing disks or for anyone on `replicated`, which binds Immediate either way. Both branches are pinned in tests, including the existing-DataVolume path, which renders its own annotation block. Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com> Assisted-By: LLM
66 lines
2.6 KiB
YAML
66 lines
2.6 KiB
YAML
suite: vm-disk DataVolume binding
|
|
templates:
|
|
- templates/dv.yaml
|
|
tests:
|
|
- it: requests immediate binding for a standalone disk
|
|
set:
|
|
source:
|
|
http:
|
|
url: https://example.com/disk.img
|
|
asserts:
|
|
- equal:
|
|
path: metadata.annotations["cdi.kubevirt.io/storage.bind.immediate.requested"]
|
|
value: "true"
|
|
|
|
# Both branches are pinned, because the two cases the switch exists for want
|
|
# opposite defaults: a standalone disk needs the bind now or it never
|
|
# populates, and a disk a VMInstance will consume binds correctly only when
|
|
# KubeVirt's launcher pod is the first consumer. Asserted by key absence and
|
|
# not by a negated match, which passes for free once the path stops resolving.
|
|
- it: omits the annotation when the operator defers binding to the consumer
|
|
set:
|
|
bindImmediately: false
|
|
source:
|
|
http:
|
|
url: https://example.com/disk.img
|
|
asserts:
|
|
- notExists:
|
|
path: metadata.annotations["cdi.kubevirt.io/storage.bind.immediate.requested"]
|
|
- exists:
|
|
path: metadata.annotations["vm-disk.cozystack.io/source"]
|
|
|
|
# The existing-DataVolume path renders its own annotation block, so the switch
|
|
# has to reach it too rather than only the creation path.
|
|
- it: defers binding on an existing DataVolume as well
|
|
set:
|
|
bindImmediately: false
|
|
storageClass: replicated
|
|
source: {http: {url: https://example.com/original.qcow2}}
|
|
kubernetesProvider:
|
|
scheme:
|
|
"cdi.kubevirt.io/v1beta1/DataVolume":
|
|
gvr: {group: cdi.kubevirt.io, version: v1beta1, resource: datavolumes}
|
|
namespaced: true
|
|
objects:
|
|
- kind: DataVolume
|
|
apiVersion: cdi.kubevirt.io/v1beta1
|
|
metadata:
|
|
name: RELEASE-NAME
|
|
namespace: NAMESPACE
|
|
annotations:
|
|
vm-disk.cozystack.io/source: '{"http":{"url":"https://example.com/original.qcow2"}}'
|
|
vm-disk.cozystack.io/storage-class: replicated
|
|
spec:
|
|
source: {http: {url: https://example.com/original.qcow2}}
|
|
storage: {resources: {requests: {storage: 9Gi}}, storageClassName: replicated}
|
|
asserts:
|
|
- notFailedTemplate: {}
|
|
# 9Gi comes from the mocked object and 5Gi from values, so this proves the
|
|
# render took the existing-DataVolume path rather than passing as a fresh
|
|
# create that happens to omit the same annotation.
|
|
- equal:
|
|
path: spec.storage.resources.requests.storage
|
|
value: 9Gi
|
|
- notExists:
|
|
path: metadata.annotations["cdi.kubevirt.io/storage.bind.immediate.requested"]
|