From b4be7eccb9031793ae152013b7c265f19f80e6fe Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Tue, 3 Mar 2020 15:57:15 -0500 Subject: [PATCH] Document locations for CSI support Signed-off-by: Nolan Brubaker --- pkg/controller/backup_controller.go | 8 ++++++++ pkg/persistence/object_store.go | 3 ++- pkg/persistence/object_store_layout.go | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/controller/backup_controller.go b/pkg/controller/backup_controller.go index ef7a91dc3..d1b5a46e0 100644 --- a/pkg/controller/backup_controller.go +++ b/pkg/controller/backup_controller.go @@ -40,6 +40,7 @@ import ( velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" pkgbackup "github.com/vmware-tanzu/velero/pkg/backup" "github.com/vmware-tanzu/velero/pkg/discovery" + "github.com/vmware-tanzu/velero/pkg/features" velerov1client "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1" velerov1informers "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions/velero/v1" velerov1listers "github.com/vmware-tanzu/velero/pkg/generated/listers/velero/v1" @@ -74,6 +75,8 @@ type backupController struct { formatFlag logging.Format } +// TODO (nrb): Add clients for the VS/VSContent here. +// How about creating them in the server iff EnableCSI, and if they're nil in the backup controller, don't worry about it? func NewBackupController( backupInformer velerov1informers.BackupInformer, client velerov1client.BackupsGetter, @@ -599,6 +602,11 @@ func recordBackupMetrics(log logrus.FieldLogger, backup *velerov1api.Backup, bac } func persistBackup(backup *pkgbackup.Request, backupContents, backupLog *os.File, backupStore persistence.BackupStore, log logrus.FieldLogger) []error { + if features.IsEnabled("EnableCSI") { + // Get the list of VolumeSnapshots & VolumeSnapshotContents associated with the backup and serialize them as JSON + // Probably shouldn't fetch them here as there's no client, but they should be passed in somehow. + } + errs := []error{} backupJSON := new(bytes.Buffer) diff --git a/pkg/persistence/object_store.go b/pkg/persistence/object_store.go index 8ddf066a6..562393e78 100644 --- a/pkg/persistence/object_store.go +++ b/pkg/persistence/object_store.go @@ -42,6 +42,7 @@ type BackupInfo struct { PodVolumeBackups, VolumeSnapshots, BackupResourceList io.Reader + // Add io.Readers here for VS and VSContents lists? } // BackupStore defines operations for creating, retrieving, and deleting @@ -51,7 +52,7 @@ type BackupStore interface { ListBackups() ([]string, error) - PutBackup(info BackupInfo) error + PutBackup(info BackupInfo) error // Extend this method for a VS/VSContent parameter, or create a new one for the beta period? GetBackupMetadata(name string) (*velerov1api.Backup, error) GetBackupVolumeSnapshots(name string) ([]*volume.Snapshot, error) GetPodVolumeBackups(name string) ([]*velerov1api.PodVolumeBackup, error) diff --git a/pkg/persistence/object_store_layout.go b/pkg/persistence/object_store_layout.go index ebf75af19..d1423fb0e 100644 --- a/pkg/persistence/object_store_layout.go +++ b/pkg/persistence/object_store_layout.go @@ -99,3 +99,5 @@ func (l *ObjectStoreLayout) getRestoreLogKey(restore string) string { func (l *ObjectStoreLayout) getRestoreResultsKey(restore string) string { return path.Join(l.subdirs["restores"], restore, fmt.Sprintf("restore-%s-results.gz", restore)) } + +// TODO: Add keys for VS & VSContents json.gz files