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

Pass DV labels to PVC #2547

Merged
merged 6 commits into from
Mar 17, 2023
Merged

Conversation

ido106
Copy link
Contributor

@ido106 ido106 commented Jan 19, 2023

Signed-off-by: Ido Aharon iaharon@redhat.com

What this PR does / why we need it:
Pass all the DataVolume labels to its created PVC. It's fixing the current behavior which passes only specific labels, aligning it with DV annotations passing to the PVC.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2533

Special notes for your reviewer:

Release note:

Pass all the DataVolume labels to its created PVC

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jan 19, 2023
@kubevirt-bot kubevirt-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 19, 2023
@kubevirt-bot
Copy link
Contributor

Hi @ido106. Thanks for your PR.

I'm waiting for a kubevirt member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@awels
Copy link
Member

awels commented Jan 19, 2023

So you essentially want to pass all labels from the DV to the PVC? Any particular reason you want that? We are already passing labels from the DV to the import/upload/clone pods for things like istio and I don't think we want to pass those to the PVC.

@akalenyu
Copy link
Collaborator

So you essentially want to pass all labels from the DV to the PVC? Any particular reason you want that? We are already passing labels from the DV to the import/upload/clone pods for things like istio and I don't think we want to pass those to the PVC.

So we actually discussed this in the sig-storage meeting and I tried to summarize it in the issue itself;
Basically, if we look at DVs as a PVC creation template, you will want to say which labels you want on your PVC, right?

I would understand the argument that you could just grab the PVC and label it after the DV creation, but that is a bit clunky..
What if you created the DV with generateName? like the issue author did?
Anyway, we were already passing down annotations and could not think why we aren't giving the same treatment to labels.

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.

Awesome! great spot!

Would it be possible to also add a one-liner to some func tests that ensures we pass the labels?
in e.g. import/upload/clone/...

@@ -761,7 +746,9 @@ func (r *ReconcilerBase) newPersistentVolumeClaim(dataVolume *cdiv1.DataVolume,
if util.ResolveVolumeMode(targetPvcSpec.VolumeMode) == corev1.PersistentVolumeFilesystem {
labels[common.KubePersistentVolumeFillingUpSuppressLabelKey] = common.KubePersistentVolumeFillingUpSuppressLabelValue
}
labels = passDataVolumeInstancetypeLabelstoPVC(dataVolume.GetLabels(), labels)
for k, v := range dataVolume.Labels {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that not all flows we have are using newPersistentVolumeClaim
One example I could find is smart clone which creates the target PVC in

target := &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: snapshot.Name,
Namespace: snapshot.Namespace,
Labels: labels,

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Alex, there is no DV in that function and the PVC is created from a VolumeSnapshot, so I don't think labels should be passed in this case. wdyt ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There should be a way to grab/pass the associated DV to this func

dataVolume, err := r.getDataVolume(snapshot)

@arnongilboa
Copy link
Collaborator

@ido106 please fill in the What this PR does / why we need it and Release note sections in the card description.

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jan 19, 2023
@mhenriks
Copy link
Member

/ok-to-test

@kubevirt-bot kubevirt-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 19, 2023
@awels
Copy link
Member

awels commented Jan 24, 2023

/retest-required

@mhenriks
Copy link
Member

mhenriks commented Feb 7, 2023

@ido106 any update on this? I believe we are waiting on a functional test?

@arnongilboa
Copy link
Collaborator

@ido106 any update on this? I believe we are waiting on a functional test?

Ido is in his exam period, so I guess he'll continue his first PR when he's back.

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.

Looking good, some things to consider, and maybe it's worth to add one liner checks in some of the functional tests?

@@ -352,7 +352,7 @@ func (r *SmartCloneReconciler) getTargetPVC(dataVolume *cdiv1.DataVolume) (*core
return pvc, nil
}

func newPvcFromSnapshot(name string, snapshot *snapshotv1.VolumeSnapshot, targetPvcSpec *corev1.PersistentVolumeClaimSpec) (*corev1.PersistentVolumeClaim, error) {
func newPvcFromSnapshot(c client.Client, name string, snapshot *snapshotv1.VolumeSnapshot, targetPvcSpec *corev1.PersistentVolumeClaimSpec) (*corev1.PersistentVolumeClaim, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you may even be able to just pass
annotations, labels map[string]string/dv *cdiv1.DataVolume to this func
(the DV should be already available to you when calling newPvcFromSnapshot)

return nil, err
}
if dv != nil {
for k, v := range dv.Labels {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like we also don't pass the annotations in this case, we probably should

@@ -365,9 +365,9 @@ func (r *ReconcilerBase) getPVC(dv *cdiv1.DataVolume) (*corev1.PersistentVolumeC
return pvc, nil
}

func (r *ReconcilerBase) getDataVolume(key types.NamespacedName) (*cdiv1.DataVolume, error) {
func getDataVolume(c client.Client, key types.NamespacedName) (*cdiv1.DataVolume, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm not sure why this one needed to be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use this function in 2 different places in the code and one of them doesn't have access to the function this way, so I changed the signature to be a regular function and requested the client as a parameter instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAIK you only use func (r *SmartCloneReconciler) getDataVolume and not this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Alex, I tried to fix what you mentioned.
Plz let me know if there is any problem and I'll fix it tomorrow.

Copy link
Collaborator

@akalenyu akalenyu Feb 22, 2023

Choose a reason for hiding this comment

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

Looks good, I just think we should test this in functional tests as well,
since we are now committing that CDI will always pass labels

@alromeros
Copy link
Collaborator

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

Copy link
Collaborator

@alromeros alromeros left a comment

Choose a reason for hiding this comment

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

Good job Ido! I think after your latest commit this looks great. I'm only commenting some minor nitpicks in case you end up committing again, no need to change them. Everything else looks good to me so I'll give a preventive lgtm, but let's see what other folks have to say.

/lgtm

@@ -369,22 +370,32 @@ func newPvcFromSnapshot(name string, snapshot *snapshotv1.VolumeSnapshot, target
common.CDILabelKey: common.CDILabelValue,
common.CDIComponentLabel: common.SmartClonerCDILabel,
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a massive nitpick but I'd drop this empty line, as done with annotations below

dv := NewImportDataVolume("test-dv")
dv.SetAnnotations(make(map[string]string))
dv.GetAnnotations()["test-ann-1"] = "test-value-1"
dv.GetAnnotations()["test-ann-2"] = "test-value-2"
dv.GetAnnotations()[AnnSource] = "invalid phase should not copy"
dv.GetAnnotations()[AnnPodNetwork] = "data-network"
dv.GetAnnotations()[AnnPodSidecarInjection] = "false"
dv.Labels = map[string]string{"test": "test-label"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick, but I'd use the same convention for Annotations and Labels (Get/Set or not).

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 22, 2023
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 22, 2023
Signed-off-by: Ido Aharon <iaharon@redhat.com>
Signed-off-by: Ido Aharon <iaharon@redhat.com>
@akalenyu
Copy link
Collaborator

akalenyu commented Mar 2, 2023

/lgtm

awesome!

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2023
@akalenyu
Copy link
Collaborator

akalenyu commented Mar 3, 2023

/hold

I think I see the problem

targetDV.Labels = map[string]string{"test-label-1": "test-label-key-1"}
targetDV.Annotations = map[string]string{"test-annotation-1": "test-annotation-key-1"}

The annotations are being overwritten so we lose AnnDeleteAfterCompletion
We should probably just append the test annotations/labels to existing ones

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2023
Signed-off-by: Ido Aharon <iaharon@redhat.com>
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 5, 2023
@akalenyu
Copy link
Collaborator

akalenyu commented Mar 5, 2023

/hold cancel

But we have an unrelated CI issue following 1.56.0 release related to v1alpha1 manifests

@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 Mar 5, 2023
@akalenyu
Copy link
Collaborator

akalenyu commented Mar 5, 2023

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 5, 2023
@akalenyu
Copy link
Collaborator

akalenyu commented Mar 6, 2023

/retest

1 similar comment
@akalenyu
Copy link
Collaborator

akalenyu commented Mar 7, 2023

/retest

@akalenyu
Copy link
Collaborator

akalenyu commented Mar 7, 2023

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

@akalenyu
Copy link
Collaborator

/cc @mhenriks

@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 Mar 17, 2023
@mhenriks
Copy link
Member

/cherrypick release-v1.56

@kubevirt-bot
Copy link
Contributor

@mhenriks: once the present PR merges, I will cherry-pick it on top of release-v1.56 in a new PR and assign it to you.

In response to this:

/cherrypick release-v1.56

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@awels
Copy link
Member

awels commented Mar 17, 2023

/override pull-containerized-data-importer-e2e-destructive

@kubevirt-bot
Copy link
Contributor

@awels: Overrode contexts on behalf of awels: pull-containerized-data-importer-e2e-destructive

In response to this:

/override pull-containerized-data-importer-e2e-destructive

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kubevirt-bot kubevirt-bot merged commit 184ee03 into kubevirt:main Mar 17, 2023
@kubevirt-bot
Copy link
Contributor

@mhenriks: new pull request created: #2646

In response to this:

/cherrypick release-v1.56

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataVolume Labels are not Copied to the PVC
7 participants