795 Commits

Author SHA1 Message Date
Colin Walters
986f176e7c Release 2018.5
Lots of stuff queued up.

Closes: #1585
Approved by: jlebon
2018-05-11 13:06:19 +00:00
Colin Walters
6873650cae lib/sysroot: Add OSTREE_EX_STAGE_DEPLOYMENTS environment variable
I feel like I'm drowning in a pile of experimental-but-almost-stable
features...

Anyways, since we made the feature opt-in in rpm-ostree in
https://github.com/projectatomic/rpm-ostree/pull/1352
let's mirror that a bit here with an environment variable so people
can play with it more easily.

The tests needed some tweaks; specifically we need to reload the
status fact after making changes.  I'm still a bit uncertain
about the Ansible-as-tests.

But we add an upgrade test that uses the new environment variable.

Closes: #1583
Approved by: jlebon
2018-05-11 12:39:17 +00:00
Colin Walters
605d313206 tests/installed: Disable all rpmmd repos
For the same reason we do in the rpm-ostree tests.  This also
made sure the test run worked when I was offline on a plane.

Closes: #1583
Approved by: jlebon
2018-05-11 12:39:17 +00:00
Colin Walters
a3295ee584 ci: Drop str hotpatch
The change we want is in the current Fedora repos, and git master
is broken:

> qemu-system-x86_64: -vnc :1: Failed to start VNC server: Failed to bind socket: Address already in use

 https://pagure.io/standard-test-roles/pull-request/186#comment-52440

Closes: #1582
Approved by: jlebon
2018-05-08 12:57:35 +00:00
Colin Walters
579faf92fd tests: Fix installed tests more
OK so I noticed that something was failing and we were missing
`set -xeuo pipefail` in our shells.  That of course revealed
the ansible tests didn't actually work - my only defense
here is spending so much time fighting to get it through CI
and trying something new.

Anyways, to make the staged-deploy tests work we need a task
that actually uses `rpm-ostree override` rather than `usroverlay`.

Let's make this a bit saner and have a clean split between
tests that are "shell-script+usroverlay" and "ansible+override".

Closes: #1577
Approved by: jlebon
2018-05-04 19:25:32 +00:00
Colin Walters
956618a188 tests: Tweak staged-deploy test to be faster
Work around https://github.com/ostreedev/ostree/issues/1569

Closes: #1573
Approved by: jlebon
2018-05-04 13:06:37 +00:00
Colin Walters
5337ba51b2 lib/deploy: Do post-ops when removing staged commit
These are further fixes based on running more of the rpm-ostree
test suite.

When dropping the staged deployment, we do need to do the
"post operations" such as bumping the sysroot mtime, so that
clients know something changed.  We also need to regenerate
the deployment refs.  And of course do a sysroot reload.

Also, add a "base cleanup" after creating a staged deployment
which also regenerates the refs.

Closes: #1570
Approved by: jlebon
2018-05-02 16:22:34 +00:00
Colin Walters
25ba8db987 lib/deploy: Throw an error if trying to stage when not ostree-booted
There's no reason to do this.  I didn't actually hit this problem,
but it's a corner case that just occurred to me while working on
the code.

I think callers should be adapted to skip trying to use staging
if there's no booted deployment.

Closes: #1568
Approved by: jlebon
2018-05-02 13:27:01 +00:00
Colin Walters
36ac768fb7 repo: Add checksum to error message opening unreadable object
This would have debugged trying to do a pull as non-root from
a sysroot repository.  See for example:
https://github.com/ostreedev/ostree/issues/1562

Closes: #1564
Approved by: jlebon
2018-05-01 19:22:10 +00:00
Colin Walters
8c1542134c lib/repo: Enable locking by default, but drop external API
The code has been sitting around for a while but since I disabled
it by default, I doubt anyone is really using it or relying on it.

This patch and turns on locking by default, and also drops the
API which was only public in the experimental API builds.
Conceptually these are two distinct things, and we
may actually want to split up the patches.

I don't think this will break anyone, but it's hard to say for sure.
It's also going to be hard to find out until we actually release
I suspect...

But anyone who is broken should be able to add `locking=false` into
their repo config.  On the flip side Endless has been shipping with
this enabled and it is reported to help.

The reason to drop the APIs: I'm a bit concerned about the interactions over time
between libostree's use of the API and any apps that start using it.
For example, if an app specifies a SHARED lock in their code, then
later internally we decide to temporarily grab an `EXCLUSIVE`, but the
app had a second thread/process that was `EXCLUSIVE` already, and
that process was waiting on the first bit of code, then we could
deadlock. I can't think of a real world situation where this would happen
yet though.

We are likely to in the future have say `fsck` take an external lock,
`checkout` grab a shared one, etc.

Closes: #1555
Approved by: jlebon
2018-04-30 17:24:51 +00:00
Colin Walters
06d39efcb5 bin/deploy: Avoid loading merge deployment kargs unless necessary
The fact that `ostree admin deploy` always itself loaded the
merge kargs masked a bug in the core.  Let's change our tests
to not pass any kernel arguments to ensure we cover this.

The new logic in the CLI is a bit subtle, but if you read
carefully is a lot clearer I believe.  Basically we have one
of a few "starting points" in the first section, which can
then be further augmented.

Closes: #1558
Approved by: jlebon
2018-04-27 17:48:21 +00:00
Jonathan Lebon
dc4aa346a3 lib/deploy: Also compare deployment csum versions
When comparing deployments to determine whether we need a new
bootversion, we should also check whether the commit "version" metadata
is the same. Otherwise, we may end up with the a bootconfig whose
`title` includes a version that doesn't match the one from the
deployment checksum.

Closes: https://github.com/projectatomic/rpm-ostree/issues/1343

Closes: #1556
Approved by: cgwalters
2018-04-24 17:04:27 +00:00
Jonathan Lebon
8cfef187c5 tests: Port the last python2 script to python3
This is not used by any test, nor is it packaged. Though let's just port
it over to py3 to certify our codebase completely py2-free. I've
manually checked that the script is still functional.

Closes: #1546
Approved by: cgwalters
2018-04-23 18:33:45 +00:00
Jonathan Lebon
d56058bc9a tests/installed: Prefer python3 over python2
In a world progressively unapproving of python2, let's be a bit smarter
and support testing on platforms that only have python3 installed.

Closes: #1546
Approved by: cgwalters
2018-04-23 18:33:45 +00:00
Colin Walters
d4282720c7 tests: Disable itest-pull.sh since it is too slow
Hopefully we'll fix this soon.

Closes: #1548
Approved by: cgwalters
2018-04-23 17:23:40 +00:00
Colin Walters
76f3e603f9 tests: Lower retry timeout to 5s
No need to poll every second, there's going to be some latency
here and we want to avoid the overhead of polling.

Closes: #1548
Approved by: cgwalters
2018-04-23 17:23:40 +00:00
Colin Walters
41b97e9c12 fsck: Only print "marking commit partial" once
Let's only print if the commit isn't already partial; this
addresses a spam of "marking commit partial" from fsck.

Closes: #1548
Approved by: cgwalters
2018-04-23 17:23:40 +00:00
Jonathan Lebon
6d01d82b9b tests/installed: increase async retries to 500
It seems like 240 retries is just not long enough for all the
non-destructive tests running in parallel to finish. Let's crank that up
to 500 retries.

Closes: #1548
Approved by: cgwalters
2018-04-23 17:23:40 +00:00
Colin Walters
e5f6c9d1e2 tests/installed: Make reboot task less racy
This took a whole lot of experimentation.  I hit upon the idea
of doing a `systemctl stop sshd` to avoid the situation where we
might ssh back into the system while it's in the process of shutting
down.

Ultimately the other fix is disabling `ControlMaster`; see
for example: https://github.com/ansible/ansible/issues/17935

Closes: #1548
Approved by: cgwalters
2018-04-23 17:23:40 +00:00
Matthew Leeds
cf78888401 create-usb: Update summary in destination repo
Currently the create-usb command only generates a summary file in the
destination repo if one doesn't already exist, which means if one does
exist it becomes out of date after the new refs are pulled. This commit
makes ostree regenerate the summary regardless of whether it exists, so
that consumers such as ostree_repo_find_remotes_async() (and at a higher
level, GNOME Software) get an accurate picture of the refs available on
the mount. This commit also updates one of the unit tests to check that
the summary is accurate after a second pull into the same repo.

Since any user of the create-usb command is using collection IDs they
are new enough to be using the unsigned summary support. While it would
technically be possible to use summary signatures on a repo and use the
create-usb command on it (a scenario broken by this commit), the
create-usb command is designed for P2P distribution of refs, which
requires use of unsigned summary support. So this is a legitimate
narrowing of the tool.

Fixes https://github.com/ostreedev/ostree/issues/1465

Closes: #1543
Approved by: cgwalters
2018-04-19 13:35:15 +00:00
Matthew Leeds
653be1556d tests: Fix typo in unit test
Closes: #1543
Approved by: cgwalters
2018-04-19 13:35:15 +00:00
Colin Walters
16d3359bf8 lib/sysroot: Move staged into deployment list, rework handling
Followup to: https://github.com/ostreedev/ostree/pull/1503
After starting some more work on on this in rpm-ostree, it is
actually simpler if the staged deployment just shows up in the list.

It's effectively opt-in today; down the line we may make it the default,
but I worry about breaking things that e.g. assume they can mutate
the deployment before rebooting and have `/etc` already merged.

There's not that many things in libostree that iterate over the deployment
list.  The biggest change here is around the
`ostree_sysroot_write_deployments_with_options` API.  I initially
tried hard to support a use case like "push a rollback" while retaining
the staged deployment, but everything gets very messy because that
function truly is operating on the bootloader list.

For now what I settled on is to just discard the staged deployment;
down the line we can enhance things.

Where we then have some new gymnastics is around implementing
the finalization; we need to go to some effort to pull the staged
deployment out of the list and mark it as unstaged, and then pass
it down to `write_deployments()`.

Closes: #1539
Approved by: jlebon
2018-04-18 18:59:15 +00:00
Alexander Larsson
474556b955 fsck: Mark commits with missing or deleted object partial
This means we can later use various operations to heal the repository
because ostree does not assume all objects are there.

This the begining of a fix for https://github.com/ostreedev/ostree/pull/345

Closes: #1533
Approved by: cgwalters
2018-04-14 15:36:21 +00:00
Giuseppe Scrivano
cdaf7cd838 commit, payload-reflink: do not write to the parent repo
reintroduce the feature that was reverted with commit:

28c7bc6d0e153a0b07bdb82d25473a490765067f

Differently than the original implementation, now we don't attempt any
test for reflinks support on the parent repository, since the test
requires write access to the repository.

Additionally, also check that the two repositories are on the same
device before attempting any reflink.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1525
Approved by: cgwalters
2018-04-13 21:52:53 +00:00
Colin Walters
eb506c759c Add concept of "staged" deployment
Add API to write a deployment state to `/run/ostree/staged-deployment`,
along with a systemd service which runs at shutdown time.

This is a big change to the ostree model for hosts,
but it closes a longstanding set of bugs; many, many people have
hit the "losing changes in /etc" problem.  It also avoids
the other problem of racing with programs that modify `/etc`
such as LVM backups:
https://bugzilla.redhat.com/show_bug.cgi?id=1365297

We need this in particular to go to a full-on model for
automatically updated host systems where (like a dual-partition model)
everything is fully prepared and the reboot can be taken
asynchronously.

Closes: https://github.com/ostreedev/ostree/issues/545

Closes: #1503
Approved by: jlebon
2018-04-12 14:55:12 +00:00
Colin Walters
b9fc3eaa15 tests/installed: Move tasks into tasks/ directory
It's cleaner to separate test playbooks from their tasks.

Closes: #1535
Approved by: jlebon
2018-04-11 19:11:07 +00:00
Colin Walters
7357d346c4 tests: Better error message if target is not a symlink
I broke the code for this and ended up adding this to debug it.

Closes: #1535
Approved by: jlebon
2018-04-11 19:11:07 +00:00
Colin Walters
ab61f812c4 tests/installed: Move auto-build logic to playbook-run.sh
This makes it a bit more convenient to make a code change, then
`rm -rf build && ./playbook-run.sh ...`.

Closes: #1535
Approved by: jlebon
2018-04-11 19:11:07 +00:00
Colin Walters
5215f24e68 tests: Merge installed/ and fedora-str/ directories
Let's be opinionated now, and our installed/ test story *is*
Ansible/STR.  Merge `tests/fedora-str` into `tests/installed/`.

Rework the nondestructive tests into a separate playbook run, and parallelize
them for more efficiency.

The destructive tests are also changed to use Ansible more.

Add a higher level `run.sh` entrypoint and update the `README.md`
with some useful tips.

Closes: #1513
Approved by: jlebon
2018-04-05 20:59:23 +00:00
Matthew Leeds
cb3360fca6 lib/repo: Add timestamps to OstreeRepoFinderResult
Currently OstreeRepoFinderResult, a data structure used by pull code
that supports P2P operations, has a hash table mapping refs to checksums
but doesn't include timestamp information. This means that clients have
no way of knowing just from the OstreeRepoFinderResult information if a
commit being offered by a peer remote is an update or downgrade until
they start pulling it. The client could check the summary or the commit
metadata for the timestamps, but this requires adding the temporary
remotes to the repo config, and ostree is already checking timestamps
before returning the results, so I think it makes more sense for them to
be returned rather than leaving it to the client. This limitation is
especially important for offline computers, because for online computers
the latest commit available from any remote is the latest commit,
period.

This commit adds a "ref_to_timestamp" hash table to
OstreeRepoFinderResult that is symmetric to "ref_to_checksum" in that it
shares the same keys. This is an API break, but it's part of the
experimental API, and none of the current users of that (flatpak,
eos-updater, and gnome-software) are affected. See the documentation for
more details on "ref_to_timestamp". One thing to note is the data
structure currently gets initialized in find_remotes_cb(), so only users
of ostree_repo_find_remotes_async() will get them, not users of, say,
ostree_repo_finder_resolve_all_async(). This is because the individual
OstreeRepoFinder implementations don't currently access the timestamps
(but I think this could be changed in the future if there's a need).

This commit will allow P2P support to be added to
flatpak_installation_list_installed_refs_for_update, which will allow
GNOME Software to update apps from USB drives while offline (it's
already possible online).

Closes: #1518
Approved by: cgwalters
2018-04-03 15:50:40 +00:00
Matthew Leeds
925772eb09 tests: Fix unit test for ref-binding metadata
The `ostree show` command is currently failing due to incorrect syntax,
but we want to check that it fails because the metadata isn't there.

Closes: #1520
Approved by: cgwalters
2018-03-28 23:41:55 +00:00
Colin Walters
d379f87405 tests/installed: Fix TESTS= being empty
I broke this in 9b55aaea6f
I'd obviously tested *setting* it locally worked, but I didn't test that
not having it set ran all the tests.

I don't understand why we were doing the `+ ` pattern before; let's
just check if it's empty.

Closes: #1516
Approved by: jlebon
2018-03-26 19:02:54 +00:00
Colin Walters
246a7a5cc2 tests/payload-link: Just test a single duplicate object
We were previously assuming that the host content had duplicates,
which...hopefully it doesn't!  We shouldn't rely on that.

Also this test is slow in production and flaky.  Let's just test
a single duplicate object.

Closes: #1509
Approved by: jlebon
2018-03-22 19:01:52 +00:00
Colin Walters
d2c7c550c1 tests: Small tweaks for local iteration
Support e.g. `-e tests=payload-link`, to choose specific tests for more rapid
iteration, and allow skipping tmpdir cleanup to be able to debug.

Closes: #1509
Approved by: jlebon
2018-03-22 19:01:52 +00:00
Colin Walters
bb9cd1eb72 tests/installed: Use temporary directories more consistently
This is prep for splitting off "nondestructive" tests which
we can run in parallel from the destructive/invasive ones which
e.g. change the host refspec, do deployments.

The `cd` invocation in `prepare_tmpdir` wasn't working because we were running
it in a subshell. Fix this by dropping the subshell.

Closes: #1509
Approved by: jlebon
2018-03-22 19:01:52 +00:00
Colin Walters
dca1cfa60f tests/str: Verify standard-test-roles is installed
This tripped me up when regenerating my dev container.

Closes: #1509
Approved by: jlebon
2018-03-22 19:01:52 +00:00
Colin Walters
d48ccbcabf tests/str: Rework sysinstall-tests to be an entrypoint
Prep for creating more types of tests.

Move copying of `tests/` into the sysinstall-tests rather than `overlay-git`
as not all test types may need that.

Factored out of https://github.com/ostreedev/ostree/pull/1501

Closes: #1509
Approved by: jlebon
2018-03-22 19:01:52 +00:00
Colin Walters
671b026fcc Release 2018.3
It's been over a month since 2018.2; we have a few features and various fixes,
and the "stage" work pending which is pretty invasive. Time for a new release!

Closes: #1506
Approved by: jlebon
2018-03-21 16:01:41 +00:00
Jonathan Lebon
4e4436beec lib/fetcher: Allow clients to append to User-Agent
We do already have `http-headers`, which potentially could be used to
allow clients to completely override the field, but it seems like the
more common use case is simply to append.

Closes: #1496
Approved by: cgwalters
2018-03-16 19:21:31 +00:00
Jonathan Lebon
296ef25e12 lib/core: Support <remote>: syntax when listing refs
Allow users to pass `<remote>:` to list all refs we have locally
belonging to `<remote>`. Also (re-)allow the similar `<remote>:.` syntax
for backwards compatibility with flatpak.

Closes: #1500
Approved by: cgwalters
2018-03-16 19:18:08 +00:00
Colin Walters
10fb74025d tests/str: Rework invocation
Let's make our `run.sh` generically support any playbook. This is prep for
writing further tests in Ansible. Along with that, rework the Ansible so that
`tests.yml` is a playbook, and then the other bits are just task lists. It's
easier to read.

I also started to add a `use_git_build` variable with the idea that we'll be
able to run these same tests against an upstream image by setting that variable
off.

Closes: #1493
Approved by: jlebon
2018-03-16 13:26:22 +00:00
Colin Walters
79fc506284 tests: Avoid generating lots of output in itest-payload-link
We noticed this in a recent PR.  While I'm here, also only do
the `find` once, add `-type l` for good measure, and use our
built in `libtest.sh` assertion functions.

Closes: #1494
Approved by: giuseppe
2018-03-13 13:05:27 +00:00
Colin Walters
6e9d00dbeb ci: Rework installed tests to use Fedora Standard Test interface
Reusing the way `standard-test-roles` has support for booting
a qcow2 actually gets us to the "VM-in-container" flow.  Plus
Ansible over shell script is sometimes nicer.

https://fedoraproject.org/wiki/CI/Tests#Testing_an_Atomic_Host

It's better than what we were doing before for installed tests,
and moreover using Ansible more broadly for testing is going
to align us better with Fedora's CI.

As part of this I split off a "libpaprci" which I intend to maintain
as a "copylib" for a little bit between ostree/rpm-ostree, and then
we'll figure out how to expand from there (maybe some of the patterns
get "baked in" to PAPR for example).

Note the `FAH27-insttests` context moves to the top since it's now
of primary importance, and I expect that we start expanding it.

Closes: #1462
Approved by: jlebon
2018-03-08 20:51:42 +00:00
Giuseppe Scrivano
127d8bb846 commit: add logic for .payload-link
When a new object is added to the repository, create a
$PAYLOAD-SHA256.payload-link symlink file as well.  The target of the
symlink is the checksum of the object that was added the repository.

Whenever we add a new object file, in addition to lookup if the file is
already present with the same checksum we also check if an object with
the same payload is in the repository.

If a file with the same payload is already present in the repository, we
copy it with `glnx_regfile_copy_bytes` that internally attempts to
create a reflink (ioctl (..., FICLONE, ..)) to the target file if the
file system supports it.  This enables to have objects that share the
payload but have a different inode and xattrs.

By default the payload-link-threshold value is G_MAXUINT64 that disables
the feature.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1443
Approved by: cgwalters
2018-03-07 18:28:59 +00:00
Colin Walters
969e4eb72e repo/refs: Clean up error prefixing
Add some "function global" prefixing in line with what we do in
other places now, and drop the "manual filename" prefixing that
is no longer necessary since
23f7df1500

Closes: https://github.com/ostreedev/ostree/issues/1467

Closes: #1485
Approved by: jlebon
2018-03-06 14:01:39 +00:00
Colin Walters
79d6f635df prune: Error if --static-deltas-only without --delete-commit
The original changes here apparently had the *idea* that `--static-deltas-only`
would be useful in general, but we never implemented that.  The current
situation where it's ignored unless `--delete-commit` is specified is
very misleading and I can easily see it leading to data loss for people.

Let's error out until we have a chance to make it actually useful.

Related: https://github.com/ostreedev/ostree/issues/1479

Closes: #1482
Approved by: giuseppe
2018-03-05 17:39:35 +00:00
Colin Walters
733c0498dc lib/repo: Do account for size with prune --no-prune
I think this got changed in a refactor.  We definitely want
to total up the amount of space that *would* be freed even
with `--no-prune` AKA `OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE`.

It's actually a bit terrifying this is apparently the first test case for
the `--no-prune` option...

Closes: https://github.com/ostreedev/ostree/issues/1480

Closes: #1483
Approved by: jlebon
2018-03-05 16:58:12 +00:00
Colin Walters
7f88fddcd4 sysroot: Add concept of deployment "pinning" 📌
Example user story: Jane rebases her OS to a new major version N, and wants to
keep around N-1 even after a few upgrades for a while so she can easily roll
back. I plan to add `rpm-ostree rebase --pin` to opt-in to this for example.

Builds on the new `libostree-transient` group to store pinning state there.

Closes: https://github.com/ostreedev/ostree/issues/1460

Closes: #1464
Approved by: jlebon
2018-02-26 19:06:59 +00:00
Simon McVittie
971265e4e4 Use Python 3 for tests
Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #1463
Approved by: cgwalters
2018-02-23 22:49:06 +00:00
Simon McVittie
6cabeaed3f tests/bootloader-entries-crosscheck: Use Python 3-friendly sorting
This is a little clearer than a strcmp()-style negative/zero/positive
return, and also works in Python 2.

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

Closes: #1457
Approved by: cgwalters
2018-02-22 19:24:47 +00:00