Commit Graph

4059 Commits

Author SHA1 Message Date
Umang Jain
66079c7b65 lib/repo: Allow min-free-space-size and -percent to co-exist
Previously, we would error out if both of the options were mentioned
in the config file (even if one of them is disabled with 0). There
were few suggestions that this behavior was not quite right.

Therefore, instead of throwing error and exiting, it's preferred to
warn the user. Hence, the solution that worked out is:
* Allow both options to exist simulateneously
* Check each config's value and decide:
  * If both are present and are non-zero, warn the user. Also, prefer
    to use min-free-space-size over the another.
  * If both are absent, then use -percent=3% as fallback
  * Every other case is valid hence, no warning

https://phabricator.endlessm.com/T13698
(cherry picked from commit be68991cf80f0aa1da7d36ab6e1d2c4d6c7cd3fb)
Signed-off-by: Robert McQueen <rob@endlessm.com>

Closes: #1685
Approved by: cgwalters
2018-07-20 14:58:40 +00:00
Emmanuele Bassi
7306577e61 Add a check for gpg-error via pkg-config
Some downstreams — namely, the Yocto Project — ship gpg-error with a
pkg-config file, and modify gpg-error-config to error out when you try
using it instead of pkg-config.

We can check for gpg-error via pkg-config, and if it's not available,
fall back to gpg-error-config.

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>

Closes: #1682
Approved by: cgwalters
2018-07-18 01:34:36 +00:00
Colin Walters
ededa9de41 Update libglnx
For `renameat2()` fix to build with latest glibc (e.g. Fedora rawhide).

Update submodule: libglnx

Closes: #1680
Approved by: jlebon
2018-07-17 19:59:18 +00:00
Colin Walters
be8bbc5f87 build-sys: Link with gpg-error directly
We use the API, and not linking breaks the build with e.g.
`-fuse-ld=gold` in a Fedora 28 buildroot as gold doesn't do the
"search indirect dependencies" thing.

Closes: #1679
Approved by: jlebon
2018-07-17 19:14:14 +00:00
Colin Walters
fef07889d3 deploy: Fix overriding kernel args for staged deployments
This is the inverse of https://github.com/ostreedev/ostree/pull/1558
aka commits cadece6c4f and
3358698c86

Needed to fix `rpm-ostree kargs` test suite with default staging; skipping
a test here for now as eventually what we'll do is turn on the rpm-ostree
suite fully here.

Closes: #1677
Approved by: jlebon
2018-07-09 18:04:57 +00:00
William Manley
c7b12a8730 ostree repo commit: Speed up composing trees with --tree=ref
Running `ostree commit --tree=ref=a --tree=dir=b` involves reading the
whole of a into an `OstreeMutableTree` before composing `b` on top.  This
is inefficient if a is a complete rootfs and b is just touching one file.
We process O(size of a + size of b) directories rather than
O(number of touched dirs).

This commit makes `ostree commit` more efficient at composing multiple
directories together.  With `ostree_mutable_tree_fill_empty_from_dirtree`
we create a lazy `OstreeMutableTree` which only reads the underlying
information from disk when needed.  We don't need to read all the
subdirectories just to get the checksum of a tree already checked into the
repo.

This provides great speedups when composing a rootfs out of multiple other
rootfs as we do in our build system.  We compose multiple containers
together with:

    ostree commit --tree=ref=base-rootfs --tree=ref=container1 --tree=ref=container2

and it is much faster now.

As a test I ran

    time ostree --repo=... commit --orphan --tree=ref=big-rootfs --tree=dir=modified_etc

Where modified_etc contained a modified sudoers file under /etc.  I used
`strace` to count syscalls and I seperatly took timing measurements.  To
test with a cold cache I ran

    sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

Results:

|                      | Before | After |
| -------------------- | ------ | ----- |
| Time (cold cache)    |   8.1s | 0.12s |
| Time (warm cache)    |   3.7s | 0.08s |
| `openat` calls       |  53589 |   246 |
| `fgetxattr` calls    |  78916 |     0 |

I'm not sure if this will have some negative interaction with the
`_ostree_repo_commit_modifier_apply` which is short-circuited here.  I
think it was disabled for `--tree=ref=` anyway, but I'm not certain.  All
the tests pass anyway.

I originally implemented this in terms of the `OstreeRepoFile` APIs, but
it was *way* less efficient, opening and reading many files unnecessarily.

Closes: #1643
Approved by: cgwalters
2018-07-09 13:10:51 +00:00
Alex Kiernan
11eb0bd227 switchroot: Move late /run/ostree-booted creation to ostree-system-generator
When ostree-prepare-root is pid 1, ostree-prepare-boot defers creation of
/run/ostree-booted, which happens in ostree-remount, but that's too late
if we need ostree-system-generator to bind /var. Add the creation of the
/run/ostree-booted marker to ostree-system-generator based on the
existence of the ostree= kernel command line argument (which matches the
condition that ostree-remount uses).

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>

Closes: #1675
Approved by: cgwalters
2018-07-09 00:11:31 +00:00
Alex Kiernan
d6327f9dd9 switchroot: Fix typo in comment ENINVAL => EINVAL
Closes: #1676
Approved by: cgwalters
2018-07-08 12:41:59 +00:00
Umang Jain
eeacbc6b29 repo: Reword min-free-space-size option's error strings
It is important that we use user-friendly error strings. The reason
being error strings are seen by users such as in GNOME Software's
error banner.

Closes: #1671
Approved by: jlebon
2018-07-06 19:59:11 +00:00
Umang Jain
4c023a9585 lib/repo-commit: Factor out min-free-space-size error reporting
Improves code readability.

Closes: #1671
Approved by: jlebon
2018-07-06 19:59:10 +00:00
Colin Walters
7468600029 deploy: Retain staged by default
For `rpm-ostree ex livefs` we have a use case of pushing a rollback
deployment.  There's no reason this should require deleting the staged
deployment (and doing so actually breaks livefs which tries to access
it as a data source).

I was initially very conservative here, but I think it ends up
being fairly easy to retain the staged deployment.  We need to handle
two cases:

First, when the staged is *intentionally* deleted; here, we just need
to unlink the `/run` file, and then everything will be sync'd up after
reloading.

Second, (as in the livefs case) where we're retaining it,
e.g. adding a deployment to the end.  What I realized here is that
we can have the code keep `new_deployments` as view without staged,
and then when we do the final reload we'll end up re-reading it from
disk anyways.

Closes: #1672
Approved by: jlebon
2018-07-06 15:23:52 +00:00
Robert Fairley
10c2fc33f6 tests: Run network retries test for many retries directly
This runs a test involving many retries for the --network-retries
option directly rather than inside a conditional statement, so that
the command does not silently fail and allow the test to continue
running.

Closes: #1673
Approved by: jlebon
2018-07-05 20:11:42 +00:00
Robert Fairley
7baf167881 ostree/pull: Add network-retries command line option
This exposes a way to specify from the command line the number
of times to retry each download after a network error. If a negative
value is given, then the default number of retries (5) is used. If 0
is given, then errors are returned without retrying.

closes #1659

Closes: #1669
Approved by: jlebon
2018-07-05 17:59:09 +00:00
Robert Fairley
4f096c8f11 tests: Move assert_fail function to tests/libtest.sh
This moves the assert_fail function definition which was defined
and called in tests/test-remote-headers.sh. Done in preparation
for use of the assert_fail function in other test files.

Closes: #1669
Approved by: jlebon
2018-07-05 17:59:09 +00:00
Alex Kiernan
3696e1cfdd build: Use ostree_prepare_root_CPPFLAGS for ostree-prepare-root
Swap from AM_CPPFLAGS to ostree_prepare_root_CPPFLAGS when compiling
ostree-prepare-root statically. This fixes a problem when you have
systemd and libmount, but only ostree_prepare_root_CPPFLAGS includes
-DHAVE_SYSTEMD_AND_LIBMOUNT=1.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>

Closes: #1670
Approved by: jlebon
2018-07-04 19:45:50 +00:00
Jonathan Lebon
2cb2571127 tests/installed: Add NOTE when re-using RPMs
One gotcha here is that we don't invalidate the RPMs if we're not
sitting on the same commit anymore. Shouldn't be too hard to fix, though
let's at least make a note of it for now.

Closes: #1668
Approved by: cgwalters
2018-07-04 16:06:38 +00:00
Colin Walters
61ba4e7e5a tests/installed: Add var-mount.yml destructive test
Closes: #1668
Approved by: cgwalters
2018-07-04 16:06:38 +00:00
Jonathan Lebon
a13ea6497e switchroot: Fix regression for separately mounted /var
I made a logical error in #1617 which resulted in the exact *opposite*
behaviour we want when `/var` is a separate mount.

Split this out and lower the number of negations to make it more obvious
that it's correct.

Closes: #1667

Closes: #1668
Approved by: cgwalters
2018-07-04 16:06:38 +00:00
Marcus Folkesson
8af389b758 build: add ostree-soup-* to build process when configured with avahi
Avoid getting these link errors:
    ./.libs/libostree-1.so: undefined reference to `soup_uri_set_path'
    ./.libs/libostree-1.so: undefined reference to `soup_uri_new'
    ./.libs/libostree-1.so: undefined reference to `soup_uri_free'
    ./.libs/libostree-1.so: undefined reference to `soup_uri_set_scheme'
    ./.libs/libostree-1.so: undefined reference to `soup_uri_to_string'
    ./.libs/libostree-1.so: undefined reference to `soup_uri_set_host'
    ./.libs/libostree-1.so: undefined reference to `soup_uri_set_port'
    collect2: error: ld returned 1 exit status

Reproduce with:
    ./configure --with-avahi --without-soup

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>

Closes: #1666
Approved by: cgwalters
2018-07-03 19:42:49 +00:00
Alex Kiernan
a0527e7086 boot: Use emergency.target, not emergency.service
Follow systemd units in using emergency.target, not emergency.service
(which is the sole unit, by default, in emergency.target) so we can
easily reconfigure the units which are actived when entering
emergency mode.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>

Closes: #1665
Approved by: cgwalters
2018-07-03 13:38:10 +00:00
Umang Jain
0c8b86ea09 lib/repo: Minor fixes around min-free-space
Summary:
* Remove a useless if condition in prepare_transaction()
* Fix glnx_throw error propagation
* Integer overflow check while parsing min-free-space-size config
* Documentation fixes

Closes: #1663
Approved by: jlebon
2018-07-03 12:59:26 +00:00
William Manley
488365f9bf OstreeMutableTree: Invalidate parent contents checksum when metadata changes
This bug has existed before the previous commit, but thanks to the previous
commit it is now easy to fix.

Closes: #1655
Approved by: cgwalters
2018-06-29 21:31:08 +00:00
William Manley
5b0dd1002e OstreeMutableTree: Refactor: Add parent pointer
This implements a TODO item from
`ostree_mutable_tree_get_contents_checksum`.  We now no-longer invalidate
the dirtree contents checksum at `get_contents_checksum` time - we
invalidate it when the mtree is modified.  This is implemented by keeping
a pointer to the parent directory in each `OstreeMutableTree`.  This gives
us stronger invariants on `contents_checksum`.

For even stronger guarantees about invariants we could make
`ostree_repo_write_mtree` or similar a member of `OstreeMutableTree` and
remove `ostree_mutable_tree_set_metadata_checksum`.

I think I've fixed a bug here too.  We now invalidate parent's contents
checksum when our metadata checksum changes, whereas we didn't before.

Closes: #1655
Approved by: cgwalters
2018-06-29 21:31:08 +00:00
Colin Walters
f2e71c60ec ci/flatpak: Fix to use built ostree version
Noticed as part of a random failure in this PR:
https://github.com/ostreedev/ostree/pull/1655
that we weren't actually testing the version of ostree
we built in git.  Probably we should be generating RPMs but...later.

Closes: #1662
Approved by: jlebon
2018-06-29 20:54:42 +00:00
Philip Withnall
abff8b8cfa lib/repo-commit: Abort a transaction if preparing it fails
If ostree_repo_prepare_transaction() fails, we should reset the
repository’s state so that the failed call was essentially idempotent.
Do that by calling ostree_repo_abort_transaction() on the failure path.

Typically, the way for preparing a transaction to fail is for its
GCancellable to be triggered, rather than because any of the operations
involved in preparing a transaction are particularly failure prone.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1647
Approved by: cgwalters
2018-06-29 19:32:44 +00:00
Marcus Folkesson
be018ed70c ci: exclude 'lib' from libsoup configure option
The option used by configure script is actually
--with-soup/--without-soup.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>

Closes: #1661
Approved by: jlebon
2018-06-29 13:16:05 +00:00
Colin Walters
7ead3c1aa8 sysroot: Reject attempts to pin the staged deployment
From https://github.com/projectatomic/rpm-ostree/pull/1434#discussion_r198936674

To support it we'd have to actually write it to disk, which...let's
not try that right now.

Closes: #1660
Approved by: jlebon
2018-06-29 01:52:30 +00:00
William Manley
bab3b2bd4c tests: Save corefiles back to tests/ directory if one exists
Makes it easier to debug failures from the tests.

Closes: #1657
Approved by: cgwalters
2018-06-28 15:07:14 +00:00
Matthew Leeds
05d8ade563 create-usb: Tweak docs for --destination-repo
Make it show up in the help output as --destination-repo=DEST so it's
clear that it takes an argument.

Closes: #1656
Approved by: jlebon
2018-06-28 13:03:09 +00:00
Umang Jain
d686056254 lib/repo: Cleanup current boot's staging dir min-free-space-* checks are hit
min-free-space-* act as a gating condition whether to we want hold onto caches in
repo/tmp. If it is found that the free-disk space is going below this threshold,
we flag it as an error and cleanup current boot's staging directory.

Closes: #1602
Approved by: jlebon
2018-06-27 19:02:02 +00:00
Umang Jain
1074668ede lib/repo: cleanup_tmpdir should be executed after releasing lock file
Here's a subtle bug in abort_transaction():
One of the policies of cleaning up is to skip the current boot's staging
directory. The responsible function for this is cleanup_tmpdir() which tries
to lock each of the tmpdir before deleting it. When it comes to the current
boot's staging dir, it tries to lock the directory(again!) but fails as there
is already a lockfile present. Just because the current boot's staging dir was
meant to be skipped, the bug never surfaced up and wasn't catastrohpic.

if (!_ostree_repo_try_lock_tmpdir (dfd, path, &lockfile, &did_lock, error))
  return FALSE;
if (!did_lock)
  return TRUE; /* Note early return */
...
if (g_str_has_prefix (path, self->stagedir_prefix))
  return TRUE; /* Note early return */

The actual check for skipping staging dir for current boot was never reached
because the function returned at did_lock failure.

Therefore, execute cleanup_tmpdir() after releasing the lockfile in
abort_transaction() so that cleanup_tmpdir gets a chance to lock current boot's
staging directory and succeed.

Closes: #1602
Approved by: jlebon
2018-06-27 19:02:02 +00:00
Javier Martinez Canillas
9f48e212a3 deploy: Change BootLoaderSpec filenames so they can be used for sorting
Currently the BLS snippets are named ostree-$ID-$VARIANT_ID-$index.conf,
but the BLS config files are actually sorted by using the version field
which is the inverse of the index.

In most places, _ostree_sysroot_read_boot_loader_configs() is used to
get the BLS files and this function already returns them sorted by the
version field. The only place where the index trailing number is used is
in the ostree-grub-generator script that lists the BLS files to populate
the grub config file.

But for some bootloaders the BLS filename is the criteria for sorting by
taking the filename as a string version. So on these bootloaders the BLS
entries will be listed in the reverse order.

To avoid that, change the BLS snippets filename to have the version field
instead of the index and also to have the version before deployment name.

Make the filenames to be of the form ostree-$version-$ID-$VARIANT_ID.conf
so the version is before the deployment name.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Closes: #1654
Approved by: cgwalters
2018-06-27 18:08:28 +00:00
Simon McVittie
47ae4f5c7e OstreeRepoFinderConfig: Fix guint/gsize confusion
If a function has a guint "out argument", passing a pointer to a gsize
is not, in general, valid. On an ILP64 platform there is no problem
since guint and gsize are identical, but on an LP64 platform it will
overwrite only the first word of the gsize, leaving the second word
unaffected. On little-endian machines, if the second word is
zero-initialized (as it is here), the result is numerically equal to
the guint, but on big-endian machines the result is around 4 billion
times what it should be, resulting in
ostree_repo_finder_config_resolve_async() reading past the end of
the array and causing undefined behaviour.

In practice this caused assertion failures (and consequently test
failures) on Debian's s390x (z/Architecture), ppc64 (64-bit PowerPC)
and sparc64 (64-bit SPARC) ports.

Closes: #1640
Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1641
Approved by: cgwalters
2018-06-27 15:24:18 +00:00
Javier Martinez Canillas
25e17e0b62 ostree-grub-generator: sort BLS files by version instead of alphabetically
The ostree-grub-generator populates the grub.cfg menu entries using the
BLS config files. But it uses the ls command that by default sorts the
entries alphabetically, so the order won't be correct if there are more
than 10 deployments, i.e:

$ ls -1 /boot/loader/entries/
ostree-fedora-workstation-0.conf
ostree-fedora-workstation-10.conf
ostree-fedora-workstation-1.conf
...

So instead the -v option should be used to make ls use version sorting:

$ ls -1 -v /boot/loader/entries/
ostree-fedora-workstation-0.conf
ostree-fedora-workstation-1.conf
...
ostree-fedora-workstation-10.conf

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Closes: #1653
Approved by: cgwalters
2018-06-27 14:20:29 +00:00
Jonathan Lebon
8dff04601b tests/installed: Wait a bit more for http.server
And also print out the output if it still didn't start up in case there
are error messages hidden in there.

This should hopefully help with diagnosing the flakes we've been seeing
in starting it up.

Closes: #1652
Approved by: cgwalters
2018-06-27 13:29:55 +00:00
Colin Walters
087ad1167a ci: Workaround getfedora.org/atomic_qcow2_latest being 404
Closes: #1652
Approved by: cgwalters
2018-06-27 13:29:55 +00:00
Matthew Leeds
f1133a2a0a man/ostree.repo-config: Document collection-id
The collection-id option in the core section was recently made public
but not documented.

Closes: #1646
Approved by: cgwalters
2018-06-26 12:52:49 +00:00
William Manley
5d031ae78b Add test for composing trees in different ways
In preparation for adding `ostree commit` optimisations.

Closes: #1645
Approved by: jlebon
2018-06-25 16:22:22 +00:00
William Manley
5190f1df42 OstreeMutableTree: Document ostree_mutable_tree_ensure_dir
Closes: #1645
Approved by: jlebon
2018-06-25 16:22:21 +00:00
William Manley
ca8571a49b OstreeMutableTree: Document each private member of OstreeMutableTree
A prelude to my understanding.  Unfortunately `OstreeMutableTree` provides
little encapsulation, as each member has setters† so it's difficult to come
up with a list of invariants.

† `files` and `subdirs` only have getters, but the getters return mutable
  references to the internals, so we still can't reason about invariants.

Closes: #1645
Approved by: jlebon
2018-06-25 16:22:21 +00:00
Simon McVittie
e120a6b119 avahi: Fail immediately if we can't talk to D-Bus or Avahi
We special-case AVAHI_ERR_NO_DAEMON to not cause warnings, but if
we pass AVAHI_CLIENT_NO_FAIL to avahi_client_new, we never actually
see AVAHI_ERR_NO_DAEMON. Instead, we will get AVAHI_ERR_BAD_STATE
when we try to use the client.

Closes: #1618
Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1639
Approved by: cgwalters
2018-06-23 14:54:39 +00:00
Umang Jain
8d97b55241 tests: Add tests for space checks during deltas codepath
Closes: #1614
Approved by: jlebon
2018-06-22 21:01:56 +00:00
Umang Jain
095376efa2 lib/repo: Enforce min-free-space-* size check for regfiles in deltas
During the pull, there is an explicit check for free space on disk
vs. the size of uncompressed delta; But while writing the new content
objects that are generated, they have to honor min-free-space-* checks
too. We enforce this check in _bare_content_commit as that is where
we can know the final size of the new content object.

Closes: #1614
Approved by: jlebon
2018-06-22 21:01:56 +00:00
Colin Walters
1174d9f5ba lib/repo: Fix 32 bit format string error 2018-06-21 11:33:23 -04:00
Jonathan Lebon
603c1258cc Post-release version bump 2018-06-21 11:23:40 -04:00
Colin Walters
31a356dca9 Release 2018.6 2018-06-19 15:48:14 -04:00
Colin Walters
0f88a2a72d tests/installed: Add a free-space success path test
We implicitly test the success percent path a lot, but not the
absolute path.

Closes: #1632
Approved by: jlebon
2018-06-19 18:29:31 +00:00
Colin Walters
5e9d382811 lib/repo: Do free space math under lock in error path
We were referencing the txn bits outside of the lock in the error
path. Generally shouldn't matter, but e.g. Rust wouldn't let us do this, and
race detector tooling will warn about it.

Closes: #1632
Approved by: jlebon
2018-06-19 18:29:31 +00:00
Colin Walters
acab2c1ac6 lib/repo: Rename free_space_size variable to free_space_mb
I generally like having variables include their units where applicable;
timer variables having `_secs` or `_ms`, etc.

Closes: #1632
Approved by: jlebon
2018-06-19 18:29:31 +00:00
Colin Walters
a2b08f9342 lib/repo: Fix double-set-error in min-free-space-size code
We need to pass `NULL` as the error, we only care if the key exists;
otherwise we'll try to set the error twice.

Closes: #1632
Approved by: jlebon
2018-06-19 18:29:31 +00:00