Fix postgres directory search on tarfile

During AIO-SX upgrade playbook, sysinv can fail with a
"ValueError: substring not found" when trying to extract
postgres data from the backup tarfile. This issue is hit
when the code tries find a "/" character in a path inside
the tarfile but it is not present.

This commit adds a "/" character to the end of every
directory path to solve the issue.

Test Plan
PASS: run AIO-SX n+2 upgrade playbook successfully
PASS: (Regression) run AIO-SX n+1 upgrade playbook sucessfully

Story: 2009303
Task: 47127

Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
Change-Id: If9f8153696d0b957edd29bfcf3f350e77e692579
This commit is contained in:
Heitor Matsui 2023-01-04 10:43:41 -03:00
parent e4bd099dd4
commit 2c9995ede4
1 changed files with 2 additions and 0 deletions

View File

@ -1273,6 +1273,8 @@ def extract_postgres_data(archive):
offset = len(ansible_start_path)
for member in archive.getmembers():
if member.name.startswith(ansible_start_path):
if member.isdir() and not member.name.endswith("/"):
member.name = member.name + "/"
ansible_path = member.name[:member.name.index('/', offset)]
break
extract_relative_directory(