Skip to content

Commit faed8f3

Browse files
committed
Add deploy-via-container and container-imgref keys for image.yaml
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.
1 parent d1eefa4 commit faed8f3

File tree

3 files changed

+46
-13
lines changed

3 files changed

+46
-13
lines changed

src/cmd-buildextend-metal

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ cat image-default.json "${image_json}" | jq -s add > image-configured.json
139139
# We do some extra handling of the rootfs here; it feeds into size estimation.
140140
rootfs_type=$(jq -re .rootfs < image-configured.json)
141141

142+
deploy_container=
143+
container_imgref=$(jq -r '.["container-imgref"]//""' < image-configured.json)
144+
if test -n "${container_imgref}" || jq -re '.["deploy-via-container"]' < image-configured.json >/dev/null; then
145+
deploy_container=ostree-unverified-image:oci-archive:$builddir/$(meta_key images.ostree.path)
146+
fi
147+
142148
# fs-verity requires block size = page size. We need to take that into account
143149
# in the disk size estimation due to higher fragmentation on larger blocks.
144150
BLKSIZE=""
@@ -204,6 +210,8 @@ cat >image-dynamic.json << EOF
204210
"osname": "${name}",
205211
"buildid": "${build}",
206212
"imgid": "${img}",
213+
"deploy-container": "${deploy_container}",
214+
"container-imgref": "${container_imgref}",
207215
"ostree-commit": "${commit}",
208216
"ostree-ref": "${ref}",
209217
"ostree-repo": "${ostree_repo}"

src/create_disk.sh

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ commit=$(getconfig "ostree-commit")
9999
ref=$(getconfig "ostree-ref")
100100
# We support not setting a remote name (used by RHCOS)
101101
remote_name=$(getconfig_def "ostree-remote" "")
102+
deploy_container=$(getconfig "deploy-container" "")
103+
container_imgref=$(getconfig "container-imgref" "")
102104
os_name=$(getconfig "osname")
103105
rootfs_size=$(getconfig "rootfs-size")
104106
buildid=$(getconfig "buildid")
@@ -249,26 +251,45 @@ fi
249251
ostree admin init-fs --modern $rootfs
250252
# Initialize the "stateroot"
251253
ostree admin os-init "$os_name" --sysroot $rootfs
254+
255+
# Propagate flags into target repository
252256
if [ "${rootfs_type}" = "ext4verity" ]; then
253257
ostree config --repo=$rootfs/ostree/repo set ex-fsverity.required 'true'
254258
fi
255-
time ostree pull-local --repo $rootfs/ostree/repo "$ostree" "$commit"
256-
if test -n "${remote_name}"; then
257-
deploy_ref="${remote_name}:${ref}"
258-
ostree refs --repo $rootfs/ostree/repo --create "${deploy_ref}" "${commit}"
259-
else
260-
deploy_ref=$commit
261-
fi
259+
260+
# Compute kargs
262261
# Note that $ignition_firstboot is interpreted by grub at boot time,
263262
# *not* the shell here. Hence the backslash escape.
264263
allkargs="$extrakargs \$ignition_firstboot"
265-
kargsargs=""
266-
for karg in $allkargs
267-
do
268-
kargsargs+="--karg-append=$karg "
269-
done
270-
ostree admin deploy "${deploy_ref}" --sysroot $rootfs --os "$os_name" $kargsargs
271264

265+
if test -n "${deploy_container}"; then
266+
kargsargs=""
267+
for karg in $allkargs
268+
do
269+
kargsargs+="--karg=$karg "
270+
done
271+
rpm-ostree ex-container image deploy --imgref "${deploy_container}" \
272+
${container_imgref:+--target-imgref $container_imgref} \
273+
--stateroot "$os_name" --sysroot $rootfs $kargsargs
274+
else
275+
# Pull the commit
276+
time ostree pull-local --repo $rootfs/ostree/repo "$ostree" "$commit"
277+
# Deploy it, using an optional remote prefix
278+
if test -n "${remote_name}"; then
279+
deploy_ref="${remote_name}:${ref}"
280+
ostree refs --repo $rootfs/ostree/repo --create "${deploy_ref}" "${commit}"
281+
else
282+
deploy_ref=$commit
283+
fi
284+
kargsargs=""
285+
for karg in $allkargs
286+
do
287+
kargsargs+="--karg-append=$karg "
288+
done
289+
ostree admin deploy "${deploy_ref}" --sysroot $rootfs --os "$os_name" $kargsargs
290+
fi
291+
# Note that at the current time, this only supports deploying non-layered
292+
# container images; xref https://github.com/ostreedev/ostree-rs-ext/issues/143
272293
deploy_root="$rootfs/ostree/deploy/${os_name}/deploy/${commit}.0"
273294
test -d "${deploy_root}"
274295

src/image-default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
bootfs: "ext4"
33
rootfs: "xfs"
44
grub-script: "/usr/lib/coreos-assembler/grub.cfg"
5+
# True if we should use `rpm-ostree ex-container image deploy`
6+
deploy-via-container: false
7+
# Set this to a target container reference, e.g. ostree-unverified-registry:quay.io/example/os:latest
8+
# container-imgref: ""

0 commit comments

Comments
 (0)