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

Bootstrap without docker #109

Closed
wants to merge 1 commit into from

Conversation

yabberyabber
Copy link
Contributor

@yabberyabber yabberyabber commented Apr 24, 2024

With this change we bootstrap the workspace creation environment using a centos rootfs rather than pulling down a docker container. This has the following benefits:

  • docker and golang are no longer in the dependency set which should result in less cache churn
  • we no longer need a finalizer to set up yum repos --- creating these files in their own snapshot and overlaying it makes it much more cache-friendly and avoids us needing to mount the whole workspace in a tmpfs in order to let the finalizer run
  • we can check the content hash of the thing we download (in theory we trust quay.io to not change their docker image tags, but we have no way of checking this)
  • The artifactory URL can now be overridden via cluster config -- although the default value of artifactory.infra.corp.arista.io is preserved

It does add a bit of complexity that we start with a centos container to bootstrap an alma container. However I don't think this is really an issue as the content that we are installing comes from our internal alma repositories. The only thing we are using centos for is to run dnf and resolve/install dependencies into our alma images.

wget https://cloud.centos.org/centos/9-stream/${arch}/images/CentOS-Stream-Container-Base-9-20230501.0.${arch}.tar.xz \
--output-document base.tar.xz

echo "$cksum base.tar.xz" | sha256sum -c
Copy link
Member

Choose a reason for hiding this comment

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

I found this construct to be more straightforward:

filename=base-${arch}.tar.xz
wget https://cloud.centos.org/centos/9-stream/${arch}/images/CentOS-Stream-Container-Base-9-20230501.0.${arch}.tar.xz \
    --output-document ${filename}

grep $filename <<-SUMS | sha256sum -cw
63b7ddb444b23a07cb851398c338595e410fb3fac2dd72061d0292c653e5afe6 *base-x86_64.tar.xz
312a833dfe646ce5b41f362cae577df9797955b85ced96173be8e88e5ebd5990 *base-arm64.tar.xz
SUMS

It ends up being easier to extend since you don't need to remap the arch names for every arch, so adding new architectures is typically about adding a new line in the sum document

arch=$(uname -m)
case "$arch" in
x86_64)
arch=x86_64
Copy link
Member

Choose a reason for hiding this comment

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

nit: remove

Comment on lines +51 to +75
internal/bootstrap/extract/1:
no-create-mountpoints: true
units:
- floor: .%internal/bootstrap/iso-extraction-floor
sources: []
mappings:
/src/base: .%internal/bootstrap/base.tar.xz
build: |
tar --strip-components=1 -xf /src/base/base.tar.xz -C /dest

internal/bootstrap/extract/2:
description: |
Extract our bootstrapping environment and remove any pre-configured
yum repos. This bootstrapping environment will be centos 9 stream,
but because we will install el9 repos under /etc/yum.repos.d, the
environments that we boostrap will be el9.
no-create-mountpoints: true
units:
- floor: .%internal/bootstrap/iso-extraction-floor
sources: []
mappings:
/src/layer: .%internal/bootstrap/extract/1
build: |
tar -xf /src/layer/layer.tar -C /dest
rm /dest/etc/yum.repos.d/*
Copy link
Member

Choose a reason for hiding this comment

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

I don't see much value in separating these steps from the main download step. I guess the argument is that we don't need to redownload the tarball should any of the commands responsible for extracting and preparing that bootstrap image change, but redownloading a file is generally pretty fast for this to not really matter. This just ends up taking thrice the storage since we're individually storing the tarball, the layer tarball, and the extracted layer separately.


internal/bootstrap/network:
entry:
share-net: true
Copy link
Member

Choose a reason for hiding this comment

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

not part of this change but this is definitely no longer accurate and should be using network.enabled: true

yum repos. This bootstrapping environment will be centos 9 stream,
but because we will install el9 repos under /etc/yum.repos.d, the
environments that we boostrap will be el9.
no-create-mountpoints: true
Copy link
Member

Choose a reason for hiding this comment

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

You probably do want to ensure all of the mountpoints are created, because this image is getting entry settings that will attempt to mount /tmp, /dev, ... and while I'm sure the base centos image contains these, it doesn't hurt to assert that they're created

Comment on lines +17 to +19
Downloading a recent-ish centos container base from the upstream
centos registry. Note that we cache this step separately for quick
development.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe do mention that this is used for bootstrapping alma linux, and just has to be a rpm-based system. I would also mention that the image should seldom change since it would invalidate all of the eext snapshots.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would this image changing invalidate all eext-snapshots ?
It'd invalidate the eext base-image snapshot since the floor changed, but wouldn't the base-image snapshot be generated with the same content hash ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The snapshot hash isn't a content-hash --- it's actually a hash of all the inputs to the build

Since the definition of internal/bootstrap/base.tar.xz is an input to the next build, just changing the build script (and the version of alman that we fetch) is sufficient to change the hash of all downstream consumers

@aajith-arista
Copy link
Collaborator

Sorry, I totally missed this PR.
I'm wondering why the golang and docker dependencies are more troublesome than the alpine dependency ?
Also don't we still have the go dependency since we use the go generator to build eext itself ?

@aajith-arista
Copy link
Collaborator

ndencies are more troublesome than the alpine dependency ?
Also don't we still have the go dependency since we use the go generator to build eext itself ?

Ok, I understand why the alpine dependency is not a problem as it's only used in the iso-extraction-floor, and the bootstrap image's hash won't depend on it.

However, I'm still confused about golang dependency. Is it minor go version updates that we roll in to eos-trunk ? Will this change the eext binary's hash which is built with the go generator ?

Also, I have built on top of Andrew's commit here: #116

@aajith-arista
Copy link
Collaborator

I've already pulled in Andrew's changes here: #116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants