Merge pull request #66 from skriss/getallbackups-fix

in GetAllBackups don't error if single backup is unreadable
This commit is contained in:
Andy Goldstein
2017-09-05 13:02:56 -04:00
committed by GitHub
2 changed files with 9 additions and 3 deletions

View File

@@ -115,7 +115,8 @@ func (br *backupService) GetAllBackups(bucket string) ([]*api.Backup, error) {
for _, backupDir := range prefixes {
backup, err := br.GetBackup(bucket, backupDir)
if err != nil {
return nil, err
glog.Errorf("Error reading backup directory %s: %v", backupDir, err)
continue
}
output = append(output, backup)

View File

@@ -271,7 +271,7 @@ func TestGetAllBackups(t *testing.T) {
},
},
{
name: "decode error returns nil/error",
name: "backup that can't be decoded is ignored",
bucket: "test-bucket",
storage: map[string]map[string][]byte{
"test-bucket": map[string][]byte{
@@ -279,7 +279,12 @@ func TestGetAllBackups(t *testing.T) {
"backup-2/ark-backup.json": []byte("this is not valid backup JSON"),
},
},
expectedErr: true,
expectedRes: []*api.Backup{
&api.Backup{
TypeMeta: metav1.TypeMeta{Kind: "Backup", APIVersion: "ark.heptio.com/v1"},
ObjectMeta: metav1.ObjectMeta{Name: "backup-1"},
},
},
},
}