From a38d9163d70cfe4e872dc5bb12c1c117ec9098d0 Mon Sep 17 00:00:00 2001 From: Valentin David Date: Wed, 29 Aug 2018 12:36:21 +0200 Subject: Report processing errors from tracking Failures to write files when tracking were not reported. Fixes #533. --- buildstream/_scheduler/queues/trackqueue.py | 15 +++---------- tests/frontend/track.py | 34 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/buildstream/_scheduler/queues/trackqueue.py b/buildstream/_scheduler/queues/trackqueue.py index c7a8f4cc7..f443df3be 100644 --- a/buildstream/_scheduler/queues/trackqueue.py +++ b/buildstream/_scheduler/queues/trackqueue.py @@ -58,18 +58,9 @@ class TrackQueue(Queue): # Set the new refs in the main process one by one as they complete for unique_id, new_ref in result: source = _plugin_lookup(unique_id) - try: - # We appear processed if at least one source has changed - if source._save_ref(new_ref): - changed = True - except SourceError as e: - # FIXME: We currently dont have a clear path to - # fail the scheduler from the main process, so - # this will just warn and BuildStream will exit - # with a success code. - # - source.warn("Failed to update project file", - detail="{}".format(e)) + # We appear processed if at least one source has changed + if source._save_ref(new_ref): + changed = True element._tracking_done() diff --git a/tests/frontend/track.py b/tests/frontend/track.py index 73b63ec4c..c7921fe4c 100644 --- a/tests/frontend/track.py +++ b/tests/frontend/track.py @@ -1,3 +1,4 @@ +import stat import os import pytest from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction @@ -634,3 +635,36 @@ def test_track_junction_included(cli, tmpdir, datafiles, ref_storage, kind): result = cli.run(project=project, args=['track', 'junction.bst']) result.assert_success() + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("kind", [(kind) for kind in ALL_REPO_KINDS]) +def test_track_error_cannot_write_file(cli, tmpdir, datafiles, kind): + if os.geteuid() == 0: + pytest.skip("This is not testable with root permissions") + + project = str(datafiles) + dev_files_path = os.path.join(project, 'files', 'dev-files') + element_path = os.path.join(project, 'elements') + element_name = 'track-test-{}.bst'.format(kind) + + configure_project(project, { + 'ref-storage': 'inline' + }) + + repo = create_repo(kind, str(tmpdir)) + ref = repo.create(dev_files_path) + + element_full_path = os.path.join(element_path, element_name) + generate_element(repo, element_full_path) + + st = os.stat(element_path) + try: + read_mask = stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH + os.chmod(element_path, stat.S_IMODE(st.st_mode) & ~read_mask) + + result = cli.run(project=project, args=['track', element_name]) + result.assert_main_error(ErrorDomain.STREAM, None) + result.assert_task_error(ErrorDomain.SOURCE, 'save-ref-error') + finally: + os.chmod(element_path, stat.S_IMODE(st.st_mode)) -- cgit v1.2.1