Skip to content

Commit e3e1fb6

Browse files
authored
Merge pull request #386 from ggriffiths/r21_fix_build_install_go115
release-2.1: Update release tools for go build fix
2 parents 034c545 + b7bba3e commit e3e1fb6

File tree

7 files changed

+176
-25
lines changed

7 files changed

+176
-25
lines changed

release-tools/SIDECAR_RELEASE_PROCESS.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
5050
## Release Process
5151
1. Identify all issues and ongoing PRs that should go into the release, and
5252
drive them to resolution.
53-
1. Download [K8s release notes
53+
1. Download v2.8+ [K8s release notes
5454
generator](https://github.com/kubernetes/release/tree/master/cmd/release-notes)
5555
1. Generate release notes for the release. Replace arguments with the relevant
5656
information.
@@ -62,13 +62,10 @@ naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
6262
```
6363
* For new patch releases on a release branch:
6464
```
65-
GITHUB_TOKEN=<token> release-notes --branch=release-1.1
66-
--start-rev=v1.1.1 --end-sha=f0a9219b29cc9053047c39d149ce9b22bc7b918b
65+
GITHUB_TOKEN=<token> release-notes --discover=patch-to-latest --branch=release-1.1
6766
--github-org=kubernetes-csi --github-repo=external-provisioner
6867
--required-author="" --output out.md
6968
```
70-
* `--start-rev` should point to the last patch release from the release branch.
71-
* `--end-sha` should point to the latest commit from the release branch.
7269
1. Compare the generated output to the new commits for the release to check if
7370
any notable change missed a release note.
7471
1. Reword release notes as needed. Make sure to check notes for breaking
@@ -89,6 +86,12 @@ naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
8986
[external-provisioner example](https://github.com/kubernetes-csi/external-provisioner/releases/new)
9087
1. If release was a new major/minor version, create a new `release-<minor>`
9188
branch at that commit.
89+
1. Check [image build status](https://k8s-testgrid.appspot.com/sig-storage-image-build).
90+
1. Promote images from k8s-staging-sig-storage to k8s.gcr.io/sig-storage. From
91+
the [k8s image
92+
repo](https://github.com/kubernetes/k8s.io/tree/master/k8s.gcr.io/images/k8s-staging-sig-storage),
93+
run `./generate.sh > images.yaml`, and send a PR with the updated images.
94+
Once merged, the image promoter will copy the images from staging to prod.
9295
1. Update [kubernetes-csi/docs](https://github.com/kubernetes-csi/docs) sidecar
9396
and feature pages with the new released version.
9497
1. After all the sidecars have been released, update

release-tools/build.make

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ BUILD_PLATFORMS =
7171

7272
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
7373
# defined by BUILD_PLATFORMS.
74-
build-%: check-go-version-go
74+
$(CMDS:%=build-%): build-%: check-go-version-go
7575
mkdir -p bin
7676
echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix; do \
7777
if ! (set -x; CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o "./bin/$*$$suffix" ./cmd/$*); then \
@@ -80,10 +80,10 @@ build-%: check-go-version-go
8080
fi; \
8181
done
8282

83-
container-%: build-%
83+
$(CMDS:%=container-%): container-%: build-%
8484
docker build -t $*:latest -f $(shell if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi) --label revision=$(REV) .
8585

86-
push-%: container-%
86+
$(CMDS:%=push-%): push-%: container-%
8787
set -ex; \
8888
push_image () { \
8989
docker tag $*:latest $(IMAGE_NAME):$$tag; \
@@ -105,6 +105,77 @@ build: $(CMDS:%=build-%)
105105
container: $(CMDS:%=container-%)
106106
push: $(CMDS:%=push-%)
107107

108+
# Additional parameters are needed when pushing to a local registry,
109+
# see https://github.com/docker/buildx/issues/94.
110+
# However, that then runs into https://github.com/docker/cli/issues/2396.
111+
#
112+
# What works for local testing is:
113+
# make push-multiarch PULL_BASE_REF=master REGISTRY_NAME=<your account on dockerhub.io> BUILD_PLATFORMS="linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x"
114+
DOCKER_BUILDX_CREATE_ARGS ?=
115+
116+
# This target builds a multiarch image for one command using Moby BuildKit builder toolkit.
117+
# Docker Buildx is included in Docker 19.03.
118+
#
119+
# ./cmd/<command>/Dockerfile[.Windows] is used if found, otherwise Dockerfile[.Windows].
120+
# It is currently optional: if no such file exists, Windows images are not included,
121+
# even when Windows is listed in BUILD_PLATFORMS. That way, projects can test that
122+
# Windows binaries can be built before adding a Dockerfile for it.
123+
#
124+
# BUILD_PLATFORMS determines which individual images are included in the multiarch image.
125+
# PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name, and determines
126+
# the tag for the resulting multiarch image.
127+
$(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
128+
set -ex; \
129+
DOCKER_CLI_EXPERIMENTAL=enabled; \
130+
export DOCKER_CLI_EXPERIMENTAL; \
131+
docker buildx create $(DOCKER_BUILDX_CREATE_ARGS) --use --name multiarchimage-buildertest; \
132+
trap "docker buildx rm multiarchimage-buildertest" EXIT; \
133+
dockerfile_linux=$$(if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi); \
134+
dockerfile_windows=$$(if [ -e ./cmd/$*/Dockerfile.Windows ]; then echo ./cmd/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \
135+
if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi; \
136+
if ! [ -f "$$dockerfile_windows" ]; then \
137+
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *.exe//g' -e 's/; *;/;/g')"; \
138+
fi; \
139+
pushMultiArch () { \
140+
tag=$$1; \
141+
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do \
142+
docker buildx build --push \
143+
--tag $(IMAGE_NAME):$$arch-$$os-$$tag \
144+
--platform=$$os/$$arch \
145+
--file $$(eval echo \$${dockerfile_$$os}) \
146+
--build-arg binary=./bin/$*$$suffix \
147+
--label revision=$(REV) \
148+
.; \
149+
done; \
150+
images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do echo $(IMAGE_NAME):$$arch-$$os-$$tag; done); \
151+
docker manifest create --amend $(IMAGE_NAME):$$tag $$images; \
152+
docker manifest push -p $(IMAGE_NAME):$$tag; \
153+
}; \
154+
if [ $(PULL_BASE_REF) = "master" ]; then \
155+
: "creating or overwriting canary image"; \
156+
pushMultiArch canary; \
157+
elif echo $(PULL_BASE_REF) | grep -q -e 'release-*' ; then \
158+
: "creating or overwriting canary image for release branch"; \
159+
release_canary_tag=$$(echo $(PULL_BASE_REF) | cut -f2 -d '-')-canary; \
160+
pushMultiArch $$release_canary_tag; \
161+
elif docker pull $(IMAGE_NAME):$(PULL_BASE_REF) 2>&1 | tee /dev/stderr | grep -q "manifest for $(IMAGE_NAME):$(PULL_BASE_REF) not found"; then \
162+
: "creating release image"; \
163+
pushMultiArch $(PULL_BASE_REF); \
164+
else \
165+
: "ERROR: release image $(IMAGE_NAME):$(PULL_BASE_REF) already exists: a new tag is required!"; \
166+
exit 1; \
167+
fi
168+
169+
.PHONY: check-pull-base-ref
170+
check-pull-base-ref:
171+
if ! [ "$(PULL_BASE_REF)" ]; then \
172+
echo >&2 "ERROR: PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name."; \
173+
exit 1; \
174+
fi
175+
176+
.PHONY: push-multiarch
177+
push-multiarch: $(CMDS:%=push-multiarch-%)
178+
108179
clean:
109180
-rm -rf bin
110181

release-tools/cloudbuild.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. release-tools/prow.sh
5+
6+
gcr_cloud_build

release-tools/cloudbuild.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# A configuration file for multi-arch image building with the Google cloud build service.
2+
#
3+
# Repos using this file must:
4+
# - import csi-release-tools
5+
# - add a symlink cloudbuild.yaml -> release-tools/cloudbuild.yaml
6+
# - add a .cloudbuild.sh which can be a custom file or a symlink
7+
# to release-tools/cloudbuild.sh
8+
# - accept "binary" as build argument in their Dockerfile(s) (see
9+
# https://github.com/pohly/node-driver-registrar/blob/3018101987b0bb6da2a2657de607174d6e3728f7/Dockerfile#L4-L6)
10+
# because binaries will get built for different architectures and then
11+
# get copied from the built host into the container image
12+
#
13+
# See https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md
14+
# for more details on image pushing process in Kubernetes.
15+
#
16+
# To promote release images, see https://github.com/kubernetes/k8s.io/tree/master/k8s.gcr.io/images/k8s-staging-sig-storage.
17+
18+
# This must be specified in seconds. If omitted, defaults to 600s (10 mins).
19+
timeout: 1800s
20+
# This prevents errors if you don't use both _GIT_TAG and _PULL_BASE_REF,
21+
# or any new substitutions added in the future.
22+
options:
23+
substitution_option: ALLOW_LOOSE
24+
steps:
25+
# The image must contain bash and curl. Ideally it should also contain
26+
# the desired version of Go (currently defined in release-tools/travis.yml),
27+
# but that just speeds up the build and is not required.
28+
- name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20200421-a2bf5f8'
29+
entrypoint: ./.cloudbuild.sh
30+
env:
31+
- GIT_TAG=${_GIT_TAG}
32+
- PULL_BASE_REF=${_PULL_BASE_REF}
33+
- REGISTRY_NAME=gcr.io/${_STAGING_PROJECT}
34+
- HOME=/root
35+
substitutions:
36+
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
37+
# can be used as a substitution.
38+
_GIT_TAG: '12345'
39+
# _PULL_BASE_REF will contain the ref that was pushed to trigger this build -
40+
# a branch like 'master' or 'release-0.2', or a tag like 'v0.2'.
41+
_PULL_BASE_REF: 'master'
42+
# The default gcr.io staging project for Kubernetes-CSI
43+
# (=> https://console.cloud.google.com/gcr/images/k8s-staging-sig-storage/GLOBAL).
44+
# Might be overridden in the Prow build job for a repo which wants
45+
# images elsewhere.
46+
_STAGING_PROJECT: 'k8s-staging-sig-storage'

release-tools/filter-junit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ limitations under the License.
1515
*/
1616

1717
/*
18-
* This command filters a JUnit file such that only tests with a name
19-
* matching a regular expression are passed through. By concatenating
20-
* multiple input files it is possible to merge them into a single file.
21-
*/
18+
This command filters a JUnit file such that only tests with a name
19+
matching a regular expression are passed through. By concatenating
20+
multiple input files it is possible to merge them into a single file.
21+
*/
2222
package main
2323

2424
import (

release-tools/prow.sh

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ get_versioned_variable () {
8585
echo "$value"
8686
}
8787

88-
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
88+
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x; linux arm64 -arm64" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
8989

9090
# If we have a vendor directory, then use it. We must be careful to only
9191
# use this for "make" invocations inside the project's repo itself because
@@ -218,17 +218,18 @@ configvar CSI_PROW_DRIVER_CANARY "${CSI_PROW_HOSTPATH_CANARY}" "driver image ove
218218
# all generated files are present.
219219
#
220220
# CSI_PROW_E2E_REPO=none disables E2E testing.
221-
# TOOO: remove versioned variables and make e2e version match k8s version
222-
configvar CSI_PROW_E2E_VERSION_1_15 v1.15.0 "E2E version for Kubernetes 1.15.x"
223-
configvar CSI_PROW_E2E_VERSION_1_16 v1.16.0 "E2E version for Kubernetes 1.16.x"
224-
configvar CSI_PROW_E2E_VERSION_1_17 v1.17.0 "E2E version for Kubernetes 1.17.x"
225-
# TODO: add new CSI_PROW_E2E_VERSION entry for future Kubernetes releases
226-
configvar CSI_PROW_E2E_VERSION_LATEST master "E2E version for Kubernetes master" # testing against Kubernetes master is already tracking a moving target, so we might as well use a moving E2E version
227-
configvar CSI_PROW_E2E_REPO_LATEST https://github.com/kubernetes/kubernetes "E2E repo for Kubernetes >= 1.13.x" # currently the same for all versions
228-
configvar CSI_PROW_E2E_IMPORT_PATH_LATEST k8s.io/kubernetes "E2E package for Kubernetes >= 1.13.x" # currently the same for all versions
229-
configvar CSI_PROW_E2E_VERSION "$(get_versioned_variable CSI_PROW_E2E_VERSION "${csi_prow_kubernetes_version_suffix}")" "E2E version"
230-
configvar CSI_PROW_E2E_REPO "$(get_versioned_variable CSI_PROW_E2E_REPO "${csi_prow_kubernetes_version_suffix}")" "E2E repo"
231-
configvar CSI_PROW_E2E_IMPORT_PATH "$(get_versioned_variable CSI_PROW_E2E_IMPORT_PATH "${csi_prow_kubernetes_version_suffix}")" "E2E package"
221+
tag_from_version () {
222+
version="$1"
223+
shift
224+
case "$version" in
225+
latest) echo "master";;
226+
release-*) echo "$version";;
227+
*) echo "v$version";;
228+
esac
229+
}
230+
configvar CSI_PROW_E2E_VERSION "$(tag_from_version "${CSI_PROW_KUBERNETES_VERSION}")" "E2E version"
231+
configvar CSI_PROW_E2E_REPO "https://github.com/kubernetes/kubernetes" "E2E repo"
232+
configvar CSI_PROW_E2E_IMPORT_PATH "k8s.io/kubernetes" "E2E package"
232233

233234
# csi-sanity testing from the csi-test repo can be run against the installed
234235
# CSI driver. For this to work, deploying the driver must expose the Unix domain
@@ -513,6 +514,10 @@ go_version_for_kubernetes () (
513514
if ! [ "$go_version" ]; then
514515
die "Unable to determine Go version for Kubernetes $version from hack/lib/golang.sh."
515516
fi
517+
# Strip the trailing .0. Kubernetes includes it, Go itself doesn't.
518+
# Ignore: See if you can use ${variable//search/replace} instead.
519+
# shellcheck disable=SC2001
520+
go_version="$(echo "$go_version" | sed -e 's/\.0$//')"
516521
echo "$go_version"
517522
)
518523

@@ -1189,3 +1194,23 @@ main () {
11891194

11901195
return "$ret"
11911196
}
1197+
1198+
# This function can be called by a repo's top-level cloudbuild.sh:
1199+
# it handles environment set up in the GCR cloud build and then
1200+
# invokes "make push-multiarch" to do the actual image building.
1201+
gcr_cloud_build () {
1202+
# Register gcloud as a Docker credential helper.
1203+
# Required for "docker buildx build --push".
1204+
gcloud auth configure-docker
1205+
1206+
if find . -name Dockerfile | grep -v ^./vendor | xargs --no-run-if-empty cat | grep -q ^RUN; then
1207+
# Needed for "RUN" steps on non-linux/amd64 platforms.
1208+
# See https://github.com/multiarch/qemu-user-static#getting-started
1209+
(set -x; docker run --rm --privileged multiarch/qemu-user-static --reset -p yes)
1210+
fi
1211+
1212+
# Extract tag-n-hash value from GIT_TAG (form vYYYYMMDD-tag-n-hash) for REV value.
1213+
REV=v$(echo "$GIT_TAG" | cut -f3- -d 'v')
1214+
1215+
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make push-multiarch REV="${REV}" REGISTRY_NAME="${REGISTRY_NAME}" BUILD_PLATFORMS="${CSI_PROW_BUILD_PLATFORMS}"
1216+
}

release-tools/travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ git:
66
depth: false
77
matrix:
88
include:
9-
- go: 1.13.3
9+
- go: 1.15
1010
before_script:
1111
- mkdir -p bin
1212
- wget https://github.com/golang/dep/releases/download/v0.5.1/dep-linux-amd64 -O bin/dep

0 commit comments

Comments
 (0)