allow individual backup storage locations to be read-only (#1517)

* allow individual backup storage locations to be read-only

Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
Steve Kriss
2019-05-29 14:21:25 -04:00
committed by Nolan Brubaker
parent 4e2e4cd5c4
commit 411d44a673
16 changed files with 336 additions and 88 deletions
+35 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright 2017 the Velero contributors.
Copyright 2017, 2019 the Velero contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -146,6 +146,12 @@ func TestProcessBackupValidationFailures(t *testing.T) {
backup: velerotest.NewTestBackup().WithName("backup-1").WithStorageLocation("nonexistent").Backup,
expectedErrs: []string{"a BackupStorageLocation CRD with the name specified in the backup spec needs to be created before this backup can be executed. Error: backupstoragelocation.velero.io \"nonexistent\" not found"},
},
{
name: "backup for read-only backup location fails validation",
backup: velerotest.NewTestBackup().WithName("backup-1").WithStorageLocation("read-only").Backup,
backupLocation: velerotest.NewTestBackupStorageLocation().WithName("read-only").WithAccessMode(velerov1api.BackupStorageLocationAccessModeReadOnly).BackupStorageLocation,
expectedErrs: []string{"backup can't be created because backup storage location read-only is currently in read-only mode"},
},
}
for _, test := range tests {
@@ -358,6 +364,34 @@ func TestProcessBackupCompletions(t *testing.T) {
},
},
},
{
name: "backup for a location with ReadWrite access mode gets processed",
backup: velerotest.NewTestBackup().WithName("backup-1").WithStorageLocation("read-write").Backup,
backupLocation: velerotest.NewTestBackupStorageLocation().
WithName("read-write").
WithObjectStorage("store-1").
WithAccessMode(v1.BackupStorageLocationAccessModeReadWrite).
BackupStorageLocation,
expectedResult: &v1.Backup{
ObjectMeta: metav1.ObjectMeta{
Namespace: v1.DefaultNamespace,
Name: "backup-1",
Labels: map[string]string{
"velero.io/storage-location": "read-write",
},
},
Spec: v1.BackupSpec{
StorageLocation: "read-write",
},
Status: v1.BackupStatus{
Phase: v1.BackupPhaseCompleted,
Version: 1,
StartTimestamp: metav1.NewTime(now),
CompletionTimestamp: metav1.NewTime(now),
Expiration: metav1.NewTime(now),
},
},
},
{
name: "backup with a TTL has expiration set",
backup: velerotest.NewTestBackup().WithName("backup-1").WithTTL(10 * time.Minute).Backup,