Skip to content

Commit 4a6b47d

Browse files
authored
Merge pull request #4586 from dmcgowan/update-cri-push
Update CRI tests to build and push to gcs
2 parents 84aacd5 + 65df8db commit 4a6b47d

8 files changed

Lines changed: 178 additions & 42 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ jobs:
354354
run: |
355355
sudo PATH=$PATH script/setup/install-seccomp
356356
gosu root script/setup/install-runc
357-
script/setup/install-cni
358-
script/setup/install-critools
357+
gosu root script/setup/install-cni
358+
gosu root script/setup/install-critools
359359
working-directory: src/github.com/containerd/containerd
360360

361361
- name: Install criu

Makefile

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,21 @@ install-cri-deps: $(BINARIES)
261261
cp bin/* $(CRIDIR)
262262
else
263263
install-cri-deps: $(BINARIES)
264-
@sudo rm -rf ${CRIDIR}
265-
@sudo install -d ${CRIDIR}/usr/local/bin
266-
@sudo install -D -m 755 bin/* ${CRIDIR}/usr/local/bin
267-
@sudo install -d ${CRIDIR}/opt/containerd/cluster
268-
@sudo cp -r contrib/gce ${CRIDIR}/opt/containerd/cluster/
269-
@sudo install -d ${CRIDIR}/etc/systemd/system
270-
@sudo install -m 644 containerd.service ${CRIDIR}/etc/systemd/system
271-
echo "CONTAINERD_VERSION: '$(VERSION:v%=%)'" | sudo tee ${CRIDIR}/opt/containerd/cluster/version
272-
273-
DESTDIR=$(CRIDIR) USESUDO=true script/setup/install-runc
264+
@rm -rf ${CRIDIR}
265+
@install -d ${CRIDIR}/usr/local/bin
266+
@install -D -m 755 bin/* ${CRIDIR}/usr/local/bin
267+
@install -d ${CRIDIR}/opt/containerd/cluster
268+
@cp -r contrib/gce ${CRIDIR}/opt/containerd/cluster/
269+
@install -d ${CRIDIR}/etc/systemd/system
270+
@install -m 644 containerd.service ${CRIDIR}/etc/systemd/system
271+
echo "CONTAINERD_VERSION: '$(VERSION:v%=%)'" | tee ${CRIDIR}/opt/containerd/cluster/version
272+
273+
DESTDIR=$(CRIDIR) USESUDO=false script/setup/install-runc
274274
DESTDIR=$(CRIDIR) script/setup/install-cni
275275
DESTDIR=$(CRIDIR) script/setup/install-critools
276276

277-
@sudo install -d $(CRIDIR)/bin
278-
@sudo install $(BINARIES) $(CRIDIR)/bin
277+
@install -d $(CRIDIR)/bin
278+
@install $(BINARIES) $(CRIDIR)/bin
279279
endif
280280

281281
ifeq ($(GOOS),windows)
@@ -298,16 +298,17 @@ endif
298298

299299
cri-release: releases/$(CRIRELEASE).tar.gz
300300
@echo "$(WHALE) $@"
301-
@cd releases && sha256sum $(CRIRELEASE).tar.gz >$(CRIRELEASE).tar.gz.sha256sum
301+
@cd releases && sha256sum $(CRIRELEASE).tar.gz >$(CRIRELEASE).tar.gz.sha256sum && ln -sf $(CRIRELEASE).tar.gz cri-containerd.tar.gz
302302

303303
cri-cni-release: releases/$(CRICNIRELEASE).tar.gz
304304
@echo "$(WHALE) $@"
305-
@cd releases && sha256sum $(CRICNIRELEASE).tar.gz >$(CRICNIRELEASE).tar.gz.sha256sum
305+
@cd releases && sha256sum $(CRICNIRELEASE).tar.gz >$(CRICNIRELEASE).tar.gz.sha256sum && ln -sf $(CRICNIRELEASE).tar.gz cri-cni-containerd.tar.gz
306306

307307
clean: ## clean up binaries
308308
@echo "$(WHALE) $@"
309309
@rm -f $(BINARIES)
310-
@if [[ -d $(OUTPUTDIR) ]]; then sudo rm -rf $(OUTPUTDIR); fi
310+
@rm -f releases/*.tar.gz*
311+
@rm -rf $(OUTPUTDIR)
311312

312313
clean-test: ## clean up debris from previously failed tests
313314
@echo "$(WHALE) $@"

script/setup/install-cni

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ go get -d github.com/containernetworking/plugins/...
2929
cd "$GOPATH"/src/github.com/containernetworking/plugins
3030
git checkout $CNI_COMMIT
3131
./build_linux.sh
32-
sudo mkdir -p $CNI_DIR
33-
sudo cp -r ./bin $CNI_DIR
34-
sudo mkdir -p $CNI_CONFIG_DIR
35-
cat << EOF | sudo tee $CNI_CONFIG_DIR/10-containerd-net.conflist
32+
mkdir -p $CNI_DIR
33+
cp -r ./bin $CNI_DIR
34+
mkdir -p $CNI_CONFIG_DIR
35+
cat << EOF | tee $CNI_CONFIG_DIR/10-containerd-net.conflist
3636
{
3737
"cniVersion": "0.4.0",
3838
"name": "containerd-net",

script/setup/install-critools

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ go get -d github.com/kubernetes-sigs/cri-tools/...
2626
cd "$GOPATH"/src/github.com/kubernetes-sigs/cri-tools
2727
git checkout $CRITEST_COMMIT
2828
make
29-
sudo make install -e BINDIR=${DESTDIR:=''}/usr/local/bin
30-
cat << EOF | sudo tee ${DESTDIR}/etc/crictl.yaml
29+
make install -e BINDIR=${DESTDIR:=''}/usr/local/bin
30+
cat << EOF | tee ${DESTDIR}/etc/crictl.yaml
3131
runtime-endpoint: unix:///run/containerd/containerd.sock
3232
EOF

test/build-utils.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,23 @@ ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
2020
PROJECT=${PROJECT:-"k8s-cri-containerd"}
2121

2222
# GOOGLE_APPLICATION_CREDENTIALS is the path of service account file.
23-
if [ -z ${GOOGLE_APPLICATION_CREDENTIALS} ]; then
23+
if [ -z ${GOOGLE_APPLICATION_CREDENTIALS:-""} ]; then
2424
echo "GOOGLE_APPLICATION_CREDENTIALS is not set"
2525
exit 1
2626
fi
2727

2828
# Activate gcloud service account.
2929
gcloud auth activate-service-account --key-file "${GOOGLE_APPLICATION_CREDENTIALS}" --project="${PROJECT}"
3030

31-
# Install dependent libraries.
32-
apt-get update
33-
if apt-cache show libbtrfs-dev > /dev/null; then
34-
apt-get install -y libbtrfs-dev
35-
else
36-
apt-get install -y btrfs-tools
37-
fi
38-
3931
# Kubernetes test infra uses jessie and stretch.
4032
if cat /etc/os-release | grep jessie; then
4133
sh -c "echo 'deb http://ftp.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/backports.list"
4234
apt-get update
4335
apt-get install -y libseccomp2/jessie-backports
4436
apt-get install -y libseccomp-dev/jessie-backports
4537
else
38+
cat /etc/os-release
39+
apt-get update
4640
apt-get install -y libseccomp2
4741
apt-get install -y libseccomp-dev
4842
fi

test/build.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,26 @@ set -o pipefail
2525
source $(dirname "${BASH_SOURCE[0]}")/build-utils.sh
2626
cd "${ROOT}"
2727

28-
# Make sure output directory is very clean.
28+
# Make sure output directory is clean.
2929
make clean
30-
make build
31-
make binaries
32-
33-
# Build and push test tarball.
34-
# TODO: mikebrow need to build/push a release tar similarly to:
35-
# https://github.com/containerd/containerd/blob/master/.github/workflows/release.yml
36-
# old script:
37-
# PUSH_VERSION=true DEPLOY_DIR=${DEPLOY_DIR:-""} \
38-
# make push TARBALL_PREFIX=cri-containerd-cni INCLUDE_CNI=true CUSTOM_CONTAINERD=true
30+
31+
# Build CRI+CNI release
32+
make BUILDTAGS="seccomp selinux no_aufs no_btrfs no_devmapper no_zfs" cri-cni-release
33+
34+
BUILDDIR=$(mktemp -d)
35+
cleanup() {
36+
if [[ ${BUILDDIR} == /tmp/* ]]; then
37+
echo "[-] REMOVING ${BUILDDIR}"
38+
rm -rf ${BUILDDIR}
39+
fi
40+
}
41+
trap cleanup EXIT
42+
43+
set -x
44+
latest=$(readlink ./releases/cri-cni-containerd.tar.gz)
45+
cp releases/${latest} ${BUILDDIR}/cri-containerd.tar.gz
46+
cp releases/${latest}.sha256sum ${BUILDDIR}/cri-containerd.tar.gz.sha256
47+
48+
# Push test tarball to Google cloud storage.
49+
VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always)
50+
PUSH_VERSION=true VERSION=${VERSION} BUILD_DIR=${BUILDDIR} ${ROOT}/test/push.sh

test/push.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# Copyright The containerd Authors.
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
source $(dirname "${BASH_SOURCE[0]}")/utils.sh
22+
23+
# DEPLOY_BUCKET is the gcs bucket where the tarball should be stored in.
24+
DEPLOY_BUCKET=${DEPLOY_BUCKET:-"cri-containerd-staging"}
25+
# DEPLOY_DIR is the directory in the gcs bucket to store the tarball.
26+
DEPLOY_DIR=${DEPLOY_DIR:-""}
27+
# BUILD_DIR is the directory of the bulid out.
28+
BUILD_DIR=${BUILD_DIR:-"_output"}
29+
# TARBALL is the tarball name.
30+
TARBALL=${TARBALL:-"cri-containerd.tar.gz"}
31+
# LATEST is the name of the latest version file.
32+
LATEST=${LATEST:-"latest"}
33+
# PUSH_VERSION indicates whether to push version.
34+
PUSH_VERSION=${PUSH_VERSION:-false}
35+
36+
release_tar=${BUILD_DIR}/${TARBALL}
37+
release_tar_checksum=${release_tar}.sha256
38+
if [[ ! -e ${release_tar} || ! -e ${release_tar_checksum} ]]; then
39+
echo "Release tarball is not built"
40+
exit 1
41+
fi
42+
43+
if ! gsutil ls "gs://${DEPLOY_BUCKET}" > /dev/null; then
44+
create_ttl_bucket ${DEPLOY_BUCKET}
45+
fi
46+
47+
if [ -z "${DEPLOY_DIR}" ]; then
48+
DEPLOY_PATH="${DEPLOY_BUCKET}"
49+
else
50+
DEPLOY_PATH="${DEPLOY_BUCKET}/${DEPLOY_DIR}"
51+
fi
52+
53+
gsutil cp ${release_tar} "gs://${DEPLOY_PATH}/"
54+
gsutil cp ${release_tar_checksum} "gs://${DEPLOY_PATH}/"
55+
echo "Release tarball is uploaded to:
56+
https://storage.googleapis.com/${DEPLOY_PATH}/${TARBALL}"
57+
58+
if ${PUSH_VERSION}; then
59+
if [[ -z "${VERSION}" ]]; then
60+
echo "VERSION is not set"
61+
exit 1
62+
fi
63+
echo ${VERSION} | gsutil cp - "gs://${DEPLOY_PATH}/${LATEST}"
64+
echo "Latest version is uploaded to:
65+
https://storage.googleapis.com/${DEPLOY_PATH}/${LATEST}"
66+
fi

test/utils.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
3+
# Copyright The containerd Authors.
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
18+
19+
# upload_logs_to_gcs uploads test logs to gcs.
20+
# Var set:
21+
# 1. Bucket: gcs bucket to upload logs.
22+
# 2. Dir: directory name to upload logs.
23+
# 3. Test Result: directory of the test result.
24+
upload_logs_to_gcs() {
25+
local -r bucket=$1
26+
local -r dir=$2
27+
local -r result=$3
28+
if ! gsutil ls "gs://${bucket}" > /dev/null; then
29+
create_ttl_bucket ${bucket}
30+
fi
31+
local -r upload_log_path=${bucket}/${dir}
32+
gsutil cp -r "${result}" "gs://${upload_log_path}"
33+
echo "Test logs are uploaed to:
34+
http://gcsweb.k8s.io/gcs/${upload_log_path}/"
35+
}
36+
37+
# create_ttl_bucket create a public bucket in which all objects
38+
# have a default TTL (30 days).
39+
# Var set:
40+
# 1. Bucket: gcs bucket name.
41+
create_ttl_bucket() {
42+
local -r bucket=$1
43+
gsutil mb "gs://${bucket}"
44+
local -r bucket_rule=$(mktemp)
45+
# Set 30 day TTL for logs inside the bucket.
46+
echo '{"rule": [{"action": {"type": "Delete"},"condition": {"age": 30}}]}' > ${bucket_rule}
47+
gsutil lifecycle set "${bucket_rule}" "gs://${bucket}"
48+
rm "${bucket_rule}"
49+
50+
gsutil -m acl ch -g all:R "gs://${bucket}"
51+
gsutil defacl set public-read "gs://${bucket}"
52+
}
53+
54+
# sha256 generates a sha256 checksum for a file.
55+
# Var set:
56+
# 1. Filename.
57+
sha256() {
58+
if which sha256sum >/dev/null 2>&1; then
59+
sha256sum "$1" | awk '{ print $1 }'
60+
else
61+
shasum -a256 "$1" | awk '{ print $1 }'
62+
fi
63+
}

0 commit comments

Comments
 (0)