Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csi-wrapper: add support for creating peerpod volumes with manually created persistent volumes #2106

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

daniel-weisse
Copy link
Contributor

@daniel-weisse daniel-weisse commented Oct 11, 2024

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 to ControllerPublishVolume 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 during CreateVolume, a little workaround is needed.
Mainly, we don't have access to the Parameters field of the PVC, which we use during CreateVolume to discern if a peerpod volume should be created, by checking if it contains the key peerpod.
So instead, we rely on the user to set the peerpod key in the VolumeContext field of the manually created PV.

A second issue is that we don't have access to the VolumeName of the PVC during ControllerPublishVolume.
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 during NodePublishVolume, replace it with the real value.

@daniel-weisse daniel-weisse requested a review from a team as a code owner October 11, 2024 06:46
@stevenhorsman
Copy link
Member

@yoheiueda - are you able to review this when you get a chance as I think you worked on the csi-wrapper feature?

Copy link
Member

@yoheiueda yoheiueda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this great contribution! I am glad to hear that peer pods will support Azure CSI with this PR.

Overall LGTM. I only have a few questions for my better understanding.

src/csi-wrapper/pkg/wrapper/nodeservice.go Show resolved Hide resolved
src/csi-wrapper/pkg/wrapper/nodeservice.go Show resolved Hide resolved
Copy link
Member

@yoheiueda yoheiueda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daniel-weisse daniel-weisse force-pushed the existing-pv branch 2 times, most recently from 3876e8a to 3a832cd Compare October 17, 2024 07:42
To support usage of manually created persistent volumes,
a peerpod volume CR needs to be created during `ControllerPublishVolume`,

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
@katexochen katexochen merged commit b5542aa into confidential-containers:main Oct 18, 2024
19 checks passed
@daniel-weisse daniel-weisse deleted the existing-pv branch October 18, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants