From 1f9d111f847cd2b117c36f6433059c65fc488c03 Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Fri, 27 Sep 2024 09:51:16 +0200 Subject: [PATCH] Fix type passed to write function during backup restoration Cinder backup throws a TypeError when trying to restore to a new volume, because slicing a memoryview object does not return a byte string. Closes-Bug: #2082587 Change-Id: Ibaf87af25dc33c59660be6e112ca78b993592385 (cherry picked from commit b5ac261e6a8f19b0bfbf93de0522f15b2cb79baf) --- cinder/backup/chunkeddriver.py | 2 +- ...ug-2082587-fix-type-passed-during-backup-restoration.yaml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-2082587-fix-type-passed-during-backup-restoration.yaml diff --git a/cinder/backup/chunkeddriver.py b/cinder/backup/chunkeddriver.py index 490baf84458..8f003329bc8 100644 --- a/cinder/backup/chunkeddriver.py +++ b/cinder/backup/chunkeddriver.py @@ -78,7 +78,7 @@ def _write_nonzero(volume_file, volume_offset, content): # The len(chunk) may be smaller than chunk_length. It's okay. if not volume_utils.is_all_zero(chunk): volume_file.seek(volume_offset + chunk_offset) - volume_file.write(chunk) + volume_file.write(chunk.tobytes()) def _write_volume(volume_is_new, volume_file, volume_offset, content): diff --git a/releasenotes/notes/bug-2082587-fix-type-passed-during-backup-restoration.yaml b/releasenotes/notes/bug-2082587-fix-type-passed-during-backup-restoration.yaml new file mode 100644 index 00000000000..20b6c40027d --- /dev/null +++ b/releasenotes/notes/bug-2082587-fix-type-passed-during-backup-restoration.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + `Bug #2082587 ` _: Fixed + backup restoration throwing TypeError on new volume.