-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
backup: remove deprecated hook support #12066
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,6 @@ import ( | |
"vitess.io/vitess/go/mysql" | ||
"vitess.io/vitess/go/sync2" | ||
"vitess.io/vitess/go/vt/concurrency" | ||
"vitess.io/vitess/go/vt/hook" | ||
"vitess.io/vitess/go/vt/log" | ||
"vitess.io/vitess/go/vt/logutil" | ||
"vitess.io/vitess/go/vt/mysqlctl/backupstorage" | ||
|
@@ -73,8 +72,7 @@ type BuiltinBackupEngine struct { | |
} | ||
|
||
// builtinBackupManifest represents the backup. It lists all the files, the | ||
// Position that the backup was taken at, and the transform hook used, | ||
// if any. | ||
// Position that the backup was taken at, the compression engine used, etc. | ||
type builtinBackupManifest struct { | ||
// BackupManifest is an anonymous embedding of the base manifest struct. | ||
BackupManifest | ||
|
@@ -88,9 +86,6 @@ type builtinBackupManifest struct { | |
// FileEntries contains all the files in the backup | ||
FileEntries []FileEntry | ||
|
||
// TransformHook that was used on the files, if any. | ||
TransformHook string | ||
|
||
// SkipCompress is true if the backup files were NOT run through gzip. | ||
// The field is expressed as a negative because it will come through as | ||
// false for backups that were created before the field existed, and those | ||
|
@@ -181,8 +176,6 @@ func (fe *FileEntry) open(cnf *Mycnf, readOnly bool) (*os.File, error) { | |
// ExecuteBackup runs a backup based on given params. This could be a full or incremental backup. | ||
// The function returns a boolean that indicates if the backup is usable, and an overall error. | ||
func (be *BuiltinBackupEngine) ExecuteBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (bool, error) { | ||
params.Logger.Infof("Hook: %v, Compress: %v", backupStorageHook, backupStorageCompress) | ||
|
||
if isIncrementalBackup(params) { | ||
return be.executeIncrementalBackup(ctx, params, bh) | ||
} | ||
|
@@ -301,11 +294,6 @@ func (be *BuiltinBackupEngine) executeIncrementalBackup(ctx context.Context, par | |
// and an overall error. | ||
func (be *BuiltinBackupEngine) executeFullBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (bool, error) { | ||
|
||
params.Logger.Infof("Hook: %v, Compress: %v", backupStorageHook, backupStorageCompress) | ||
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. Same comment as above for the log line. 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. This is a duplicate log line, because the exact same thing was already being logged just before we call this function. So I have left this deleted. |
||
if backupStorageHook != "" { | ||
log.Warning("Flag --backup_storage_hook has been deprecated, consider using one of the builtin compression algorithms or --external-compressor and --external-decompressor instead.") | ||
} | ||
|
||
if params.IncrementalFromPos != "" { | ||
return be.executeIncrementalBackup(ctx, params, bh) | ||
} | ||
|
@@ -551,7 +539,6 @@ func (be *BuiltinBackupEngine) backupFiles( | |
|
||
// Builtin-specific fields | ||
FileEntries: fes, | ||
TransformHook: backupStorageHook, | ||
SkipCompress: !backupStorageCompress, | ||
CompressionEngine: CompressionEngineName, | ||
} | ||
|
@@ -686,19 +673,6 @@ func (be *BuiltinBackupEngine) backupFile(ctx context.Context, params BackupPara | |
|
||
var writer io.Writer = bw | ||
|
||
// Create the external write pipe, if any. | ||
var pipe io.WriteCloser | ||
var wait hook.WaitFunc | ||
if backupStorageHook != "" { | ||
h := hook.NewHook(backupStorageHook, []string{"-operation", "write"}) | ||
h.ExtraEnv = params.HookExtraEnv | ||
pipe, wait, _, err = h.ExecuteAsWritePipe(writer) | ||
if err != nil { | ||
return vterrors.Wrapf(err, "'%v' hook returned error", backupStorageHook) | ||
} | ||
writer = pipe | ||
} | ||
|
||
// Create the gzip compression pipe, if necessary. | ||
var compressor io.WriteCloser | ||
if backupStorageCompress { | ||
|
@@ -727,20 +701,6 @@ func (be *BuiltinBackupEngine) backupFile(ctx context.Context, params BackupPara | |
} | ||
} | ||
|
||
// Close the hook pipe if necessary. | ||
if pipe != nil { | ||
if err := pipe.Close(); err != nil { | ||
return vterrors.Wrap(err, "cannot close hook pipe") | ||
} | ||
stderr, err := wait() | ||
if stderr != "" { | ||
params.Logger.Infof("'%v' hook returned stderr: %v", backupStorageHook, stderr) | ||
} | ||
if err != nil { | ||
return vterrors.Wrapf(err, "'%v' returned error", backupStorageHook) | ||
} | ||
} | ||
|
||
// Close the backupPipe to finish writing on destination. | ||
if err = bw.Close(); err != nil { | ||
return vterrors.Wrapf(err, "cannot flush destination: %v", name) | ||
|
@@ -820,10 +780,6 @@ func (be *BuiltinBackupEngine) ExecuteRestore(ctx context.Context, params Restor | |
return nil, err | ||
} | ||
|
||
if bm.TransformHook != "" { | ||
log.Warning("Flag --backup_storage_hook has been deprecated, consider using one of the builtin compression algorithms or --external-compressor and --external-decompressor instead.") | ||
} | ||
|
||
var err error | ||
if bm.Incremental { | ||
err = be.executeRestoreIncrementalBackup(ctx, params, bh, bm) | ||
|
@@ -919,17 +875,6 @@ func (be *BuiltinBackupEngine) restoreFile(ctx context.Context, params RestorePa | |
dst := bufio.NewWriterSize(dstFile, writerBufferSize) | ||
var reader io.Reader = bp | ||
|
||
// Create the external read pipe, if any. | ||
var wait hook.WaitFunc | ||
if bm.TransformHook != "" { | ||
h := hook.NewHook(bm.TransformHook, []string{"-operation", "read"}) | ||
h.ExtraEnv = params.HookExtraEnv | ||
reader, wait, _, err = h.ExecuteAsReadPipe(reader) | ||
if err != nil { | ||
return vterrors.Wrapf(err, "'%v' hook returned error", bm.TransformHook) | ||
} | ||
} | ||
|
||
// Create the uncompresser if needed. | ||
if !bm.SkipCompress { | ||
var decompressor io.ReadCloser | ||
|
@@ -974,17 +919,6 @@ func (be *BuiltinBackupEngine) restoreFile(ctx context.Context, params RestorePa | |
return vterrors.Wrap(err, "failed to copy file contents") | ||
} | ||
|
||
// Close the Pipe. | ||
if wait != nil { | ||
stderr, err := wait() | ||
if stderr != "" { | ||
log.Infof("'%v' hook returned stderr: %v", bm.TransformHook, stderr) | ||
} | ||
if err != nil { | ||
return vterrors.Wrapf(err, "'%v' returned error", bm.TransformHook) | ||
} | ||
} | ||
|
||
// Check the hash. | ||
hash := bp.HashString() | ||
if hash != fe.Hash { | ||
|
This file was deleted.
This file was deleted.
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.
Might be informative to instead log the
params
but IMO fine to just remove too.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've added a log line that prints more info.