@@ -154,44 +154,52 @@ getconfig_def() {
154154 jq -re .\" " $k " \" //\" " ${default} " \" < " ${config} "
155155}
156156
157- # Grab a few values from ${image_json}
158- deploy_via_container=$( getconfig_def " deploy-via-container" " " " ${image_json} " )
159- extra_kargs=" $( python3 -c ' import sys, json; args = json.load(sys.stdin)["extra-kargs"]; print(" ".join(args))' < " ${image_json} " ) "
160-
161- # OStree container ociarchive file path
162- ostree_container=" ${builddir} /$( meta_key images.ostree.path) "
163- # If no container_imgref was set let's just set it to some professional
164- # looking default. The name of the ociarchive file should suffice.
165- container_imgref_default=" ostree-image-signed:oci-archive:/$( basename " ${ostree_container} " ) "
166- container_imgref=$( getconfig_def " container_imgref" " ${container_imgref_default} " " ${image_json} " )
167-
168- echo " Estimating disk size..."
169- # The additional 35% here is obviously a hack, but we can't easily completely fill the filesystem,
170- # and doing so has apparently negative performance implications.
171- ostree_size_json=" $( /usr/lib/coreos-assembler/estimate-commit-disk-size --repo " $ostree_repo " " $commit " --add-percent 35) "
172- rootfs_size_mb=" $( jq ' ."estimate-mb".final' <<< " ${ostree_size_json}" ) "
173- # The minimum size of a disk image we'll need will be the rootfs_size
174- # estimate plus the size of the non-root partitions. We'll use this
175- # size for the metal images, but for the IaaS/virt image we'll use
176- # the size set in the configs since some of them have minimum sizes that
177- # the platforms require and we want a "default" disk size that has some
178- # free space.
179- nonroot_partition_sizes=513
180- # On s390x there is one more build - Secure Execution case, which has
181- # different image layout. We add the sizes of the se and verity
182- # partitions so that they don't "eat into" the 35% buffer (though note
183- # this is all blown away on first boot anyway). For 's390x.mpp.yaml'
184- # simplicity all s390x images have same size (of secex image).
185- if [[ $basearch == " s390x" ]]; then
186- nonroot_partition_sizes=$(( nonroot_partition_sizes + 200 + 128 + 256 + 1 ))
187- fi
188- metal_image_size_mb=" $(( rootfs_size_mb + nonroot_partition_sizes )) "
189- cloud_image_size_mb=" $( jq -r " .size*1024" < " ${image_json} " ) "
190- echo " Disk sizes: metal: ${metal_image_size_mb} M (estimated), cloud: ${cloud_image_size_mb} M"
157+ # Here we generate the input JSON we pass to runvm_osbuild for all of our image builds
158+ generate_runvm_osbuild_config () {
159+ runvm_osbuild_config_json=" ${workdir} /tmp/runvm-osbuild-config-${build} .json"
160+ echo " ${runvm_osbuild_config_json} " # Let the caller know where the config will be
161+ if [ -f " ${runvm_osbuild_config_json} " ]; then
162+ return # only need to generate this once per build
163+ fi
164+ rm -f ${workdir} /tmp/runvm-osbuild-config-* .json # clean up any previous configs
165+
166+ # Grab a few values from $image_json
167+ deploy_via_container=$( getconfig_def " deploy-via-container" " " " ${image_json} " )
168+ extra_kargs=" $( python3 -c ' import sys, json; args = json.load(sys.stdin)["extra-kargs"]; print(" ".join(args))' < " ${image_json} " ) "
169+
170+ # OStree container ociarchive file path
171+ ostree_container=" ${builddir} /$( meta_key images.ostree.path) "
172+ # If no container_imgref was set let's just set it to some professional
173+ # looking default. The name of the ociarchive file should suffice.
174+ container_imgref_default=" ostree-image-signed:oci-archive:/$( basename " ${ostree_container} " ) "
175+ container_imgref=$( getconfig_def " container_imgref" " ${container_imgref_default} " " ${image_json} " )
191176
192- # Generate the JSON describing the disk we want to build
193- runvm_osbuild_config_json=" ${tmp_builddir} /runvm-osbuild-config.json"
194- yaml2json /dev/stdin " ${runvm_osbuild_config_json} " << EOF
177+ echo " Estimating disk size..." & > 2
178+ # The additional 35% here is obviously a hack, but we can't easily completely fill the filesystem,
179+ # and doing so has apparently negative performance implications.
180+ ostree_size_json=" $( /usr/lib/coreos-assembler/estimate-commit-disk-size --repo " $ostree_repo " " $commit " --add-percent 35) "
181+ rootfs_size_mb=" $( jq ' ."estimate-mb".final' <<< " ${ostree_size_json}" ) "
182+ # The minimum size of a disk image we'll need will be the rootfs_size
183+ # estimate plus the size of the non-root partitions. We'll use this
184+ # size for the metal images, but for the IaaS/virt image we'll use
185+ # the size set in the configs since some of them have minimum sizes that
186+ # the platforms require and we want a "default" disk size that has some
187+ # free space.
188+ nonroot_partition_sizes=513
189+ # On s390x there is one more build - Secure Execution case, which has
190+ # different image layout. We add the sizes of the se and verity
191+ # partitions so that they don't "eat into" the 35% buffer (though note
192+ # this is all blown away on first boot anyway). For 's390x.mpp.yaml'
193+ # simplicity all s390x images have same size (of secex image).
194+ if [[ $basearch == " s390x" ]]; then
195+ nonroot_partition_sizes=$(( nonroot_partition_sizes + 200 + 128 + 256 + 1 ))
196+ fi
197+ metal_image_size_mb=" $(( rootfs_size_mb + nonroot_partition_sizes )) "
198+ cloud_image_size_mb=" $( jq -r " .size*1024" < " ${image_json} " ) "
199+ echo " Disk sizes: metal: ${metal_image_size_mb} M (estimated), cloud: ${cloud_image_size_mb} M" & > 2
200+
201+ # Generate the JSON describing the disk we want to build
202+ yaml2json /dev/stdin " ${runvm_osbuild_config_json} " << EOF
195203container-imgref: "${container_imgref} "
196204deploy-via-container: "${deploy_via_container} "
197205osname: "${name} "
@@ -205,6 +213,7 @@ cloud-image-size: "${cloud_image_size_mb}"
205213# not the last partition on the disk so we need to explicitly size it
206214rootfs-size: "${rootfs_size_mb} "
207215EOF
216+ }
208217
209218# In the jenkins pipelines we build the qemu image first and that operation
210219# will do a lot of the same work required for later artifacts (metal, metal4k, etc)
213222# so for those we'll set `snapshot=on` so that each will get their own disk image.
214223# This is OK because we don't checkpoint (cache) any of those stages.
215224[ " ${image_type} " == " qemu" ] && snapshot=" off" || snapshot=" on"
225+ runvm_osbuild_config_json=" $( generate_runvm_osbuild_config) "
216226runvm_with_cache_snapshot " $snapshot " -- /usr/lib/coreos-assembler/runvm-osbuild \
217227 --config " ${runvm_osbuild_config_json} " \
218228 --mpp " /usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.${basearch} .mpp.yaml" \
0 commit comments