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

Integration of Data volume using CDI populators #2722

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change update of annotation from denied list to allowed list
Instead if checking if the annotation on pvcPrime is not desired
go over desired list and if the annotation exists add it.

Signed-off-by: Shelly Kagan <skagan@redhat.com>
  • Loading branch information
ShellyKa13 committed Jun 12, 2023
commit 6690f5e980ad63374ba72f8208aa61dc02d061f5
9 changes: 0 additions & 9 deletions pkg/controller/populators/import-populator.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,6 @@ func (r *ImportPopulatorReconciler) updatePVCForPopulation(pvc *corev1.Persisten
annotations[cc.AnnSource] = cc.SourceNone
}

func deleteBoundConditionIfNeeded(pvc, pvcPrime *corev1.PersistentVolumeClaim) {
if _, ok := pvcPrime.Annotations[cc.AnnBoundCondition]; !ok {
delete(pvc.Annotations, cc.AnnBoundCondition)
delete(pvc.Annotations, cc.AnnBoundConditionMessage)
delete(pvc.Annotations, cc.AnnBoundConditionReason)
}
}

func updateVddkAnnotations(pvc, pvcPrime *corev1.PersistentVolumeClaim) {
if cc.GetSource(pvcPrime) != cc.SourceVDDK {
return
Expand All @@ -213,7 +205,6 @@ func (r *ImportPopulatorReconciler) updateImportAnnotations(pvc, pvcPrime *corev
r.log.Error(err, "Failed to update import progress for pvc %s/%s", pvc.Namespace, pvc.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why just log the error?

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 dont want to prevent the phase update in case there is some issue with the progress pod

}
updateVddkAnnotations(pvc, pvcPrime)
deleteBoundConditionIfNeeded(pvc, pvcPrime)
}

// Progress reporting
Expand Down
17 changes: 9 additions & 8 deletions pkg/controller/populators/populator-base.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package populators
import (
"context"
"reflect"
"strings"

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -216,15 +215,17 @@ func (r *ReconcilerBase) createPVCPrime(pvc *corev1.PersistentVolumeClaim, sourc

type updatePVCAnnotationsFunc func(pvc, pvcPrime *corev1.PersistentVolumeClaim)

var desiredAnnotations = []string{cc.AnnPodPhase, cc.AnnPodReady, cc.AnnPodRestarts, cc.AnnPreallocationRequested, cc.AnnPreallocationApplied, cc.AnnRunningCondition, cc.AnnRunningConditionMessage, cc.AnnRunningConditionReason, cc.AnnBoundCondition, cc.AnnBoundConditionMessage, cc.AnnBoundConditionReason}
Copy link
Member

Choose a reason for hiding this comment

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

If I understand this correctly, the dv will have bound condition true if pvc' is bound. That does not seem right to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the update boundcondition on the dv doesnt update the condition to true unless the pvc is bound:
https://github.com/kubevirt/containerized-data-importer/blob/main/pkg/controller/datavolume/conditions.go#L128-L143
so seems to me its ok.

Copy link
Member

Choose a reason for hiding this comment

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

Why bother passing over the annotations then?

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 remember there was some tests checking this. I can remove this update and see how it affects our tests if it bothers you.


func (r *ReconcilerBase) updatePVCWithPVCPrimeAnnotations(pvc, pvcPrime *corev1.PersistentVolumeClaim, updateFunc updatePVCAnnotationsFunc) error {
pvcCopy := pvc.DeepCopy()
for k, v := range pvcPrime.GetAnnotations() {
if strings.Contains(k, common.CDIAnnKey) &&
!strings.Contains(k, cc.AnnImmediateBinding) &&
!strings.Contains(k, cc.AnnPopulatorKind) &&
!strings.Contains(k, "upload") &&
!strings.Contains(k, "import") {
cc.AddAnnotation(pvcCopy, k, v)
for _, ann := range desiredAnnotations {
if value, ok := pvcPrime.GetAnnotations()[ann]; ok {
cc.AddAnnotation(pvcCopy, ann, value)
} else if _, ok := pvcCopy.GetAnnotations()[ann]; ok {
// if the desired Annotation was deleted from pvcPrime
// delete it also in the target pvc
delete(pvcCopy.Annotations, ann)
}
}
if updateFunc != nil {
Expand Down