lib/repo-commit: Relax min-free-space check in prepare_transaction()

We want a case where we can disable the min-free-space check. Initially,
it felt like to add a OSTREE_REPO_PULL_FLAGS_DISABLE_FREE_SPACE_CHECK but
the problem is prepare_transaction() does not have a OstreeRepoPullFlags
parameter which we can parse right here. On top of it, prepare_transaction()
enforces min-free-space check and won't let the transaction proceed if
the check failed.

This is pretty bad in conjunction with "inherit-transaction" as what
Flatpak uses. There is no way to disable this check unless we remove
it altogether from prepare_transaction.

This issue came out to light when flatpak wasn't able to write metadata
after fetching from remote:

[uajain@localhost ~]$ flatpak remote-info flathub org.kde.Platform//5.9
error: min-free-space-size 500MB would be exceeded

Metadata objects helps in housekeeping and restricting them means
restricting crucial UX (like search, new updates) functionalities
in clients like gnome-software. The error banners originated from
these issues are also abrupt and not much helpful to the user. This
is the specific instance of the issue this patches tries to address.

See https://github.com/flatpak/flatpak/issues/2139 for discussion.

Closes: #1779
Approved by: mwleeds
This commit is contained in:
Umang Jain authored and Atomic Bot committed 2018-12-10 20:04:17 +00:00
1 parent 3ecbdd8197
commit 963395217a
2 files changed
+23 -3

No files matched your search

@@ -45,6 +45,17 @@ echo 'min-free-space-size=1MB' >> repo/config
ostree --repo=repo pull-local /ostree/repo ${host_commit}
echo "ok min-free-space-size (success)"
# metadata object write should succeed even if free space is lower than
# min-free-space value
rm -rf mnt/repo
ostree --repo=mnt/repo init --mode=bare-user
echo 'fsync=false' >> mnt/repo/config
echo 'min-free-space-size=10MB' >> mnt/repo/config
if ostree --repo=mnt/repo pull-local --commit-metadata-only /ostree/repo ${host_commit} 2>err.txt; then
fatal "could not write metadata objects even when min-free-space value should allow it"
fi
echo "ok metadata write even when free space is lower than min-free-space value"
rm -rf mnt/repo
# Test min-free-space-size on deltas