Skip to content

Conversation

@cgwalters
Copy link
Member

@cgwalters cgwalters commented Apr 18, 2020

Part of the implementation of
#1341

This is useful for me hacking on ostree/rpm-ostree. Here we
don't need to regenerate the initramfs (usually), we just want
new ostree binaries in /usr. But we do want the OS to be
set up as a "proper" OSTree commit, i.e. not rpm-ostree usroverlay.

Here this completes a qemu image (overlaid on previous) in 13 seconds,
compared to 147 seconds for a full build; 11x faster and we're
not writing O(sizeof(coreos)) bytes to my SSD, but
O(sizeof(change) + sizeof(metadata(coreos)).

With this a workflow looks like:

$ cd /src/ostree
$ make && make install DESTDIR=/path/to/cosa/overrides/rootfs
$ cd /path/to/cosa
$ cosa build-fast
$ cosa run --qemu-image tmp/fastbuild/fastbuild-qemu.qcow2

(Or, instead of cosa run, cosa kola run --qemu-image tmp/fastbuild/fastbuild-qemu.qcow2 -E /src/ostree ext.ostree.*)

@cgwalters cgwalters mentioned this pull request Apr 18, 2020
@cgwalters cgwalters force-pushed the build-qemu-fast branch 2 times, most recently from dc6cd53 to 35b5a83 Compare April 18, 2020 20:03
@cgwalters
Copy link
Member Author

OK whee I just had my first "oh wait this doesn't work because I used build-fast" moment - I was working on a new systemd unit in the target root stored in the overlays and updated the .preset file and tried to hack things by rsync -rlv src/config/overlay.d/foo/ overrides/rootfs - but we only running the systemctl preset-all in the postprocess, which this skips. So my unit was silently not enabled.

But...eh, we can expand on this as needed.

@cgwalters cgwalters force-pushed the build-qemu-fast branch 2 times, most recently from 9190c6f to 65edf3c Compare April 22, 2020 14:58
@cgwalters
Copy link
Member Author

OK I now updated this to run in another mode that more clearly replaces rpm-ostree's make vmoverlay - if you e.g.
cd /path/to/ostree.git && env COSA_DIR=/path/to/fcos cosa build-fast you will end up with the qemu image in the ostree working directory, and you don't need to think about the make install DESTDIR= part. It's a bit like having per-project coreos-assembler branches.

xref coreos/rpm-ostree#1958

@cgwalters
Copy link
Member Author

Bigger picture, this PR is trying to add to coreos-assembler the concept of a "project source directory" that doesn't currently exist aside from the src/config.

I worked on this PR in parallel with this script in ostree:
https://github.com/ostreedev/ostree/pull/2048/files#diff-893bbb0a1a54c74c3f41b00641d40909

Because again an important goal is "edit $project (ostree, igntition, etc.); build fast dev qemu image, run project tests" while still supporting "run project tests" outside of building the project.

Tying these two things together for example, if this lands I'd probably change runkola.sh in ostree's tests to glob for fastbuild*.qcow2 or so.

I dunno though. Maybe it is cleaner to have something like:

$ ln -sr /path/to/ostree overrides/src

Then you always live inside the cosa workdir, and it becomes much more obvious how to work on multiple projects.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff! I like the project dir approach.

ISTM like we'll want the OSTree parts of logic in rpm-ostree instead at some point, e.g. rpm-ostree compose overlay or something? Then we get things like initrd regeneration and the /etc move thing more easily. (This would be helpful too for eventually implementing coreos/rpm-ostree#442.)

# Depends https://github.com/ostreedev/ostree/pull/2041/commits/b3bbbd154225e81980546b2c0b5ed98714830696
version="fastbuild-$(date +"%s")"
if [ -n "${projectdir}" ]; then
cd "${projectdir}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is minor/an aside, though in non-trivial shell scripts like this I find it conceptually easier to just always stay in the same directory and do anything that really needs a cd in a subshell.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But everything after that is in the project dir?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it seemed to me like all the paths used were absolute in the ${projectdir} case.

Part of the implementation of
coreos#1341

This is useful for me hacking on ostree/rpm-ostree.  Here we
don't need to regenerate the initramfs (usually), we just want
new ostree binaries in `/usr`.  But we *do* want the OS to be
set up as a "proper" OSTree commit, i.e. not `rpm-ostree usroverlay`.

Here this completes a qemu image (overlaid on previous) in 11 seconds,
compared to 147 seconds for a full build; ~13x faster *and* we're
not writing `O(sizeof(coreos))` bytes to my SSD, but
`O(sizeof(change) + sizeof(metadata(coreos))`.

With this a workflow looks like:
```
$ cd /src/ostree
$ make && make install DESTDIR=/path/to/cosa/overrides/rootfs
$ cd /path/to/cosa
$ cosa build-fast
$ cosa run --qemu-image tmp/fastbuild/fastbuild-qemu.qcow2
```

(Or, instead of `cosa run`, `cosa kola run --qemu-image fastbuild/fastbuild-qemu.qcow2 -E /src/ostree ext.ostree.*`)

You can also use this inside a project directory by setting `COSA_DIR`.
@jlebon
Copy link
Member

jlebon commented Apr 23, 2020

/lgtm

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cgwalters, jlebon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 3914883 into coreos:master Apr 23, 2020
@cgwalters
Copy link
Member Author

ISTM like we'll want the OSTree parts of logic in rpm-ostree instead at some point, e.g. rpm-ostree compose overlay or something?

Definitely, I have a local branch for that with some hacks but...it has a similar problem to trying to do this in the main coreos-assembler path in that it's super messy to add a bunch of "skip this, skip that, hack this" steps into the main code flow.

cgwalters added a commit to cgwalters/ostree that referenced this pull request Apr 29, 2020
I'm using [cosa build-fast](coreos/coreos-assembler#1371)
and this test doesn't like starting out with two deployments.  Clean
things up to one at the start just to simplify things.
cgwalters added a commit to cgwalters/ostree that referenced this pull request Apr 29, 2020
I'm using [cosa build-fast](coreos/coreos-assembler#1371)
and this test doesn't like starting out with two deployments.  Clean
things up to one at the start just to simplify things.
cgwalters added a commit to cgwalters/coreos-assembler that referenced this pull request May 8, 2020
This is parallel to [build-fast](coreos#1371)
which is about quickly iterating on userspace.

Here is the opposite - we just want to take our new code and
get it into the initramfs as fast as possible.  An example use
is demonstrated in the comment at the top of the file.

Here this takes about 5 seconds to run, which is fast enough
that at least I would probably stay at the terminal and not e.g.
context switch to code review or check Twitter or whatever.
cgwalters added a commit to cgwalters/coreos-assembler that referenced this pull request May 8, 2020
This is parallel to [build-fast](coreos#1371)
which is about quickly iterating on userspace.

Here is the opposite - we just want to take our new code and
get it into the initramfs as fast as possible.  An example use
is demonstrated in the comment at the top of the file.

Here this takes about 5 seconds to run, which is fast enough
that at least I would probably stay at the terminal and not e.g.
context switch to code review or check Twitter or whatever.
cgwalters added a commit to cgwalters/coreos-assembler that referenced this pull request May 8, 2020
This is parallel to [build-fast](coreos#1371)
which is about quickly iterating on userspace.

Here is the opposite - we just want to take our new code and
get it into the initramfs as fast as possible.  An example use
is demonstrated in the comment at the top of the file.

Here this takes about 5 seconds to run, which is fast enough
that at least I would probably stay at the terminal and not e.g.
context switch to code review or check Twitter or whatever.
openshift-merge-robot pushed a commit that referenced this pull request May 11, 2020
This is parallel to [build-fast](#1371)
which is about quickly iterating on userspace.

Here is the opposite - we just want to take our new code and
get it into the initramfs as fast as possible.  An example use
is demonstrated in the comment at the top of the file.

Here this takes about 5 seconds to run, which is fast enough
that at least I would probably stay at the terminal and not e.g.
context switch to code review or check Twitter or whatever.
agners pushed a commit to agners/ostree that referenced this pull request May 29, 2020
I'm using [cosa build-fast](coreos/coreos-assembler#1371)
and this test doesn't like starting out with two deployments.  Clean
things up to one at the start just to simplify things.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants