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

Add support for volume populators #2482

Merged
merged 7 commits into from Jan 17, 2023

Conversation

alromeros
Copy link
Collaborator

@alromeros alromeros commented Nov 23, 2022

What this PR does / why we need it:

This Pull Request enables the use of volume populators in CDI, so datavolume-owned PVCs can be populated using custom logic.

Populators can be now specified in the DV spec using the new DataSourceRef field, so, when a DataVolume is created with a populated DataSourceRef, the datavolume-controller creates the corresponding PVC accordingly, skipping all the population-related steps and controllers.

You can check volume-populators-redesigned and volume-populators-beta for more information about external population of volumes.

Release note:

Support for external volume populators in DataVolumes

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/L labels Nov 23, 2022
@alromeros alromeros changed the title Add support for volume populators [WIP] Add support for volume populators Nov 23, 2022
@alromeros alromeros marked this pull request as ready for review December 20, 2022 18:58
@alromeros alromeros changed the title [WIP] Add support for volume populators Add support for volume populators Dec 20, 2022
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 20, 2022
Copy link
Member

@mhenriks mhenriks left a comment

Choose a reason for hiding this comment

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

Looks great! Couple higher level comments for your consideration

pkg/controller/import-controller.go Outdated Show resolved Hide resolved
// * 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.
// +optional
DataSourceRef *corev1.TypedLocalObjectReference `json:"dataSourceRef,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying this is wrong, but it feels weird to me that the datavolume spec.source will be unset when using this API. My assumption was that DataVolumeSource would have a Populator field.

Copy link
Collaborator Author

@alromeros alromeros Dec 21, 2022

Choose a reason for hiding this comment

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

I also like the idea of having a Populator field but in practice I found it to be redundant. I have another semi-finished implementation where I add the new source so changing it wouldn't really be a problem, but I found some drawbacks:

  • Since we are embedding the PVC spec into our Storage API, it makes sense to also embed the DataSourceRef field (it's already supported in the PVC API). We should then allow users to populate it, which would leave the source field useless.
  • By having a Populator source, we could allow users to specify the populator there in the same way as they'd do it on the DataSourceRef field, and then copy it to the PVC spec. However, this would require additional validation in case both the DataSourceRef and source.Populator fields are set without really providing any advantage.
  • The biggest drawback for me: We would basically allow to do the same thing in two different ways without any justification or real advantages, which in my opinion is an ugly practice. Having two ways to do the same thing would also require some slightly ugly logic in the datavolume-controller.

I still see some advantages: Having a Populator source is easier to understand for users, and in practice, they'd probably be using that field instead of DataSourceRef. Eventually, when we adopt populators as the main population method in CDI, we could just use that single Populator source for all cases, which in my opinion is prettier than DataSourceRef. Let me know what you think.

tests/external_population_test.go Outdated Show resolved Hide resolved
@alromeros alromeros force-pushed the dv-populator-support branch 2 times, most recently from de82bb7 to c5a97dd Compare December 21, 2022 14:42
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 21, 2022
@akalenyu
Copy link
Collaborator

/test pull-containerized-data-importer-fossa

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 22, 2022
BUILD.bazel Show resolved Hide resolved
@alromeros alromeros force-pushed the dv-populator-support branch 2 times, most recently from 89fc0c6 to a474c4e Compare January 13, 2023 13:12
@mhenriks
Copy link
Member

/hold

/approve cancel

let's talk about how cross-namespace datasource support [1] affects this feature.

Main problem I see is that when the DataVolume controller creates the PVC, the user context is lost and ReferenceGrants will be checked against DataVolume service account.

[1] https://kubernetes.io/blog/2023/01/02/cross-namespace-data-sources-alpha/

@kubevirt-bot kubevirt-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 13, 2023
@mhenriks
Copy link
Member

mhenriks commented Jan 16, 2023

per discussion in 01/16/2023 kubevirt-sig-storage meeting - we should explicitly forbid cross-namespace datasources until we figure out how to do authorization with user context in webhook. However, that cannot be implemented at the moment because it requires 1.26 k8s api (currently at 1.23). Updating to 1.26 may not be trivial and I don't think this PR should be gated on that though, since namespace datasource is alpha in 1.26.

/hold cancel

@alromeros alromeros requested review from akalenyu, mhenriks and arnongilboa and removed request for mhenriks and akalenyu January 16, 2023 17:23
@mhenriks
Copy link
Member

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mhenriks

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 16, 2023
@mhenriks
Copy link
Member

@arnongilboa or @akalenyu want to make a final pass?

…Source' API

This commit introduces several changes into the datavolume external-population controller to improve its behavior when using the DataSource field.

It also introduces minor fixes on the generic populator logic.

Signed-off-by: Alvaro Romero <alromero@redhat.com>
Signed-off-by: Alvaro Romero <alromero@redhat.com>
Copy link
Collaborator

@akalenyu akalenyu left a comment

Choose a reason for hiding this comment

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

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 17, 2023
@alromeros
Copy link
Collaborator Author

/test pull-containerized-data-importer-e2e-nfs

@alromeros
Copy link
Collaborator Author

/hold cancel

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 17, 2023
@kubevirt-bot kubevirt-bot merged commit 2e9a925 into kubevirt:main Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants