All,
The CSI spec requires `CreateVolume` requests on a `ControllerService`
to be idempotent [1]:
> This operation MUST be idempotent. If a volume corresponding to the
> specified volume name already exists, is accessible from
> accessibility_requirements, and is compatible with the specified
> capacity_range, volume_capabilities and parameters in the
> CreateVolumeRequest, the Plugin MUST reply 0 OK with the
> corresponding CreateVolumeResponse.
The part about 'compatible capacity_range' is interesting in the case
where a driver uses capacity '0' for created volumes, which is valid:
> The capacity of the volume in bytes. This field is OPTIONAL. If not
> set (value of 0), it indicates that the capacity of the volume is
> unknown (e.g., NFS share).
> The value of this field MUST NOT be negative.
As such, if a volume is created with capacity request N, and the driver
returns a capacity of 0 in the `CreateVolume` response, then later on a
`CreateVolume` request comes in with the same `name`, compatible
`volume_capabilities` and compatible `parameters` but a different
capacity request (either lower or higher than N), is the driver allowed
to ignore this requested capacity (any 'new' volume would have capacity
0 anyway) and treat the operation as a no-op?
There's a bug report[2] for a test in csi-sanity [3] which asserts that
a `CreateVolume` of same name etc. but different capacity range fails
with `ALREADY_EXISTS`, which seems to be along the lines of the spec:
> Indicates that a volume corresponding to the specified volume name
> already exists but is incompatible with the specified
> capacity_range, volume_capabilities or parameters.
However, as outlined above, volumes of infinite size may need to be
handled somewhat different.
I created a PR for csi-sanity [4] to handle this corner-case, but
wanted to get community input as to whether my interpretation of the
spec is correct, and maybe this should be further clarified in the
document.
Regards,
Nicolas
[1]
https://github.com/container-storage-interface/spec/blob/87a27a2496565857ed564284eaa762587feb9453/spec.md#createvolume
[2]
https://github.com/kubernetes-csi/csi-test/issues/94
[3]
https://github.com/kubernetes-csi/csi-test/blob/99b7db913362368d25246ab05261ca14e92c6534/pkg/sanity/controller.go#L559
[4]
https://github.com/kubernetes-csi/csi-test/pull/263