Prevent overwrites due to rebalance-stop race (#20233)

Rebalance-stop can race with ongoing rebalance operations. This change
prevents these operations from overwriting objects by checking the source
and destination pool indices are different.
This commit is contained in:
Krishnan Parthasarathi
2024-08-08 19:05:14 -07:00
committed by GitHub
parent 49055658a9
commit 4e67a4027e
4 changed files with 52 additions and 5 deletions

View File

@@ -788,3 +788,20 @@ func isReplicationPermissionCheck(err error) bool {
_, ok := err.(ReplicationPermissionCheck)
return ok
}
// DataMovementOverwriteErr - captures the error when a data movement activity
// like rebalance incorrectly tries to overwrite an object.
type DataMovementOverwriteErr GenericError
func (de DataMovementOverwriteErr) Error() string {
objInfoStr := fmt.Sprintf("bucket=%s object=%s", de.Bucket, de.Object)
if de.VersionID != "" {
objInfoStr = fmt.Sprintf("%s version-id=%s", objInfoStr, de.VersionID)
}
return fmt.Sprintf("invalid data movement operation, source and destination pool are the same for %s", objInfoStr)
}
func isDataMovementOverWriteErr(err error) bool {
var de DataMovementOverwriteErr
return errors.As(err, &de)
}