Skip to content

Commit a7e6e41

Browse files
authored
fix: install containerd from rpm and versionlock it (#2368)
1 parent deda1e0 commit a7e6e41

File tree

5 files changed

+8
-132
lines changed

5 files changed

+8
-132
lines changed

templates/al2/provisioners/install-worker.sh

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,11 @@ sudo yum versionlock runc-*
150150

151151
# install containerd and lock version
152152
if [[ "$INSTALL_CONTAINERD_FROM_S3" == "true" ]]; then
153-
CONTAINERD_BINARIES=(
154-
containerd
155-
containerd-shim-runc-v2
156-
ctr
157-
)
158153
echo "Installing containerd from S3..."
159-
for binary in "${CONTAINERD_BINARIES[@]}"; do
160-
aws s3 cp --region ${BINARY_BUCKET_REGION} s3://${BINARY_BUCKET_NAME}/containerd/${CONTAINERD_VERSION}/${MACHINE}/${binary} .
161-
sudo chmod +x $binary
162-
sudo mv $binary /usr/bin/
163-
done
164-
sudo mkdir -p /var/lib/containerd
165-
sudo mv $WORKING_DIR/containerd.service /etc/systemd/system/containerd.service
166-
sudo chown root:root /etc/systemd/system/containerd.service
167-
# exclude containerd from yum.conf as versionlock doesn't work in this case
168-
echo "exclude=containerd*,docker*" | sudo tee -a /etc/yum.conf
154+
aws s3 cp --region ${BINARY_BUCKET_REGION} s3://${BINARY_BUCKET_NAME}/containerd/containerd-${CONTAINERD_VERSION}.${MACHINE}.rpm ${WORKING_DIR}/containerd/
155+
sudo yum install -y ${WORKING_DIR}/containerd/containerd-${CONTAINERD_VERSION}.${MACHINE}.rpm
156+
# have to add versionlock explicitly as sudo yum versionlock containerd-* doesn't work for rpm installed outside al repo
157+
sudo yum versionlock add containerd-${CONTAINERD_VERSION}.*
169158
else
170159
sudo yum install -y containerd-${CONTAINERD_VERSION}
171160
sudo yum versionlock containerd-*

templates/al2/runtime/containerd.service

Lines changed: 0 additions & 42 deletions
This file was deleted.

templates/al2023/provisioners/install-worker.sh

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,12 @@ fi
148148
###############################################################################
149149
sudo dnf install -y runc-${RUNC_VERSION}
150150
if [[ "$INSTALL_CONTAINERD_FROM_S3" == "true" ]]; then
151-
CONTAINERD_BINARIES=(
152-
containerd
153-
containerd-shim-runc-v2
154-
ctr
155-
)
156-
for binary in "${CONTAINERD_BINARIES[@]}"; do
157-
echo "Installing containerd from S3..."
158-
aws s3 cp --region ${BINARY_BUCKET_REGION} s3://${BINARY_BUCKET_NAME}/containerd/${CONTAINERD_VERSION}/${MACHINE}/${binary} .
159-
sudo chmod +x $binary
160-
sudo mv $binary /usr/bin/
161-
# exclude containerd from yum.conf as versionlock doesn't work in this case
162-
echo "exclude=containerd*" | sudo tee -a /etc/dnf/dnf.conf
163-
done
164-
sudo mkdir -p /var/lib/containerd
151+
aws s3 cp --region ${BINARY_BUCKET_REGION} s3://${BINARY_BUCKET_NAME}/containerd/containerd-${CONTAINERD_VERSION}.${MACHINE}.rpm ${WORKING_DIR}/containerd/
152+
sudo dnf install -y ${WORKING_DIR}/containerd/containerd-${CONTAINERD_VERSION}.${MACHINE}.rpm
165153
else
166154
sudo dnf install -y containerd-${CONTAINERD_VERSION}
167-
sudo dnf versionlock containerd-*
168155
fi
156+
sudo dnf versionlock containerd-*
169157

170158
# generate and store containerd version in file /etc/eks/containerd-version.txt
171159
containerd --version | sudo tee /etc/eks/containerd-version.txt
@@ -254,17 +242,7 @@ sudo mv $ECR_CREDENTIAL_PROVIDER_BINARY /etc/eks/image-credential-provider/
254242
### SOCI Snapshotter ##########################################################
255243
###############################################################################
256244

257-
# dnf will still try to install containerd from Amazon Linux as a dependency,
258-
# and it will break because we explicitly exclude it in favor of our manual
259-
# version in order to version lock it. dnf doesn't recognize the locally
260-
# installed version.
261-
# Use `--disableexcludes=all` to allow downloading containerd RPM (but not installing it).
262-
# TODO consider installing a stub package that provides containerd so that we can
263-
# do this the normal way with dnf.
264-
SOCI_RPM_DIR=$(mktemp -d)
265-
sudo dnf install -y --downloadonly --downloaddir="${SOCI_RPM_DIR}" --disableexcludes=all soci-snapshotter
266-
# This will break if we need other deps besides containerd.
267-
sudo rpm -i --nodeps "${SOCI_RPM_DIR}/soci-snapshotter*.rpm"
245+
sudo dnf install -y soci-snapshotter
268246
sudo systemctl enable soci-snapshotter.socket
269247

270248
################################################################################

templates/al2023/runtime/rootfs/etc/systemd/system/containerd.service

Lines changed: 0 additions & 42 deletions
This file was deleted.

templates/shared/provisioners/generate-version-info.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ if [ "$?" != 0 ]; then
3131
fi
3232
echo $(jq ".binaries.kubelet = \"$KUBELET_VERSION\"" $OUTPUT_FILE) > $OUTPUT_FILE
3333

34-
CONTAINERD_VERSION=$(containerd --version | awk '{print $3}')
35-
if [ "$?" != 0 ]; then
36-
echo "unable to get containerd version"
37-
exit 1
38-
fi
39-
echo $(jq ".binaries.containerd = \"$CONTAINERD_VERSION\"" $OUTPUT_FILE) > $OUTPUT_FILE
40-
4134
CLI_VERSION=$(aws --version | awk '{print $1}' | cut -d '/' -f 2)
4235
if [ "$?" != 0 ]; then
4336
echo "unable to get aws cli version"

0 commit comments

Comments
 (0)