build: remove obsolete cross build container

The cross build container is not used anymore since the conversion
to github actions. Now the obsolete scripts and makefiles are
cleaned up to remove some confusing leftovers from the
cross container.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit 738a300827)
This commit is contained in:
Travis Nielsen authored and mergify-bot committed 2022-04-07 20:43:06 +00:00
1 parent 585f295655
commit 2f07c19aa8
13 files changed
+5 -538

No files matched your search

+1 -1
View File
@@ -23,6 +23,6 @@ jobs:
severity: warning
check_together: 'yes'
disable_matcher: false
additional_files: build/run build/reset build/sed-in-place
additional_files: build/reset build/sed-in-place
ignore: olm
format: gcc
+1 -72
View File
@@ -18,7 +18,6 @@ The following tools are need on the host:
* git
* make
* golang
* rsync (if you're using the build container on mac)
* helm
## Build
@@ -27,15 +26,7 @@ You can build the Rook binaries and all container images for the host platform b
command below. Building in parallel with the `-j` option is recommended.
```console
make -j4
```
Developers may often wish to make only images for a particular backend in their testing. This can
be done by specifying the `IMAGES` environment variable with `make` as exemplified below. Possible
values for are as defined by sub-directory names in the `/rook/images/` dir. Multiple images can be separated by a space.
```console
make -j4 IMAGES='ceph' build
make -j4 build
```
Run `make help` for more options.
@@ -56,65 +47,3 @@ You can also run the build for all supported platforms:
```console
make -j4 build.all
```
Or from the cross container:
```console
build/run make -j4 build.all
```
Currently, only `amd64` platform supports this kind of 'cross' build. In order to make `build.all`
succeed, we need to follow the steps specified by the below section `Building for other platforms`
first.
We suggest to use native `build` to create the binaries and container images on `arm{32,64}`
platform, but if you do want to build those `arm{32,64}` binaries and images on `amd64` platform
with `build.all` command, please make sure the multi-arch feature is supported. To test run the
following:
```console
> docker run --rm -ti arm32v7/ubuntu uname -a
Linux bad621a75757 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 armv7l armv7l armv7l GNU/Linux
> docker run --rm -ti arm64v8/ubuntu uname -a
Linux f51ea93e76a2 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 aarch64 aarch64 aarch64 GNU/Linux
```
In order to build container images for these platforms we rely on cross-compilers and QEMU. Cross compiling is much faster than QEMU and so we lean heavily on it.
In order for QEMU to work inside docker containers you need to do a few things on
the linux host. If you are using a recent Docker for Mac build you can skip this section, since they added support for binfmt and multi-arch docker builds.
On an Ubuntu machine with a 4.8+ kernel you need to run install the following:
```console
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
binfmt-support
qemu-user-static
```
You also need to run the following on every boot:
```console
docker run --rm --privileged hypriot/qemu-register
```
you can install a systemd unit to help with this if you'd like, for example:
```console
cat <<EOF > /etc/systemd/system/update-binfmt.service
[Unit]
After=docker.service
[Service]
Type=oneshot
ExecStartPre=/usr/bin/docker pull hypriot/qemu-register
ExecStart=/usr/bin/docker run --rm --privileged hypriot/qemu-register
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
systemctl enable update-binfmt.service
```
+2 -2
View File
@@ -133,7 +133,7 @@ build: csv-clean build.common ## Only build for linux platform
@$(MAKE) go.build PLATFORM=linux_$(GOHOSTARCH)
@$(MAKE) -C images PLATFORM=linux_$(GOHOSTARCH)
build.all: build.common ## Build source code for all platforms. Best done in the cross build container due to cross compiler dependencies.
build.all: build.common ## Build source code for all platforms.
ifneq ($(GOHOSTARCH),amd64)
$(error cross platform image build only supported on amd64 host currently)
endif
@@ -195,7 +195,7 @@ gen-rbac: $(HELM) $(YQ) ## generate RBAC from Helm charts
@# output only stdout to the file; stderr for debugging should keep going to stderr
HELM=$(HELM) ./build/rbac/gen-common.sh
.PHONY: all build.common cross.build.parallel
.PHONY: all build.common
.PHONY: build build.all install test check vet fmt codegen mod.check clean distclean prune
# ====================================================================================
+1
View File
@@ -10,6 +10,7 @@
* Prometheus rules are installed by the Helm chart. If you were relying on the cephcluster setting
`monitoring.enabled` to create the prometheus rules, they now need to be enabled by setting
`monitoring.createPrometheusRules` in the Helm chart values.
* Remove the obsolete cross build container, now unused by the CI
## Features
-75
View File
@@ -14,11 +14,8 @@ set -u
# See the License for the specific language governing permissions and
# limitations under the License.
BUILD_HOST=$(hostname)
BUILD_REPO=github.com/rook/rook
BUILD_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd -P)
SHA256CMD=${SHA256CMD:-shasum -a 256}
BUILD_REGISTRY=build-$(echo "${BUILD_HOST}"-"${BUILD_ROOT}" | ${SHA256CMD} | cut -c1-8)
DOCKERCMD=${DOCKERCMD:-docker}
@@ -28,10 +25,6 @@ export OUTPUT_DIR=${BUILD_ROOT}/_output
export WORK_DIR=${BUILD_ROOT}/.work
export CACHE_DIR=${BUILD_ROOT}/.cache
CROSS_IMAGE=${BUILD_REGISTRY}/cross-amd64
CROSS_IMAGE_VOLUME=cross-volume
CROSS_RSYNC_PORT=10873
function ver() {
local full_ver maj min bug build
full_ver="$1" # functions should name input params for easier understanding
@@ -54,71 +47,3 @@ function check_git() {
echo WARN: submodule paths. Please consider upgrading to 2.8.3 or later
fi
}
function start_rsync_container() {
${DOCKERCMD} run \
-d \
-e OWNER=root \
-e GROUP=root \
-e MKDIRS="/volume/go/src/${BUILD_REPO}" \
-p ${CROSS_RSYNC_PORT}:873 \
-v ${CROSS_IMAGE_VOLUME}:/volume \
--entrypoint "/tini" \
"${CROSS_IMAGE}" \
-- /build/rsyncd.sh
}
function wait_for_rsync() {
# wait for rsync to come up
local tries=100
while (( tries > 0 )); do
if rsync "rsync://localhost:${CROSS_RSYNC_PORT}/" &> /dev/null ; then
return 0
fi
(( tries-- ))
sleep 0.1
done
echo ERROR: rsyncd did not come up >&2
exit 1
}
function stop_rsync_container() {
local id=$1
${DOCKERCMD} stop "${id}" &> /dev/null || true
${DOCKERCMD} rm "${id}" &> /dev/null || true
}
function run_rsync() {
local src=$1
shift
local dst=$1
shift
# run the container as an rsyncd daemon so that we can copy the
# source tree to the container volume.
local id
id=$(start_rsync_container)
# wait for rsync to come up
wait_for_rsync || { stop_rsync_container "${id}"; return 1; }
# NOTE: add --progress to show files being syncd
rsync \
--archive \
--delete \
--prune-empty-dirs \
"$@" \
"$src" "$dst" || { stop_rsync_container "${id}"; return 1; }
stop_rsync_container "${id}"
}
function rsync_host_to_container() {
run_rsync "${scriptdir}"/.. rsync://localhost:${CROSS_RSYNC_PORT}/volume/go/src/${BUILD_REPO} "$@"
}
function rsync_container_to_host() {
run_rsync rsync://localhost:${CROSS_RSYNC_PORT}/volume/go/src/${BUILD_REPO}/ "${scriptdir}"/.. "$@"
}
-26
View File
@@ -40,18 +40,6 @@ endif
ALL_PLATFORMS ?= darwin_amd64 windows_amd64 linux_amd64 linux_arm64
ifeq ($(PLATFORM),linux_amd64)
CROSS_TRIPLE = x86_64-linux-gnu
endif
ifeq ($(PLATFORM),linux_arm64)
CROSS_TRIPLE = aarch64-linux-gnu
endif
ifeq ($(PLATFORM),darwin_amd64)
CROSS_TRIPLE=x86_64-apple-darwin15
endif
ifeq ($(PLATFORM),windows_amd64)
CROSS_TRIPLE=x86_64-w64-mingw32
endif
export GOARM
# force the build of a linux binary when running on MacOS
@@ -59,20 +47,6 @@ GOHOSTOS=linux
GOHOSTARCH := $(shell go env GOHOSTARCH)
HOST_PLATFORM := $(GOHOSTOS)_$(GOHOSTARCH)
ifneq ($(PLATFORM),$(HOST_PLATFORM))
ifeq (,$(shell go env CC))
CC := $(CROSS_TRIPLE)-gcc
else
CC := $(shell go env CC)
endif
ifeq (,$(shell go env CXX))
CXX := $(CROSS_TRIPLE)-gcc
else
CXX := $(shell go env CXX)
endif
export CC CXX
endif
# REAL_HOST_PLATFORM is used to determine the correct url to download the various binary tools from and it does not use
# HOST_PLATFORM which is used to build the program.
REAL_HOST_PLATFORM=$(shell go env GOHOSTOS)_$(GOHOSTARCH)
-12
View File
@@ -16,15 +16,3 @@
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${scriptdir}/common.sh"
# this should only clean up leaked containers during rsync
for c in $(docker ps -a -q --filter=ancestor=${CROSS_IMAGE}); do
echo removing container ${c}
docker stop ${c}
docker rm ${c}
done
if [[ $(docker volume ls | grep ${CROSS_IMAGE_VOLUME}) ]]; then
echo removing volume ${CROSS_IMAGE_VOLUME}
docker volume rm ${CROSS_IMAGE_VOLUME}
fi
-165
View File
@@ -1,165 +0,0 @@
#!/bin/bash -e
set -e
set -x
# Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${scriptdir}/common.sh"
check_git
# build the the container if we've not done so already
if [ "`uname -m`" != "x86_64" ]; then
echo ERROR: we only support the cross container build on amd64 host.
exit 1
fi
echo ==== building the cross container \(this could take minutes the first time\)
make_cmd="make --no-print-directory -C ${scriptdir}/../images cross PULL=0 DOCKERCMD=${DOCKERCMD}"
make_output=$($make_cmd 2>&1) || {
cat <<EOF >&2
=== cross build image failed for ${CROSS_IMAGE}
${make_output}
EOF
exit 1
}
# run the container with the same uid and gid of the user to avoid
# permissions issues when sharing volumes with the host
USER_ARGS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g )"
BUILDER_HOME=/home/rook
KUBE_ARGS=""
# setup kubectl from the host if available
if [ -d ${HOME}/.kube ]; then
KUBE_ARGS="-v ${HOME}/.kube:${BUILDER_HOME}/.kube"
fi
if [ "`uname -s`" != "Linux" ]; then
# On non-linux hosts, its is EXTREMELY slow to mount the source
# tree inside the container. As such we use rsync to copy the source
# tree to a new docker volumer on each run. The first rsync take a
# little bit of time, but subsequent ones go by fast. This approach
# is MUCH faster than using osxfs, NFS or other approaches.
# create a new volume to hold our go workspace. NOTE: while concurrent
# runs of the build container are supported they will share the same volume
# and we will be rsyncing to it at different times. This could lead to
# undefined behavior but this should be a rare case on non-linux envs.
if [[ ! $(${DOCKERCMD} volume ls | grep ${CROSS_IMAGE_VOLUME}) ]]; then
echo ==== Creating docker volume "${CROSS_IMAGE_VOLUME}" and syncing sources
echo ==== for first time. This could take a few seconds.
${DOCKERCMD} volume create --name ${CROSS_IMAGE_VOLUME} &> /dev/null
fi
# On non-linux the layout is as follows:
#
# /var/run/docker.sock (bind mounted to host /var/run/docker.sock)
# /${BUILDER_HOME} (bind mounted to an independent docker volume)
# /.netrc (bind mounted to host ${HOME}/.netrc)
# /.aws (bind mounted to host ${HOME}/.aws)
# /.docker (bind mounted to host ${HOME}/.docker)
# /.cache (bind mounted to host ${CACHE_DIR} if set)
# /go/src/github.com/rook/rook (rsync'd from host <source>)
# now copy the source tree to the container volume. Note this also
# copies the .git directory but not the index.lock files which
# change frequently and sometimes cause rsync to fail.
rsync_host_to_container \
--filter="- /.work/" \
--filter="- /.cache/" \
--filter="- /.vscode/" \
--filter="- index.lock"
MOUNT_OPTS="-v ${CROSS_IMAGE_VOLUME}:${BUILDER_HOME}"
else
# On linux bind mounts are cheap so we dont need to rsync
# the layout is as follows:
#
# /var/run/docker.sock (bind mounted to host /var/run/docker.sock)
# /${BUILDER_HOME}
# /.netrc (bind mounted to host ${HOME}/.netrc)
# /.aws (bind mounted to host ${HOME}/.aws)
# /.docker (bind mounted to host ${HOME}/.docker)
# /go
# /pkg (bind mounted to <source>/.work/cross_pkg)
# /src/github.com/rook/rook (bind mounted to <source>)
MOUNT_OPTS="\
-v ${scriptdir}/../.work/cross_pkg:${BUILDER_HOME}/go/pkg
-v ${scriptdir}/..:${BUILDER_HOME}/go/src/${BUILD_REPO}"
fi
# if CACHE_DIR is not set bind mount it
if [[ -n "${CACHE_DIR}" ]]; then
mkdir -p ${CACHE_DIR}
DOWNLOAD_ARGS="-e CACHE_DIR=${BUILDER_HOME}/go/src/${BUILD_REPO}/.cache \
-v ${CACHE_DIR}:${BUILDER_HOME}/go/src/${BUILD_REPO}/.cache"
fi
tty -s && TTY_ARGS=-ti || TTY_ARGS=
DISABLE_NESTED_DOCKER=""
DOCKER_NESTED_ARGS=""
# BUGBUG: new docker clients switch to using OSX keychain. how do we copy creds?
# sometimes we run docker inside docker. bind the docker config and socket
if [ -z "${DISABLE_NESTED_DOCKER}" ]; then
DOCKER_NESTED_ARGS="\
-v ${HOME}/.docker:${BUILDER_HOME}/.docker \
-v /var/run/docker.sock:/var/run/docker.sock"
fi
# set AWS creds
AWS_ARGS="\
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_DEFAULT_REGION \
-v ${HOME}/.aws:${BUILDER_HOME}/.aws"
rsync_back() {
if [ "`uname -s`" != "Linux" ]; then
# rsync generated files back to the host. IMPORTANT: we never rsync the .git directory back
# since the host's version might have changed.
rsync_container_to_host \
--filter="+ /_output/" \
--filter="- /*"
fi
}
${DOCKERCMD} run \
--rm \
-h ${BUILD_HOST} \
-e BUILD_REGISTRY=${BUILD_REGISTRY} \
-e GOPATH="${BUILDER_HOME}/go" \
-e GO_PKG_DIR="" \
-e GITHUB_TOKEN \
-e VERSION \
-e CHANNEL \
-v ${PWD}/_output:${BUILDER_HOME}/go/bin \
${TTY_ARGS} \
${KUBE_ARGS} \
${DOWNLOAD_ARGS} \
${AWS_ARGS} \
${USER_ARGS} \
${DOCKER_NESTED_ARGS} \
${MOUNT_OPTS} \
-w ${BUILDER_HOME}/go/src/${BUILD_REPO} \
${CROSS_IMAGE} \
"$@" || { rsync_back; exit 1; }
rsync_back
-4
View File
@@ -22,10 +22,6 @@ export TINI_VERSION = v0.19.0
# ====================================================================================
# Image Targets
cross: cross.linux_amd64 ## Build images used for cross building.
cross.%:
@$(MAKE) -C cross PLATFORM=$*
ceph.%:
@$(MAKE) -C ceph PLATFORM=$*
-62
View File
@@ -1,62 +0,0 @@
# Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:xenial-20210114
# install build tools, compilers and cross compilers for all supported platforms
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yy -q --no-install-recommends \
awscli \
ca-certificates \
curl \
docker.io \
git \
jq \
lsb-release \
make \
rsync \
runit \
sudo \
zip && \
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yy -q --no-install-recommends nodejs && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get autoremove -y && \
DEBIAN_FRONTEND=noninteractive apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install golang from the official repo
RUN GO_VERSION=1.16.7 && \
GO_HASH=7fe7a73f55ba3e2285da36f8b085e5c0159e9564ef5f63ee0ed6b818ade8ef04 && \
curl -fsSL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz -o golang.tar.gz && \
echo "${GO_HASH} golang.tar.gz" | sha256sum -c - && \
tar -C /usr/local -xzf golang.tar.gz && \
rm golang.tar.gz
ENV PATH /usr/local/go/bin:$PATH
ARG ARCH
ARG TINI_VERSION
# Run tini as PID 1 and avoid signal handling issues
RUN curl -sSL --fail -o /tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${ARCH} && \
chmod +x /tini
# precompile the go standard library for all supported platforms and configurations
# the install suffixes match those in golang.mk so please keep them in sync
RUN platforms="linux_amd64 linux_arm64" && \
for p in $platforms; do CGO_ENABLED=0 GOOS=${p%_*} GOARCH=${p##*_} GOARM=7 go install -installsuffix static -a std; done
COPY run.sh rsyncd.sh /build/
ENTRYPOINT [ "/tini", "-g", "--", "/build/run.sh" ]
-32
View File
@@ -1,32 +0,0 @@
# Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include ../image.mk
IMAGE = $(BUILD_REGISTRY)/cross-$(GOARCH)
CACHE_IMAGES = $(IMAGE)
TEMP := $(shell mktemp -d)
do.build:
@echo === container build $(IMAGE)
@cp -a . $(TEMP)
@$(DOCKERCMD) build $(BUILD_ARGS) \
--build-arg ARCH=$(GOARCH) \
--build-arg TINI_VERSION=$(TINI_VERSION) \
--build-arg S5CMD_VERSION=$(S5CMD_VERSION) \
--build-arg S5CMD_ARCH=$(S5CMD_ARCH) \
-t $(IMAGE) \
$(TEMP)
@rm -fr $(TEMP)
-51
View File
@@ -1,51 +0,0 @@
#!/bin/bash -e
# Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
VOLUME=${VOLUME:-/volume}
ALLOW=${ALLOW:-192.168.0.0/16 172.16.0.0/12 10.0.0.0/8}
OWNER=${OWNER:-nobody}
GROUP=${GROUP:-nogroup}
if [[ "${GROUP}" != "nogroup" && "${GROUP}" != "root" ]]; then
groupadd -g ${GROUP} rsync
fi
if [[ "${OWNER}" != "nobody" && "${OWNER}" != "root" ]]; then
groupadd -u ${OWNER} -G rsync rsync
fi
chown "${OWNER}:${GROUP}" "${VOLUME}"
[ -f /etc/rsyncd.conf ] || cat <<EOF > /etc/rsyncd.conf
uid = ${OWNER}
gid = ${GROUP}
use chroot = yes
log file = /dev/stdout
reverse lookup = no
[volume]
hosts deny = *
hosts allow = ${ALLOW}
read only = false
path = ${VOLUME}
comment = volume
EOF
for dir in ${MKDIRS}; do
mkdir -p ${dir}
chown "${OWNER}:${GROUP}" ${dir}
done
exec /usr/bin/rsync --no-detach --daemon --config /etc/rsyncd.conf "$@"
-36
View File
@@ -1,36 +0,0 @@
#!/bin/bash -e
set -e
set -x
# Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARGS=( "$@" )
if [ $# -eq 0 ]; then
ARGS=( /bin/bash )
fi
BUILDER_USER=${BUILDER_USER:-rook}
BUILDER_GROUP=${BUILDER_GROUP:-rook}
BUILDER_UID=${BUILDER_UID:-1000}
BUILDER_GID=${BUILDER_GID:-1000}
groupadd -o -g "$BUILDER_GID" "$BUILDER_GROUP" 2> /dev/null
useradd -o -m -g "$BUILDER_GID" -u "$BUILDER_UID" "$BUILDER_USER" 2> /dev/null
echo "$BUILDER_USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
export HOME=/home/${BUILDER_USER}
echo "127.0.0.1 $(cat /etc/hostname)" >> /etc/hosts
[[ -S /var/run/docker.sock ]] && chmod 666 /var/run/docker.sock
chown -R "$BUILDER_UID":"$BUILDER_GID" "$HOME"
exec chpst -u :"$BUILDER_UID":"$BUILDER_GID" "${ARGS[@]}"