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

pass in correct filesize in ceph backup #5369

Merged
merged 2 commits into from
Nov 23, 2019
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
8 changes: 7 additions & 1 deletion go/vt/mysqlctl/backupstorage/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ var (
// BackupStorageImplementation is the implementation to use
// for BackupStorage. Exported for test purposes.
BackupStorageImplementation = flag.String("backup_storage_implementation", "", "which implementation to use for the backup storage feature")
// FileSizeUnknown is a special value indicating that the file size is not known.
// This is typically used while creating a file programmatically, where it is
// impossible to compute the final size on disk ahead of time.
FileSizeUnknown = int64(-1)
)

// BackupHandle describes an individual backup.
Expand All @@ -50,7 +54,9 @@ type BackupHandle interface {
// The context is valid for the duration of the writes, until the
// WriteCloser is closed.
// filesize should not be treated as an exact value but rather
// as an approximate value
// as an approximate value.
// A filesize of -1 should be treated as a special value indicating that
// the file size is unknown.
AddFile(ctx context.Context, filename string, filesize int64) (io.WriteCloser, error)

// EndBackup stops and closes a backup. The contents should be kept.
Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/builtinbackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (be *BuiltinBackupEngine) backupFiles(ctx context.Context, params BackupPar
}

// open the MANIFEST
wc, err := bh.AddFile(ctx, backupManifestFileName, 0)
wc, err := bh.AddFile(ctx, backupManifestFileName, backupstorage.FileSizeUnknown)
if err != nil {
return vterrors.Wrapf(err, "cannot add %v to backup", backupManifestFileName)
}
Expand Down
3 changes: 2 additions & 1 deletion go/vt/mysqlctl/cephbackupstorage/ceph.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func (bh *CephBackupHandle) AddFile(ctx context.Context, filename string, filesi

// Give PutObject() the read end of the pipe.
object := objName(bh.dir, bh.name, filename)
_, err := bh.client.PutObjectWithContext(ctx, bucket, object, reader, -1, minio.PutObjectOptions{ContentType: "application/octet-stream"})
// If filesize is unknown, the caller should pass in -1 and we will pass it through.
_, err := bh.client.PutObjectWithContext(ctx, bucket, object, reader, filesize, minio.PutObjectOptions{ContentType: "application/octet-stream"})
if err != nil {
// Signal the writer that an error occurred, in case it's not done writing yet.
reader.CloseWithError(err)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/xtrabackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (be *XtrabackupEngine) ExecuteBackup(ctx context.Context, params BackupPara

// open the MANIFEST
params.Logger.Infof("Writing backup MANIFEST")
mwc, err := bh.AddFile(ctx, backupManifestFileName, 0)
mwc, err := bh.AddFile(ctx, backupManifestFileName, backupstorage.FileSizeUnknown)
if err != nil {
return false, vterrors.Wrapf(err, "cannot add %v to backup", backupManifestFileName)
}
Expand Down