osbuid: integrate FsCache into ObjectStore

Integrate the recently added file system cache `FsCache` into our
object store `ObjectStore`. NB: This changes the semantics of it:
previously a call to `ObjectStore.commit` resulted in the object
being in the cache (i/o errors aside). But `FsCache.store`, which
is now the backing store for objects, will only commit objects if
there is enough space left. Thus we cannot rely that objects are
present for reading after a call to `FsCache.store`. To cope with
this we now always copy the object into the cache, even for cases
where we previously moved it: for the case where commit is called
with `object_id` matching `Object.id`, which is the case for when
`commit` is called for last stage in the pipeline. We could keep
this optimization but then we would have to special case it and
not call `commit` for these cases but only after we exported all
objects; or in other words, after we are sure we will never read
from any committed object again. The extra complexity seems not
worth it for the little gain of the optimization.
Convert all the tests for the new semantic and also remove a lot
of them that make no sense under this new paradigm.

Add a new command line option `--cache-max-size` which will set
the maximum size of the cache, if specified.
This commit is contained in:
Christian Kellner 2022-12-06 18:41:52 +01:00
parent 1e0e1fa2c2
commit ae0680da11
6 changed files with 158 additions and 247 deletions

View file

@ -43,6 +43,9 @@ is not listed here, **osbuild** will deny startup and exit with an error.
are stored
-l DIR, --libdir=DIR directory containing stages, assemblers, and
the osbuild library
--cache-max-size=SIZE maximum size of the cache (bytes) or 'unlimited'
for no restriction (size may include an optional
unit suffix, like kB, kiB, MB, MiB and so on)
--checkpoint=CHECKPOINT stage to commit to the object store during
build (can be passed multiple times)
--export=OBJECT object to export (can be passed multiple times)