-
Notifications
You must be signed in to change notification settings - Fork 257
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
Annotation to check for statically provisioned PVs when creating DataVolumes #2583
Annotation to check for statically provisioned PVs when creating DataVolumes #2583
Conversation
/hold |
@@ -101,12 +101,29 @@ func NewImportController( | |||
return datavolumeController, nil | |||
} | |||
|
|||
// TODO find a better place for this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's
key, err := cache.MetaNamespaceKeyFunc(snapshot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem is that pv claimRef is not a metav1.Object
so have to sonstruct from namespace/name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put a common func in pkg/controller/common
and get rid of the following:
datasource-controller.go: getKey := func(namespace, name string) string {
datavolume/clone-controller-base.go: getKey := func(namespace, name string) string {
datavolume/pvc-clone-controller.go: getKey := func(namespace, name string) string {
} | ||
var pvNames []string | ||
for _, pv := range pvList.Items { | ||
// TODO - should we be more specific here, like do the actual matching in pv controller? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something from https://pkg.go.dev/k8s.io/component-helpers@v0.26.1/storage/volume
can help here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately that package is not as fleshed out in k8s 23 but using it anyway
dc54297
to
626abd1
Compare
/retest-required |
9f43eae
to
3288da2
Compare
|
||
pvc, err := f.K8sClient.CoreV1().PersistentVolumeClaims(dv.Namespace).Get(context.TODO(), dv.Name, metav1.GetOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(pvc.Spec.VolumeName).To(Equal(pvName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is great, just one consideration, maybe we should make sure pv.CreationTimestamp < dv.CreationTimestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a broken record about this by now, but, maybe we would sleep better if there is an md5 check at the end of this test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a bad idea
@@ -317,6 +317,30 @@ func NewDataVolumeWithHTTPImportToBlockPV(dataVolumeName string, size string, ht | |||
|
|||
// NewDataVolumeWithExternalPopulation initializes a DataVolume struct meant to be externally populated | |||
func NewDataVolumeWithExternalPopulation(dataVolumeName, size, storageClassName string, volumeMode corev1.PersistentVolumeMode, dataSource, dataSourceRef *corev1.TypedLocalObjectReference) *cdiv1.DataVolume { | |||
dataVolume := &cdiv1.DataVolume{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what happened here?
Usually, I thought we shift towards using the storage API mostly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The storage api obscures the matching a bit, just have to be consistent either way (all pvc or all storage). I took the PVC route to be explicit as possible. Basically when I originally wrote the test I was using pvc
to create the source then didn't get a match I used storage
for target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha
3288da2
to
48b79e8
Compare
@akalenyu @arnongilboa what do you think? |
/unhold |
|
||
func shouldSetPending(pvc *corev1.PersistentVolumeClaim, dv *cdiv1.DataVolume) bool { | ||
return checkStaticProvisionPending(pvc, dv) || | ||
(pvc == nil && dv.Status.Phase == cdiv1.PhaseUnset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add && dv != nil
, as checkStaticProvisionPending()
returns false if pvc == nil || dv == nil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dv will never be nil in either case and shouldSetPending
kind of assumes the dv exists
// CheckVolumeModeMismatches is a convenience method that checks volumeMode for PersistentVolume | ||
// and PersistentVolumeClaims | ||
// TODO - later versions of k8s.io/component-helpers have this function | ||
func CheckVolumeModeMismatches(pvcSpec *v1.PersistentVolumeClaimSpec, pvSpec *v1.PersistentVolumeSpec) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's strange k8s (and you) choose Mismatches
instead of being positive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to stick with k8s on this
_, ok := pvModesMap[mode] | ||
if !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more clear to write it as:
if hasMode := pvModesMap[mode]; hasMode {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh, would rather do exactly what the lib does
…lt as a parameter Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
…cto common index creation Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
84790a4
to
a1f5684
Compare
…ions) even if source does not exist or user has no permission BUT no token is added so this is really just for the static/prepopulate cases Signed-off-by: Michael Henriksen <mhenriks@redhat.com>
a1f5684
to
3788f70
Compare
|
||
cloneSourceHandler, err := newCloneSourceHandler(dataVolume, wh.cdiClient) | ||
if err != nil { | ||
if k8serrors.IsNotFound(err) && noTokenOkay { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we continue with the following code when noTokenOkay
and not just return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to add the token if possible. Still have to handle initial provisioning case where DataVolume has static pv annotation but the pv does not exist
Expect(err).ToNot(HaveOccurred()) | ||
err = utils.DeleteVerifierPod(f.K8sClient, f.Namespace.Name) | ||
Expect(err).ToNot(HaveOccurred()) | ||
sourceMD5 = md5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really not big deal but I think you can get rid of this and use the md5 const
containerized-data-importer/tests/utils/upload.go
Lines 42 to 43 in 3788f70
// UploadFileMD5 is the expected MD5 of the uploaded file | |
UploadFileMD5 = "2a7a52285c846314d1dbd79e9818270d" |
/retest-required |
By("Creating source DV") | ||
// source here shouldn't matter | ||
dvDef := importDef() | ||
controller.AddAnnotation(dvDef, controller.AnnDeleteAfterCompletion, "false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why GC needs to be disabled?
/lgtm |
/retest |
/lgtm |
/approve |
[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 |
/cherrypick release-v1.56 |
@mhenriks: new pull request created: #2605 In response to this:
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. |
What this PR does / why we need it:
This PR basically does the following if a DataVolume that has the
cdi.kubevirt.io/storage.checkStaticVolume
annotation is created:syncCommon()
cdi.kubevirt.io/storage.persistentVolumeList
that contains the names of the PVCs from step 1syncCommon()
will check that the PVC is bound to one of the PVs in thepersistentVolumeList
annotationcdi.kubevirt.io/storage.persistentVolumeList
is removed andcdi.kubevirt.io/storage.populatedFor
is added to the PVCThe motivation for this PR is KubeVirt integration with a specific "Metro DR" solution. That solution bundles:
RamenDR
volume-replication-operator
OCM
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 #
Special notes for your reviewer:
TODO
I've taken the liberty to do some minor refactoring along the way.
This has not been addressed and is bumming me out bigtime
Release note: