Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

velero: adjust delete() returns #758

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/velero/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,12 @@ func (builder *BackupBuilder) Delete() (*BackupBuilder, error) {
builder.Definition.Name, builder.Definition.Namespace)

if !builder.Exists() {
return builder, fmt.Errorf("backup cannot be deleted because it does not exist")
glog.V(100).Infof("Backup %s in namespace %s cannot be deleted because it does not exist",
builder.Definition.Name, builder.Definition.Namespace)

builder.Object = nil

return builder, nil
}

err := builder.apiClient.Delete(context.TODO(), builder.Definition)
Expand Down
7 changes: 6 additions & 1 deletion pkg/velero/backupstoragelocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,12 @@ func (builder *BackupStorageLocationBuilder) Delete() error {
builder.Definition.Name, builder.Definition.Namespace)

if !builder.Exists() {
return fmt.Errorf("backupstoragelocation cannot be deleted because it does not exist")
glog.V(100).Infof("BackupStorageLocation %s in namespace %s cannot be deleted"+
" because it does not exist", builder.Definition.Name, builder.Definition.Namespace)

builder.Object = nil

return nil
}

err := builder.apiClient.Delete(context.TODO(), builder.Definition)
Expand Down
3 changes: 1 addition & 2 deletions pkg/velero/backupstoragelocation_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package velero

import (
"errors"
"fmt"
"testing"
"time"
Expand Down Expand Up @@ -452,7 +451,7 @@ func TestBackupStorageLocationDelete(t *testing.T) {
},
{
exists: false,
expectedError: errors.New("backupstoragelocation cannot be deleted because it does not exist"),
expectedError: nil,
},
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/velero/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,13 @@ func (builder *RestoreBuilder) Delete() (*RestoreBuilder, error) {
builder.Definition.Name, builder.Definition.Namespace)

if !builder.Exists() {
return builder, fmt.Errorf("restore cannot be deleted because it does not exist")
glog.V(100).Infof("Restore %s in namespace %s cannot be deleted"+
" because it does not exist",
builder.Definition.Name, builder.Definition.Namespace)

builder.Object = nil

return builder, nil
}

err := builder.apiClient.Delete(context.TODO(), builder.Definition)
Expand Down
Loading