ocurrent / obuilder

Experimental "docker build" alternative using btrfs/zfs snapshots
Apache License 2.0
60 stars 17 forks source link

Simplify build log and let store set its location #90

Closed MisterDA closed 2 years ago

MisterDA commented 3 years ago

The first step is to remove the dup file in the log tailing to be sure that when/if we want to move the log file, there are no open file descriptors to it. This can be done by switching to Readonly when the log is finished. The second step is to let the store decide the location of the log file. There's a bit of a chicken-and-egg problem here: the store was responsible for moving the log file, but the Db_store module creates it a sets its location, and the store doesn't have access to the location. By letting the store set the log file location, it becomes able to set it to a location independent of the results directories, or to the original location and move it if there's no problem with it.

cc @patricoferris

patricoferris commented 3 years ago

Thanks @MisterDA :))

I'm not sure if this fixes the log problem I was describing before (the moving log files bit is useful for https://github.com/patricoferris/obuilder/pull/5 however). I mean having log files outside of the build directory should in theory solve the problem, I'm just not sure if there is a reason the logs currently get saved in the build directory.

The problem I was seeing is Db_store.get_build calls Raw.build which in this case was Zfs. If the build fails then it calls

https://github.com/ocurrent/obuilder/blob/c89b8769b6212c6436e67523d4807b3c98bb1a72/lib/zfs_store.ml#L193

but as far as I can tell at that point the log file is still open so trying to destroy the dataset gets a resource busy error (only on macOS...)