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

Revert "payload: raise exception on non zero exit code from rsync" #6029

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,20 @@ def run(self):

try:
self.report_progress(_("Installing software..."))
for line in execReadlines(cmd, args):
reader = execReadlines(cmd, args, raise_on_nozero=False)
for line in reader:
self._parse_rsync_update(line)

except (OSError, RuntimeError) as e:
msg = "Failed to install image: {}".format(e)
raise PayloadInstallationError(msg) from None

if reader.rc == 11:
raise PayloadInstallationError(
"Failed to install image: "
"{} exited with code {}".format(cmd, reader.rc)
)

def _parse_rsync_update(self, line):
"""Try to extract progress from rsync output.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_install_image_task(self, exec_readlines, os_sync):
"--exclude", "/etc/machine-info",
mount_point + "/",
"/mnt/root"
])
], raise_on_nozero=False)

@patch("pyanaconda.modules.payloads.payload.live_image.installation.os.sync")
@patch("pyanaconda.modules.payloads.payload.live_image.installation.execReadlines")
Expand All @@ -140,6 +140,24 @@ def test_install_image_task_failed_exception(self, exec_readlines, os_sync):
msg = "Failed to install image: Fake!"
assert str(cm.value) == msg

@patch("pyanaconda.modules.payloads.payload.live_image.installation.os.sync")
@patch("pyanaconda.modules.payloads.payload.live_image.installation.execReadlines")
def test_install_image_task_failed_return_code(self, exec_readlines, os_sync):
"""Test installation from an image task with bad return code."""
exec_readlines.return_value = self._make_reader(11)

with tempfile.TemporaryDirectory() as mount_point:
task = InstallFromImageTask(
sysroot="/mnt/root",
mount_point=mount_point
)

with pytest.raises(PayloadInstallationError) as cm:
task.run()

msg = "Failed to install image: rsync exited with code 11"
assert str(cm.value) == msg


class InstallFromTarTaskTestCase(unittest.TestCase):
"""Test the InstallFromTarTask class."""
Expand Down
Loading