remove code that removes legacy GC finalizer from backups
Signed-off-by: Steve Kriss <krisss@vmware.com>pull/1323/head
parent
892673816b
commit
7f36f78aee
|
@ -18,7 +18,6 @@ package server
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -36,8 +35,6 @@ import (
|
|||
"github.com/spf13/pflag"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
kubeerrs "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
|
@ -65,9 +62,7 @@ import (
|
|||
"github.com/heptio/velero/pkg/podexec"
|
||||
"github.com/heptio/velero/pkg/restic"
|
||||
"github.com/heptio/velero/pkg/restore"
|
||||
"github.com/heptio/velero/pkg/util/kube"
|
||||
"github.com/heptio/velero/pkg/util/logging"
|
||||
"github.com/heptio/velero/pkg/util/stringslice"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -793,10 +788,6 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string
|
|||
// SHARED INFORMERS HAVE TO BE STARTED AFTER ALL CONTROLLERS
|
||||
go s.sharedInformerFactory.Start(ctx.Done())
|
||||
|
||||
// TODO(1.0): remove
|
||||
cache.WaitForCacheSync(ctx.Done(), s.sharedInformerFactory.Velero().V1().Backups().Informer().HasSynced)
|
||||
s.removeDeprecatedGCFinalizer()
|
||||
|
||||
s.logger.Info("Server started successfully")
|
||||
|
||||
<-ctx.Done()
|
||||
|
@ -819,43 +810,3 @@ func (s *server) runProfiler() {
|
|||
s.logger.WithError(errors.WithStack(err)).Error("error running profiler http server")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(1.0): remove
|
||||
func (s *server) removeDeprecatedGCFinalizer() {
|
||||
const gcFinalizer = "gc.ark.heptio.com"
|
||||
|
||||
backups, err := s.sharedInformerFactory.Velero().V1().Backups().Lister().List(labels.Everything())
|
||||
if err != nil {
|
||||
s.logger.WithError(errors.WithStack(err)).Error("error listing backups from cache - unable to remove old finalizers")
|
||||
return
|
||||
}
|
||||
|
||||
for _, backup := range backups {
|
||||
log := s.logger.WithField("backup", kube.NamespaceAndName(backup))
|
||||
|
||||
if !stringslice.Has(backup.Finalizers, gcFinalizer) {
|
||||
log.Debug("backup doesn't have deprecated finalizer - skipping")
|
||||
continue
|
||||
}
|
||||
|
||||
log.Info("removing deprecated finalizer from backup")
|
||||
|
||||
patch := map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
"finalizers": stringslice.Except(backup.Finalizers, gcFinalizer),
|
||||
"resourceVersion": backup.ResourceVersion,
|
||||
},
|
||||
}
|
||||
|
||||
patchBytes, err := json.Marshal(patch)
|
||||
if err != nil {
|
||||
log.WithError(errors.WithStack(err)).Error("error marshaling finalizers patch")
|
||||
continue
|
||||
}
|
||||
|
||||
_, err = s.veleroClient.VeleroV1().Backups(backup.Namespace).Patch(backup.Name, types.MergePatchType, patchBytes)
|
||||
if err != nil {
|
||||
log.WithError(errors.WithStack(err)).Error("error marshaling finalizers patch")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import (
|
|||
listers "github.com/heptio/velero/pkg/generated/listers/velero/v1"
|
||||
"github.com/heptio/velero/pkg/persistence"
|
||||
"github.com/heptio/velero/pkg/plugin/clientmgmt"
|
||||
"github.com/heptio/velero/pkg/util/stringslice"
|
||||
)
|
||||
|
||||
type backupSyncController struct {
|
||||
|
@ -92,9 +91,6 @@ func NewBackupSyncController(
|
|||
return c
|
||||
}
|
||||
|
||||
// TODO(1.0): remove this
|
||||
const gcFinalizer = "gc.ark.heptio.com"
|
||||
|
||||
func shouldSync(location *velerov1api.BackupStorageLocation, now time.Time, backupStore persistence.BackupStore, log logrus.FieldLogger) (bool, string) {
|
||||
log = log.WithFields(map[string]interface{}{
|
||||
"lastSyncedRevision": location.Status.LastSyncedRevision,
|
||||
|
@ -212,9 +208,6 @@ func (c *backupSyncController) run() {
|
|||
continue
|
||||
}
|
||||
|
||||
// remove the pre-v0.8.0 gcFinalizer if it exists
|
||||
// TODO(1.0): remove this
|
||||
backup.Finalizers = stringslice.Except(backup.Finalizers, gcFinalizer)
|
||||
backup.Namespace = c.namespace
|
||||
backup.ResourceVersion = ""
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ import (
|
|||
persistencemocks "github.com/heptio/velero/pkg/persistence/mocks"
|
||||
"github.com/heptio/velero/pkg/plugin/clientmgmt"
|
||||
pluginmocks "github.com/heptio/velero/pkg/plugin/mocks"
|
||||
"github.com/heptio/velero/pkg/util/stringslice"
|
||||
velerotest "github.com/heptio/velero/pkg/util/test"
|
||||
)
|
||||
|
||||
|
@ -99,16 +98,6 @@ func TestBackupSyncControllerRun(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "gcFinalizer (only) gets removed on sync",
|
||||
namespace: "ns-1",
|
||||
locations: defaultLocationsList("ns-1"),
|
||||
cloudBackups: map[string][]*velerov1api.Backup{
|
||||
"bucket-1": {
|
||||
velerotest.NewTestBackup().WithNamespace("ns-1").WithFinalizers("a-finalizer", gcFinalizer, "some-other-finalizer").Backup,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all synced backups get created in Velero server's namespace",
|
||||
namespace: "velero",
|
||||
|
@ -268,9 +257,6 @@ func TestBackupSyncControllerRun(t *testing.T) {
|
|||
|
||||
assert.Equal(t, expected, obj)
|
||||
} else {
|
||||
// verify that the GC finalizer is removed
|
||||
assert.Equal(t, stringslice.Except(cloudBackup.Finalizers, gcFinalizer), obj.Finalizers)
|
||||
|
||||
// verify that the storage location field and label are set properly
|
||||
assert.Equal(t, location.Name, obj.Spec.StorageLocation)
|
||||
assert.Equal(t, location.Name, obj.Labels[velerov1api.StorageLocationLabel])
|
||||
|
|
Loading…
Reference in New Issue