Skip to content

Commit

Permalink
VRG: Handle Kube objects recovery point pointer update errors
Browse files Browse the repository at this point in the history
Signed-off-by: hatfieldbrian <bhatfiel@redhat.com>
  • Loading branch information
hatfieldbrian authored and raghavendra-talur committed Oct 24, 2023
1 parent 5776a50 commit 0e03b37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
4 changes: 0 additions & 4 deletions controllers/vrg_volrep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1443,10 +1443,6 @@ func (v *vrgTest) kubeObjectProtectionValidate() *ramendrv1alpha1.VolumeReplicat
}

func kubeObjectProtectionValidate(tests []*vrgTest) {
if true {
return // TODO re-enable
}

protectedVrgList := protectedVrgListCreateAndStatusWait("protectedvrglist-vrg-"+tests[0].uniqueID, vrgS3ProfileNumber)
vrgs := make([]ramendrv1alpha1.VolumeReplicationGroup, len(tests))

Expand Down
23 changes: 6 additions & 17 deletions controllers/vrg_vrgobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@
package controllers

import (
"time"

ramen "github.com/ramendr/ramen/api/v1alpha1"
"github.com/ramendr/ramen/controllers/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
)

var vrgLastUploadTime = map[string]metav1.Time{}
var vrgLastUploadVersion = map[string]string{}

func (v *VRGInstance) vrgObjectProtect(result *ctrl.Result, s3StoreAccessors []s3StoreAccessor) {
vrg := v.instance
log := v.log

if lastUploadTime, ok := vrgLastUploadTime[v.namespacedName]; ok {
const maxVRGProtectionInterval = time.Minute

// Throttle VRG protection if this call is more recent than maxVRGProtectionInterval.
if shouldThrottleVRGProtection(lastUploadTime, maxVRGProtectionInterval) {
log.Info("VRG already protected recently. Throttling...")
if lastUploadVersion, ok := vrgLastUploadVersion[v.namespacedName]; ok {
if vrg.ResourceVersion == lastUploadVersion {
log.Info("VRG resource version unchanged, skip S3 upload", "version", vrg.ResourceVersion)

return
}
Expand Down Expand Up @@ -61,19 +56,13 @@ func (v *VRGInstance) vrgObjectProtectThrottled(result *ctrl.Result, s3StoreAcce

log1.Info("VRG Kube object protected")

vrgLastUploadTime[v.namespacedName] = metav1.Now()

vrgLastUploadVersion[v.namespacedName] = vrg.ResourceVersion
v.vrgObjectProtected = newVRGClusterDataProtectedCondition(vrg.Generation, clusterDataProtectedTrueMessage)
}

success()
}

func shouldThrottleVRGProtection(lastUploadTime metav1.Time, maxVRGProtectionTime time.Duration) bool {
// Throttle VRG protection if this call is more recent than MaxVRGProtectionTime.
return time.Now().Before(lastUploadTime.Add(maxVRGProtectionTime))
}

const vrgS3ObjectNameSuffix = "a"

func VrgObjectProtect(objectStorer ObjectStorer, vrg ramen.VolumeReplicationGroup) error {
Expand Down

0 comments on commit 0e03b37

Please sign in to comment.