canonical / rockcraft

Tool to create OCI Images using the language from Snapcraft and Charmcraft.
GNU General Public License v3.0
35 stars 43 forks source link

Clean slate between rebuilds #39

Open valentincanonical opened 2 years ago

valentincanonical commented 2 years ago

Sometimes, the rockcraft pack command will fail with the following error,

Failed to copy image: Command '['umoci', 'init', '--layout', '/root/images/bare']' returned non-zero exit status 1. (⨯ image layout creation: path already exists: /root/images/bare)                                                                            
2022-05-19 12:28:58.701 Traceback (most recent call last):                                                                                                                                                                                                                               
2022-05-19 12:28:58.702   File "/snap/rockcraft/x1/lib/python3.8/site-packages/rockcraft/oci.py", line 239, in _process_run                                                                                                                                                              
2022-05-19 12:28:58.705     subprocess.run(                                                                                                                                                                                                                                              
2022-05-19 12:28:58.705   File "/snap/rockcraft/x1/usr/lib/python3.8/subprocess.py", line 516, in run                                                                                                                                                                                    
2022-05-19 12:28:58.705     raise CalledProcessError(retcode, process.args,                                                                                                                                                                                                              
2022-05-19 12:28:58.705 subprocess.CalledProcessError: Command '['umoci', 'init', '--layout', '/root/images/bare']' returned non-zero exit status 1.                                                                                                                                     
2022-05-19 12:28:58.707 Full execution log: '/root/.cache/rockcraft/log/rockcraft-20220519-122857.121178.log'                                     

a way to reproduce that seem to be,

  1. build a part with multiple stage packages
  2. remove a package from the list
  3. try to rebuild the part
valentincanonical commented 2 years ago

Can't manage to reproduce in 100% cases... I will reopen with a working step-by-step example when I manage to reproduce.

cjdcordeiro commented 2 years ago

please re-open, I think I know what it is

cjdcordeiro commented 2 years ago

Update

the reported error case was caused by the introduction of base: bare in https://github.com/canonical/rockcraft/pull/36. This specific corner case has been fixed in https://github.com/canonical/rockcraft/commit/d1a5f04cd7ad477e8d5e056228360b97afcea28b.

I'd suggest nonetheless to keep this issue open, and ask @valentincanonical to update the description as the request is still valid for other error cases as well, like: when installing a new Rockcraft snap locally, if there is already an LXC instance from a previous build, all forthcoming builds of the same ROCK will still have the old Rockcraft version installed within the LXC instance.

Other unforeseen error cases might still occur, due to the leftover image/bundle/step dirs left within the LXC instance from previous builds.

Additionally, sensitive information might also be leftover within the LXC instance after a build.

Conclusion

I believe the issue is still valid, and we should aim to have a clean environment on every ROCK build - ideally having a new LXC instance for every build, without compromising build time

sergiusens commented 2 years ago

This looks like a craft-providers issue, @facundobatista and @mr-cal both recently worked on the code paths related to this, I will make sure looking into this is planned for in our upcoming sprint.