-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
BackupController: do as much as possible #250
Merged
skriss
merged 3 commits into
vmware-tanzu:master
from
ncdc:backup-controller-do-as-much-as-possible
Jan 3, 2018
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,36 +46,46 @@ func TestUploadBackup(t *testing.T) { | |
expectMetadataDelete bool | ||
backup io.ReadSeeker | ||
backupError error | ||
expectBackupUpload bool | ||
log io.ReadSeeker | ||
logError error | ||
expectedErr string | ||
}{ | ||
{ | ||
name: "normal case", | ||
metadata: newStringReadSeeker("foo"), | ||
backup: newStringReadSeeker("bar"), | ||
log: newStringReadSeeker("baz"), | ||
name: "normal case", | ||
metadata: newStringReadSeeker("foo"), | ||
backup: newStringReadSeeker("bar"), | ||
expectBackupUpload: true, | ||
log: newStringReadSeeker("baz"), | ||
}, | ||
{ | ||
name: "error on metadata upload does not upload data or log", | ||
name: "error on metadata upload does not upload data", | ||
metadata: newStringReadSeeker("foo"), | ||
metadataError: errors.New("md"), | ||
log: newStringReadSeeker("baz"), | ||
expectedErr: "md", | ||
}, | ||
{ | ||
name: "error on data upload deletes metadata", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see prev comment re: whether to delete metadata file in this case |
||
metadata: newStringReadSeeker("foo"), | ||
backup: newStringReadSeeker("bar"), | ||
expectBackupUpload: true, | ||
backupError: errors.New("backup"), | ||
expectMetadataDelete: true, | ||
expectedErr: "backup", | ||
}, | ||
{ | ||
name: "error on log upload is ok", | ||
metadata: newStringReadSeeker("foo"), | ||
backup: newStringReadSeeker("bar"), | ||
log: newStringReadSeeker("baz"), | ||
logError: errors.New("log"), | ||
name: "error on log upload is ok", | ||
metadata: newStringReadSeeker("foo"), | ||
backup: newStringReadSeeker("bar"), | ||
expectBackupUpload: true, | ||
log: newStringReadSeeker("baz"), | ||
logError: errors.New("log"), | ||
}, | ||
{ | ||
name: "don't upload data when metadata is nil", | ||
backup: newStringReadSeeker("bar"), | ||
log: newStringReadSeeker("baz"), | ||
}, | ||
} | ||
|
||
|
@@ -87,11 +97,12 @@ func TestUploadBackup(t *testing.T) { | |
backupName = "test-backup" | ||
logger = arktest.NewLogger() | ||
) | ||
defer objStore.AssertExpectations(t) | ||
|
||
if test.metadata != nil { | ||
objStore.On("PutObject", bucket, backupName+"/ark-backup.json", test.metadata).Return(test.metadataError) | ||
} | ||
if test.backup != nil { | ||
if test.backup != nil && test.expectBackupUpload { | ||
objStore.On("PutObject", bucket, backupName+"/"+backupName+".tar.gz", test.backup).Return(test.backupError) | ||
} | ||
if test.log != nil { | ||
|
@@ -111,7 +122,6 @@ func TestUploadBackup(t *testing.T) { | |
assert.NoError(t, err) | ||
} | ||
|
||
objStore.AssertExpectations(t) | ||
}) | ||
} | ||
} | ||
|
@@ -372,5 +382,5 @@ func newStringReadSeeker(s string) *stringReadSeeker { | |
} | ||
|
||
func (srs *stringReadSeeker) Seek(offset int64, whence int) (int64, error) { | ||
panic("not implemented") | ||
return 0, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably makes sense to leave the metadata file here, right? For the same reason that we're uploading it for failed backups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was planning to ask you about that. I'm happy to remove this code!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we handle the situation where the backup completed successfully, we were able to upload the metadata, but uploading the tarball failed for some reason? What you'd see is a completed backup, with logs, but no ability to restore it... TODO for later, or fix now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't you see
Failed
on the API object? this func would return an error to the controller, and thenrunBackup
would return an error toprocessBackup
which would log it and mark it as failed. If this is true, I think it's still not ideal but reasonably obvious enough that no further changes would be needed for now,There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my scenario, the json file in object storage has
Completed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but the backup obj in etcd has
Failed
, right? soark backup get
would showFailed
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd have to go back through the various places where status is changed to failed to confirm. Also, if you were to sync from object storage into a new kube cluster, it would come in as completed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true. idk, what do you think makes sense? we could remove everything from obj storage on error, or re-upload metadata with a Failed status, or...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on where to leave this for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot about this thread. Let me page it back in and think about it.