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

filesystem: Bubble up errors rather than panicing #414

Merged
merged 2 commits into from
Jul 10, 2023

Conversation

obbardc
Copy link
Member

@obbardc obbardc commented Jul 5, 2023

If the overlay action fails to copy a file into the target filesystem
(e.g. destination path inside the filesystem doesn't exist), the current
behaviour is to panic, which causes a debos call inside the fakemachine
to panic, which isn't detected by the outer debos call.

This causes the exection of the inner debos call to stop (i.e. the
remaining recipe actions are no longer ran which is expected), but the
postexec commands still run and the overall exection is marked as
successful!

Rework the panics to instead bubble up errors so that any errors when
overlaying files causes the recipe to error out correctly rather than
this unexpected behaviour.

Attempt to overlay a file into a directory in the filesystem which doesn't
exist. The expected behavior is to cause an error.

This test is currently a manual test case and is not hooked into the CI.

Signed-off-by: Christopher Obbard <[email protected]>
@obbardc obbardc added the bug label Jul 5, 2023
@obbardc obbardc added this to the v1.1.2 milestone Jul 5, 2023
@obbardc obbardc requested a review from sjoerdsimons July 5, 2023 11:58
@obbardc obbardc self-assigned this Jul 5, 2023
If the overlay action fails to copy a file into the target filesystem
(e.g. destination path inside the filesystem doesn't exist), the current
behaviour is to panic, which causes a debos call inside the fakemachine
to panic, which isn't detected by the outer debos call.

This causes the execution of the inner debos call to stop (i.e. the
remaining recipe actions are no longer ran which is expected), but the
postexec commands still run and the overall exection is marked as
successful!

Rework the panics to instead bubble up errors so that any errors when
overlaying files causes the recipe to error out correctly rather than
this unexpected behaviour.

Before this commit is applied, the panic causes the debos call inside the
fakemachine to fail without being trapped by the outer debos call and the
outer debos call to still run the postprocess commands and exit with no
error as if the overlay action was successful:

    $ debos tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml
    2023/07/05 11:07:24 ==== Overlay file to a non-existent destination ====
    2023/07/05 11:07:24 Overlaying tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml on /scratch/root/this/path/does/not/exist
    2023/07/05 11:07:24 Failed to copy file tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml: open /scratch/root/this/path/does/not/3277940894: no such file or directory
    2023/07/05 12:07:24 ==== run ====
    2023/07/05 12:07:24 echo Test | Test
    2023/07/05 12:07:24 ==== Recipe done ====
    $ echo $?
    0

With this commit applied, the execution of the outer debos call stops when
the overlay action fails and the error is correctly bubbled up to the user:

    $ debos tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml
    2023/07/05 11:08:15 ==== Overlay file to a non-existent destination ====
    2023/07/05 11:08:15 Overlaying tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml on /scratch/root/this/path/does/not/exist
    2023/07/05 11:08:15 Action `Overlay file to a non-existent destination` failed at stage Run, error: Failed to copy file tests/overlay-non-existent-destination/overlay-non-existent-destination.yaml: open /scratch/root/this/path/does/not/1742738134: no such file or directory
    $ echo $?
    1

Fixes: #401
Signed-off-by: Christopher Obbard <[email protected]>
@obbardc obbardc force-pushed the wip/obbardc/actions-overlay-fix-panic branch from 310bcfc to ba3b209 Compare July 5, 2023 11:59
@sjoerdsimons sjoerdsimons added this pull request to the merge queue Jul 10, 2023
Merged via the queue into main with commit 5412d8b Jul 10, 2023
50 checks passed
@obbardc obbardc deleted the wip/obbardc/actions-overlay-fix-panic branch July 25, 2023 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants