Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filesystem: Bubble up errors rather than panicing
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: go-debos#401 Signed-off-by: Christopher Obbard <[email protected]>
- Loading branch information