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 <chris.obbard@collabora.com>
Currently the overlay action prints directly to stdout, which
ends up not following the standard output format the other
actions follow. Let's clean this up by using the action's
existing logging functions rather than printing directly
to stdout.
Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
Various filesystem operations here and there are done without checking
the return value, so when it fails nobody knows and the user waste his
time understanding what's going on. Checking return values is useful.
Signed-off-by: Arnaud Rebillout <arnaud.rebillout@collabora.com>
Add a new function similar to the realpath C function to resolve the
canonical absolute path of a file.
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Fix typo leading to incorrect error message in case of any problems
with links during FS copying.
Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Initially 'debos.go' contained a lot of additions and logical parts in
single file. So move logical parts from 'debos.go' to appropriate packages:
- 'debos' package: actions interface and filesystem addons
- 'recipe' package: logic of Yaml-based recipe parsing
Use correct imports, naming and syntax for splitted files.
Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>