diff --git a/pkg/applicationmanager/controllers/applicationbackup.go b/pkg/applicationmanager/controllers/applicationbackup.go index 6ed1671a77..bc377e409e 100644 --- a/pkg/applicationmanager/controllers/applicationbackup.go +++ b/pkg/applicationmanager/controllers/applicationbackup.go @@ -21,6 +21,7 @@ import ( "github.com/libopenstorage/stork/pkg/objectstore" "github.com/libopenstorage/stork/pkg/resourcecollector" "github.com/libopenstorage/stork/pkg/rule" + "github.com/libopenstorage/stork/pkg/version" "github.com/portworx/sched-ops/k8s/apiextensions" "github.com/portworx/sched-ops/k8s/core" storkops "github.com/portworx/sched-ops/k8s/stork" @@ -57,6 +58,7 @@ const ( backupVolumeBatchCount = 10 maxRetry = 10 retrySleep = 10 * time.Second + storkVersion = annotationPrefix + "storkVersion" ) var ( @@ -206,6 +208,15 @@ func (a *ApplicationBackupController) createBackupLocationPath(backup *stork_api // handle updates for ApplicationBackup objects func (a *ApplicationBackupController) handle(ctx context.Context, backup *stork_api.ApplicationBackup) error { + // update the stork verison only for the in-progress backup CR. + if backup.Status.Status == stork_api.ApplicationBackupStatusInProgress || + backup.Status.Status == stork_api.ApplicationBackupStatusInitial || + backup.Status.Status == stork_api.ApplicationBackupStatusPending { + if _, ok := backup.Annotations[storkVersion]; !ok { + backup.Annotations[storkVersion] = version.Version + } + } + if backup.DeletionTimestamp != nil { if controllers.ContainsFinalizer(backup, controllers.FinalizerCleanup) { if err := a.deleteBackup(backup); err != nil { diff --git a/pkg/applicationmanager/controllers/applicationbackupschedule.go b/pkg/applicationmanager/controllers/applicationbackupschedule.go index e05852b04f..78d51aaf3e 100644 --- a/pkg/applicationmanager/controllers/applicationbackupschedule.go +++ b/pkg/applicationmanager/controllers/applicationbackupschedule.go @@ -11,6 +11,7 @@ import ( "github.com/libopenstorage/stork/pkg/controllers" "github.com/libopenstorage/stork/pkg/log" "github.com/libopenstorage/stork/pkg/schedule" + "github.com/libopenstorage/stork/pkg/version" "github.com/portworx/sched-ops/k8s/apiextensions" storkops "github.com/portworx/sched-ops/k8s/stork" "github.com/sirupsen/logrus" @@ -89,6 +90,10 @@ func (s *ApplicationBackupScheduleController) Reconcile(request reconcile.Reques // Handle updates for ApplicationBackupSchedule objects func (s *ApplicationBackupScheduleController) handle(ctx context.Context, backupSchedule *stork_api.ApplicationBackupSchedule) error { + if _, ok := backupSchedule.Annotations[storkVersion]; !ok { + backupSchedule.Annotations[storkVersion] = version.Version + } + if backupSchedule.DeletionTimestamp != nil { return nil } diff --git a/pkg/applicationmanager/controllers/applicationrestore.go b/pkg/applicationmanager/controllers/applicationrestore.go index 2c206d80e8..71c517568e 100644 --- a/pkg/applicationmanager/controllers/applicationrestore.go +++ b/pkg/applicationmanager/controllers/applicationrestore.go @@ -16,6 +16,7 @@ import ( "github.com/libopenstorage/stork/pkg/log" "github.com/libopenstorage/stork/pkg/objectstore" "github.com/libopenstorage/stork/pkg/resourcecollector" + "github.com/libopenstorage/stork/pkg/version" "github.com/portworx/sched-ops/k8s/apiextensions" "github.com/portworx/sched-ops/k8s/core" storkops "github.com/portworx/sched-ops/k8s/stork" @@ -218,6 +219,16 @@ func (a *ApplicationRestoreController) Reconcile(request reconcile.Request) (rec // Handle updates for ApplicationRestore objects func (a *ApplicationRestoreController) handle(ctx context.Context, restore *storkapi.ApplicationRestore) error { + + // update the stork verison only for the in-progress restore CR. + if restore.Status.Status == storkapi.ApplicationRestoreStatusInProgress || + restore.Status.Status == storkapi.ApplicationRestoreStatusInitial || + restore.Status.Status == storkapi.ApplicationRestoreStatusPending { + if _, ok := restore.Annotations[storkVersion]; !ok { + restore.Annotations[storkVersion] = version.Version + } + } + if restore.DeletionTimestamp != nil { if controllers.ContainsFinalizer(restore, controllers.FinalizerCleanup) { if err := a.cleanupRestore(restore); err != nil {