Skip to content

Commit

Permalink
Add deploy-via-container key for image.yaml
Browse files Browse the repository at this point in the history
This builds on the `image-format: oci` key to switch to using
the new ostree-container code to do the deployment (via rpm-ostree).

Unlike the above though, this is not something we can turn on
by default until we intend to hard cut over to fetching updates
via containers.

The intention is to use this to produce image builds that are
initially provisioned via a container image so that we can more
easily experiment with the "container native" flow.

A side note; I suspect this will indirectly fix
openshift/os#594
because now we're opening a single large file and pulling that
over virtio instead of lots of smaller files.
  • Loading branch information
cgwalters committed Oct 28, 2021
1 parent 99bd472 commit 809093e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
6 changes: 6 additions & 0 deletions src/cmd-buildextend-metal
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ cat image-default.json "${image_json}" | jq -s add > image-configured.json
# We do some extra handling of the rootfs here; it feeds into size estimation.
rootfs_type=$(jq -re .rootfs < image-configured.json)

deploy_container=
if jq -re '.["deploy-via-container"]' < image-configured.json >/dev/null; then
deploy_container=ostree-unverified-image:oci-archive:$builddir/$(meta_key images.ostree.path)
fi

# fs-verity requires block size = page size. We need to take that into account
# in the disk size estimation due to higher fragmentation on larger blocks.
BLKSIZE=""
Expand Down Expand Up @@ -204,6 +209,7 @@ cat >image-dynamic.json << EOF
"osname": "${name}",
"buildid": "${build}",
"imgid": "${img}",
"deploy-container": "${deploy_container}",
"ostree-commit": "${commit}",
"ostree-ref": "${ref}",
"ostree-repo": "${ostree_repo}"
Expand Down
48 changes: 33 additions & 15 deletions src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ commit=$(getconfig "ostree-commit")
ref=$(getconfig "ostree-ref")
# We support not setting a remote name (used by RHCOS)
remote_name=$(getconfig_def "ostree-remote" "")
deploy_container=$(getconfig "deploy-container" "")
os_name=$(getconfig "osname")
rootfs_size=$(getconfig "rootfs-size")
buildid=$(getconfig "buildid")
Expand Down Expand Up @@ -249,28 +250,45 @@ fi
ostree admin init-fs --modern $rootfs
# Initialize the "stateroot"
ostree admin os-init "$os_name" --sysroot $rootfs

# Propagate flags into target repository
if [ "${rootfs_type}" = "ext4verity" ]; then
ostree config --repo=$rootfs/ostree/repo set ex-fsverity.required 'true'
fi
time ostree pull-local --repo $rootfs/ostree/repo "$ostree" "$commit"
if test -n "${remote_name}"; then
deploy_ref="${remote_name}:${ref}"
ostree refs --repo $rootfs/ostree/repo --create "${deploy_ref}" "${commit}"
else
deploy_ref=$commit
fi

# Compute kargs
# Note that $ignition_firstboot is interpreted by grub at boot time,
# *not* the shell here. Hence the backslash escape.
allkargs="$extrakargs \$ignition_firstboot"
kargsargs=""
for karg in $allkargs
do
kargsargs+="--karg-append=$karg "
done
ostree admin deploy "${deploy_ref}" --sysroot $rootfs --os "$os_name" $kargsargs

deploy_root="$rootfs/ostree/deploy/${os_name}/deploy/${commit}.0"
test -d "${deploy_root}"
if test -n "${deploy_container}"; then
kargsargs=""
for karg in $allkargs
do
kargsargs+="--karg=$karg "
done
rpm-ostree ex-container image deploy --imgref "${deploy_container}" --stateroot "$os_name" --sysroot $rootfs $kargsargs
deploy_root=$(ls -d $rootfs/ostree/deploy/${os_name}/deploy/*.0)
test -d "${deploy_root}"
else
# Pull the commit
time ostree pull-local --repo $rootfs/ostree/repo "$ostree" "$commit"
# Deploy it, using an optional remote prefix
if test -n "${remote_name}"; then
deploy_ref="${remote_name}:${ref}"
ostree refs --repo $rootfs/ostree/repo --create "${deploy_ref}" "${commit}"
else
deploy_ref=$commit
fi
kargsargs=""
for karg in $allkargs
do
kargsargs+="--karg-append=$karg "
done
ostree admin deploy "${deploy_ref}" --sysroot $rootfs --os "$os_name" $kargsargs
deploy_root="$rootfs/ostree/deploy/${os_name}/deploy/${commit}.0"
test -d "${deploy_root}"
fi

# This will allow us to track the version that an install
# originally used; if we later need to understand something
Expand Down
2 changes: 2 additions & 0 deletions src/image-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
bootfs: "ext4"
rootfs: "xfs"
grub-script: "/usr/lib/coreos-assembler/grub.cfg"
# True if we should use `rpm-ostree ex-container deploy`
deploy-via-container: false

0 comments on commit 809093e

Please sign in to comment.