Skip to content

Commit

Permalink
Change update of annotation from denied list to allowed list
Browse files Browse the repository at this point in the history
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 1, 2023
1 parent 4ab90a6 commit 6838e8b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 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,13 @@ 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}

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)
}
}
if updateFunc != nil {
Expand Down

0 comments on commit 6838e8b

Please sign in to comment.