Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove code invoking Anaconda to build disk images #835

Merged
merged 1 commit into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ RUN ./build.sh install_rpms
# Ok copy in the rest of them for the next few steps
COPY ./ /root/containerbuild/
RUN ./build.sh write_archive_info
RUN ./build.sh install_anaconda
RUN ./build.sh make_and_makeinstall
RUN ./build.sh configure_user

Expand Down
54 changes: 0 additions & 54 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,59 +89,6 @@ _prep_make_and_make_install() {
fi
}

# For now keep using the f29 anaconda. There's no golden f30 image yet and it
# doesn't support the installclass stuff and hopefully we'll stop using it soon.
installer_release=29

# Download url is different for primary and secondary fedora
# Primary Fedora - https://download.fedoraproject.org/pub/fedora/linux/releases/
# Secondary Fedora - https://download.fedoraproject.org/pub/fedora-secondary/releases/
declare -A repository_dirs
repository_dirs[aarch64]=fedora/linux
repository_dirs[armhfp]=fedora/linux
repository_dirs[x86_64]=fedora/linux
repository_dirs[ppc64le]=fedora-secondary
repository_dirs[s390x]=fedora-secondary

repository_dir=${repository_dirs[$arch]}
INSTALLER=https://download.fedoraproject.org/pub/$repository_dir/releases/$installer_release/Everything/$arch/iso/Fedora-Everything-netinst-$arch-$installer_release-1.2.iso
INSTALLER_CHECKSUM=https://download.fedoraproject.org/pub/$repository_dir/releases/$installer_release/Everything/$arch/iso/Fedora-Everything-$installer_release-1.2-$arch-CHECKSUM

install_anaconda() {
if [ "$arch" == "x86_64" ]; then
return
fi

# Overriding install URL
if [ -n "${INSTALLER_URL_OVERRIDE-}" ]; then
INSTALLER="${INSTALLER_URL_OVERRIDE}"
echo "info: Overriding the install URL with contents of INSTALLER_URL_OVERRIDE"
fi
# Overriding install checksum URL
if [ -n "${INSTALLER_CHECKSUM_URL_OVERRIDE-}" ]; then
INSTALLER_CHECKSUM="${INSTALLER_CHECKSUM_URL_OVERRIDE}"
echo "info: Overriding the install checksum URL with contents of INSTALLER_CHECKSUM_URL_OVERRIDE"
fi

installer_bn=$(basename "${INSTALLER}")
checksums_bn=$(basename "${INSTALLER_CHECKSUM}")

anacondadir=/usr/lib/coreos-assembler-anaconda
if ! [ -f "${anacondadir}/${installer_bn}" ]; then
(
mkdir -p $anacondadir
cd $anacondadir
rm tmp -rf && mkdir -p tmp
cd tmp
curl -L --remote-name-all "${INSTALLER}" "${INSTALLER_CHECKSUM}"
sha256sum -c "${checksums_bn}"
mv "${installer_bn}" "${checksums_bn}" ..
cd ..
rmdir tmp
)
fi
}

make_and_makeinstall() {
_prep_make_and_make_install
make && make install
Expand Down Expand Up @@ -183,7 +130,6 @@ else
configure_yum_repos
install_rpms
write_archive_info
install_anaconda
make_and_makeinstall
configure_user
fi
2 changes: 1 addition & 1 deletion src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ if [ -n "${previous_commit}" ]; then
fi
fi

# and point the ref to it if there isn't one already (in which case it might be newer, but e.g. Anaconda failed)
# and point the ref to it if there isn't one already (in which case it might be newer, but e.g. creating disk failed)
if ! ostree rev-parse --repo="${tmprepo}" "${ref}" &>/dev/null; then
ostree refs --repo="${tmprepo}" --create "${ref}" "${previous_commit}"
fi
Expand Down
83 changes: 28 additions & 55 deletions src/cmd-buildextend-metal
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,8 @@ if [ $# -ne 0 ]; then
fi

case "$basearch" in
"x86_64"|"aarch64"|"s390x"|"ppc64le") use_anaconda=;;
*)
# for qemu, we can fallback to Anaconda
if [[ ${image_type} == qemu ]]; then
use_anaconda=1
else
# otherwise, we don't know how to create bare metal images for this
# architecture
fatal "$basearch is not supported for this command"
fi
;;
"x86_64"|"aarch64"|"s390x"|"ppc64le") ;;
*) fatal "$basearch is not supported for this command" ;;
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, would it make sense to just move it somewhere near the top of cmdlib.sh and have a more generic error?

Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly - though I'd like to keep this PR scoped to mostly just deleting code so we can back it out more easily if need be.

However, thinking about this one more - it feels a bit harsh to people porting to other architectures if we make cosa refuse to work at all, versus just the disk image building part. So I think this probably makes sense here still.

esac

if [[ "$basearch" != "s390x" && $image_type == dasd ]]; then
Expand Down Expand Up @@ -176,51 +167,33 @@ ostree_remote="$(python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin).g
save_var_subdirs="$(python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin).get("save-var-subdirs-for-selabel-workaround", "NONE"))' < "$configdir/image.yaml")"
luks_flag="$(python3 -c 'import sys, yaml; lf=yaml.safe_load(sys.stdin).get("luks_rootfs", ""); print("--luks-rootfs" if lf.lower() in ("yes", "true") else "")' < "$configdir/image.yaml")"


if [ -z "${use_anaconda}" ]; then
qemu-img create -f ${image_format} "${path}.tmp" "$size"
# In the anaconda path, run_virtinstall dereferences in the ref_is_temp
# case. Here, we need to dereference ourselves.
ref_arg=${ref}
if [ -n "${ref_is_temp}" ]; then
ref_arg=${commit}
fi
target_drive=("-drive" "if=virtio,id=target,format=${image_format},file=${path}.tmp")
if [[ $image_format == raw && $image_type == dasd ]]; then
target_drive=("-drive" "if=none,id=target,format=${image_format},file=${path}.tmp" \
# we need 4096 block size for ECKD DASD
"-device" "virtio-blk-ccw,drive=target,physical_block_size=4096,logical_block_size=4096,scsi=off")
fi
runvm "${target_drive[@]}" -- \
/usr/lib/coreos-assembler/create_disk.sh \
--disk /dev/vda \
--buildid "${build}" \
--imgid "${img}" \
--grub-script /usr/lib/coreos-assembler/grub.cfg \
--kargs "\"${kargs}\"" \
--osname "${name}" \
--ostree-ref "${ref_arg}" \
--ostree-remote "${ostree_remote}" \
--ostree-repo "${ostree_repo}" \
--save-var-subdirs "${save_var_subdirs}" \
"${luks_flag}"
mv "${path}.tmp" "$path"
echo "{}" > tmp/vm-iso-checksum.json
else
[ "${image_type}" == qemu ]
mkdir -p tmp/anaconda
# forgive me for this sin
checksum_location=$(find /usr/lib/coreos-assembler-anaconda/ -name '*CHECKSUM' | head -1)
img_base=tmp/${name}-${build}-base.qcow2
run_virtinstall "${ostree_repo}" "${ref}" "${PWD}"/"${img_base}" --variant=cloud
/usr/lib/coreos-assembler/gf-platformid "$(pwd)"/"${img_base}" "${path}" qemu
vm_iso_checksum=$(awk '/SHA256.*iso/{print$NF}' "${checksum_location}")
cat > tmp/vm-iso-checksum.json <<EOF
{
"coreos-assembler.vm-iso-checksum": "${vm_iso_checksum}"
}
EOF
qemu-img create -f ${image_format} "${path}.tmp" "$size"
# We support deploying a commit directly instead of a ref
ref_arg=${ref}
if [ -n "${ref_is_temp}" ]; then
ref_arg=${commit}
fi
target_drive=("-drive" "if=virtio,id=target,format=${image_format},file=${path}.tmp")
if [[ $image_format == raw && $image_type == dasd ]]; then
target_drive=("-drive" "if=none,id=target,format=${image_format},file=${path}.tmp" \
# we need 4096 block size for ECKD DASD
"-device" "virtio-blk-ccw,drive=target,physical_block_size=4096,logical_block_size=4096,scsi=off")
fi
runvm "${target_drive[@]}" -- \
/usr/lib/coreos-assembler/create_disk.sh \
--disk /dev/vda \
--buildid "${build}" \
--imgid "${img}" \
--grub-script /usr/lib/coreos-assembler/grub.cfg \
--kargs "\"${kargs}\"" \
--osname "${name}" \
--ostree-ref "${ref_arg}" \
--ostree-remote "${ostree_remote}" \
--ostree-repo "${ostree_repo}" \
--save-var-subdirs "${save_var_subdirs}" \
"${luks_flag}"
mv "${path}.tmp" "$path"
echo "{}" > tmp/vm-iso-checksum.json

# there's probably a jq one-liner for this...
python3 -c "
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-compress
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_cpu_param(param):
return int(f.read().strip())


# XXX: should dedupe this with logic in virt-install and put in the shared lib
# XXX: should dedupe this with logic in cmdlib and put in the shared lib
def xz_threads():
with open("/proc/1/cgroup") as f:
in_k8s = re.search(r'.*kubepods.*', f.read())
Expand Down
29 changes: 0 additions & 29 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -650,35 +650,6 @@ sha256sum_str() {
sha256sum | cut -f 1 -d ' '
}

# This generates the "base image"; not specific to a platform.
run_virtinstall() {
local ostree_repo=$1; shift
local ostree_rev=$1; shift
local dest=$1; shift
local tmpdest="${dest}.tmp"

# forgive me for this sin
local iso_location
iso_location=$(find /usr/lib/coreos-assembler-anaconda/ -name '*.iso' | head -1)

# if the ref is temporary, then we want a checksum refspec
if [ -n "${ref_is_temp}" ]; then
set -- "$@" --delete-ostree-ref
ostree_rev=$(ostree rev-parse --repo="${ostree_repo}" "${ostree_rev}")
fi

/usr/lib/coreos-assembler/virt-install --create-disk --dest="${tmpdest}" \
--tmpdir "${PWD}/tmp" --fs9p \
--kickstart-out "${PWD}"/tmp/flattened.ks \
--console-log-file "${PWD}/install.log" \
--ostree-remote="${name}" --ostree-stateroot="${name}" \
--ostree-ref="${ostree_rev}" \
--location "${iso_location}" \
--configdir="${configdir}" \
--ostree-repo="${ostree_repo}" "$@"
mv "${tmpdest}" "${dest}"
}

get_latest_build() {
if [ -L "${workdir:-$(pwd)}/builds/latest" ]; then
readlink "${workdir:-$(pwd)}/builds/latest"
Expand Down
1 change: 0 additions & 1 deletion src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ cat > rootfs/.coreos-aleph-version.json << EOF
}
EOF

# See the equivalent code in gf-anaconda-cleanup
# /var hack: we'd like to remove all of /var, but SELinux issues prevent that.
# see https://github.com/coreos/ignition-dracut/pull/79#issuecomment-488446949
if [ "${save_var_subdirs}" != NONE ]; then
Expand Down
2 changes: 1 addition & 1 deletion src/deps-aarch64.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# For grub install when creating images without anaconda
# For grub install when creating images
grub2

# For creating bootable UEFI media on aarch64
Expand Down
8 changes: 2 additions & 6 deletions src/deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ selinux-policy-targeted rpm-build
# Standard build tools
make git rpm-build

# virt-install dependencies
libvirt libguestfs-tools /usr/bin/qemu-img /usr/bin/virsh /usr/bin/virt-install
qemu-kvm

# And we process kickstarts
/usr/bin/ksflatten
# virt dependencies
libguestfs-tools /usr/bin/qemu-img qemu-kvm

# ostree-releng-scripts dependencies
rsync
Expand Down
103 changes: 0 additions & 103 deletions src/gf-anaconda-cleanup

This file was deleted.

Loading