csi-wrapper: add support for creating peerpod volumes with manually created persistent volumes #2106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The peerpod volume custom resource is currently only created during the
CreateVolume
rpc of the controller service.This endpoint is called by Kubernetes during the creation of a persistent volume claim (PVC) without an already existing persistent volume (PV).
All subsequent controller, node, and podvm csi-wrapper endpoints that interact with peerpod volumes CRs (e.g.
ControllerPublishVolume
) now assume that a peerpod volume already exists.However, this is not the case if a PVC with a manually created, or already existing, PV is created.
This is required when statically provisioning a volume, for example, by the azuredisk-csi-driver to consume a pre-existing disk through a PVC.
When a PV already exists, the
CreateVolume
endpoint is never called, and we directly go toControllerPublishVolume
instead.This PR aims to fix this problem by performing an check during
ControllerPublishVolume
if there is no matching peerpod volume found.Since the information we get during
ControllerPublishVolume
is a lot more limited than what we get duringCreateVolume
, a little workaround is needed.Mainly, we don't have access to the
Parameters
field of the PVC, which we use duringCreateVolume
to discern if a peerpod volume should be created, by checking if it contains the keypeerpod
.So instead, we rely on the user to set the
peerpod
key in theVolumeContext
field of the manually created PV.A second issue is that we don't have access to the
VolumeName
of the PVC duringControllerPublishVolume
.This value is checked for comparison during
NodePublishVolume
to ensure the peerpod volume matches the "real" volume to publish.We side steps this issue by setting a placeholder name during
ControllerPublishVolume
, and if this placeholder is set duringNodePublishVolume
, replace it with the real value.