Skip to content

Commit 8e4ba5d

Browse files
committed
Update csi-release-tools
$ git subtree pull --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master
2 parents 40f35a9 + fdb3218 commit 8e4ba5d

14 files changed

+2146
-9
lines changed

release-tools/.prow.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! /bin/bash -e
2+
#
3+
# This is for testing csi-release-tools itself in Prow. All other
4+
# repos use prow.sh for that, but as csi-release-tools isn't a normal
5+
# repo with some Go code in it, it has a custom Prow test script.
6+
7+
./verify-shellcheck.sh "$(pwd)"

release-tools/README.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,118 @@ Cheat sheet:
4949
- `git subtree add --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master` - add release tools to a repo which does not have them yet (only once)
5050
- `git subtree pull --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master` - update local copy to latest upstream (whenever upstream changes)
5151
- edit, `git commit`, `git subtree push --prefix=release-tools [email protected]:<user>/csi-release-tools.git <my-new-or-existing-branch>` - push to a new branch before submitting a PR
52+
53+
verify-shellcheck.sh
54+
--------------------
55+
56+
The [verify-shellcheck.sh](./verify-shellcheck.sh) script in this repo
57+
is a stripped down copy of the [corresponding
58+
script](https://github.com/kubernetes/kubernetes/blob/release-1.14/hack/verify-shellcheck.sh)
59+
in the Kubernetes repository. It can be used to check for certain
60+
errors shell scripts, like missing quotation marks. The default
61+
`test-shellcheck` target in [build.make](./build.make) only checks the
62+
scripts in this directory. Components can add more directories to
63+
`TEST_SHELLCHECK_DIRS` to check also other scripts.
64+
65+
End-to-end testing
66+
------------------
67+
68+
A repo that wants to opt into testing via Prow must set up a top-level
69+
`.prow.sh`. Typically that will source `prow.sh` and then transfer
70+
control to it:
71+
72+
``` bash
73+
#! /bin/bash -e
74+
75+
. release-tools/prow.sh
76+
main
77+
```
78+
79+
All Kubernetes-CSI repos are expected to switch to Prow. For details
80+
on what is enabled in Prow, see
81+
https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes-csi
82+
83+
Test results for periodic jobs are visible in
84+
https://testgrid.k8s.io/sig-storage-csi-ci
85+
86+
It is possible to reproduce the Prow testing locally on a suitable machine:
87+
- Linux host
88+
- Docker installed
89+
- code to be tested checkout out in `$GOPATH/src/<import path>`
90+
- `cd $GOPATH/src/<import path> && ./.prow.sh`
91+
92+
Beware that the script intentionally doesn't clean up after itself and
93+
modifies the content of `$GOPATH`, in particular the `kubernetes` and
94+
`kind` repositories there. Better run it in an empty, disposable
95+
`$GOPATH`.
96+
97+
When it terminates, the following command can be used to get access to
98+
the Kubernetes cluster that was brought up for testing (assuming that
99+
this step succeeded):
100+
101+
export KUBECONFIG="$(kind get kubeconfig-path --name="csi-prow")"
102+
103+
It is possible to control the execution via environment variables. See
104+
`prow.sh` for details. Particularly useful is testing against different
105+
Kubernetes releases:
106+
107+
CSI_PROW_KUBERNETES_VERSION=1.13.3 ./.prow.sh
108+
CSI_PROW_KUBERNETES_VERSION=latest ./.prow.sh
109+
110+
Dependencies and vendoring
111+
--------------------------
112+
113+
Most projects will (eventually) use `go mod` to manage
114+
dependencies. `dep` is also still supported by `csi-release-tools`,
115+
but not documented here because it's not recommended anymore.
116+
117+
The usual instructions for using [go
118+
modules](https://github.com/golang/go/wiki/Modules) apply. Here's a cheat sheet
119+
for some of the relevant commands:
120+
- list available updates: `GO111MODULE=on go list -u -m all`
121+
- update or add a single dependency: `GO111MODULE=on go get <package>`
122+
- update all dependencies to their next minor or patch release:
123+
`GO111MODULE=on go get ./...` (add `-u=patch` to limit to patch
124+
releases)
125+
- lock onto a specific version: `GO111MODULE=on go get <package>@<version>`
126+
- clean up `go.mod`: `GO111MODULE=on go mod tidy`
127+
- update vendor directory: `GO111MODULE=on go mod vendor`
128+
129+
`GO111MODULE=on` can be left out when using Go >= 1.13 or when the
130+
source is checked out outside of `$GOPATH`.
131+
132+
`go mod tidy` must be used to ensure that the listed dependencies are
133+
really still needed. Changing import statements or a tentative `go
134+
get` can result in stale dependencies.
135+
136+
The `test-vendor` verifies that it was used when run locally or in a
137+
pre-merge CI job. If a `vendor` directory is present, it will also
138+
verify that it's content is up-to-date.
139+
140+
The `vendor` directory is optional. It is still present in projects
141+
because it avoids downloading sources during CI builds. If this is no
142+
longer deemed necessary, then a project can also remove the directory.
143+
144+
Conversion of a repository that uses `dep` to `go mod` can be done with:
145+
146+
GO111MODULE=on go mod init
147+
release-tools/go-get-kubernetes.sh <current Kubernetes version from Gopkg.toml>
148+
GO111MODULE=on go mod tidy
149+
GO111MODULE=on go mod vendor
150+
git rm -f Gopkg.toml Gopkg.lock
151+
git add go.mod go.sum vendor
152+
153+
### Updating Kubernetes dependencies
154+
155+
When using packages that are part of the Kubernetes source code, the
156+
commands above are not enough because the [lack of semantic
157+
versioning](https://github.com/kubernetes/kubernetes/issues/72638)
158+
prevents `go mod` from finding newer releases. Importing directly from
159+
`kubernetes/kubernetes` also needs `replace` statements to override
160+
the fake `v0.0.0` versions
161+
(https://github.com/kubernetes/kubernetes/issues/79384). The
162+
`go-get-kubernetes.sh` script can be used to update all packages in
163+
lockstep to a different Kubernetes version. Example usage:
164+
```
165+
$ ./release-tools/go-get-kubernetes.sh 1.16.4
166+
```
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Sidecar Release Process
2+
3+
This page describes the process for releasing a kubernetes-csi sidecar.
4+
5+
## Prerequisites
6+
7+
The release manager must:
8+
9+
* Be a member of the kubernetes-csi organization. Open an
10+
[issue](https://github.com/kubernetes/org/issues/new?assignees=&labels=area%2Fgithub-membership&template=membership.md&title=REQUEST%3A+New+membership+for+%3Cyour-GH-handle%3E) in
11+
kubernetes/org to request membership
12+
* Be a top level approver for the repository. To become a top level approver,
13+
the candidate must demonstrate ownership and deep knowledge of the repository
14+
through active maintainence, responding to and fixing issues, reviewing PRs,
15+
test triage.
16+
* Be part of the maintainers or admin group for the repository. admin is a
17+
superset of maintainers, only maintainers level is required for cutting a
18+
release. Membership can be requested by submitting a PR to kubernetes/org.
19+
[Example](https://github.com/kubernetes/org/pull/1467)
20+
21+
## Updating CI Jobs
22+
Whenever a new Kubernetes minor version is released, our kubernetes-csi CI jobs
23+
must be updated.
24+
25+
[Our CI jobs](https://k8s-testgrid.appspot.com/sig-storage-csi-ci) have the
26+
naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
27+
28+
1. Jobs should be actively monitored to find and fix failures in sidecars and
29+
infrastructure changes early in the development cycle. Test failures are sent
30+
31+
1. "-on-master" jobs are the closest reflection to the new Kubernetes version.
32+
1. Fixes to our prow.sh CI script can be tested in the [CSI hostpath
33+
repo](https://github.com/kubernetes-csi/csi-driver-host-path) by modifying
34+
[prow.sh](https://github.com/kubernetes-csi/csi-driver-host-path/blob/master/release-tools/prow.sh)
35+
along with any overrides in
36+
[.prow.sh](https://github.com/kubernetes-csi/csi-driver-host-path/blob/master/.prow.sh)
37+
to mirror the failing environment. Once e2e tests are passing (verify-unit tests
38+
will fail), then the prow.sh changes can be submitted to [csi-release-tools](https://github.com/kubernetes-csi/csi-release-tools).
39+
1. Changes can then be updated in all the sidecar repos and hostpath driver repo
40+
by following the [update
41+
instructions](https://github.com/kubernetes-csi/csi-release-tools/blob/master/README.md#sharing-and-updating).
42+
1. New pull and CI jobs are configured by
43+
[gen-jobs.sh](https://github.com/kubernetes/test-infra/blob/master/config/jobs/kubernetes-csi/gen-jobs.sh).
44+
New pull jobs that have been unverified should be initially made optional.
45+
[Example](https://github.com/kubernetes/test-infra/pull/15055)
46+
1. Once new pull and CI jobs have been verified, and the new Kubernetes version
47+
is released, we can make the optional jobs required, and also remove the
48+
Kubernetes versions that are no longer supported.
49+
50+
## Release Process
51+
1. Identify all issues and ongoing PRs that should go into the release, and
52+
drive them to resolution.
53+
1. Download [K8s release notes
54+
generator](https://github.com/kubernetes/release/tree/master/cmd/release-notes)
55+
1. Generate release notes for the release. Replace arguments with the relevant
56+
information.
57+
```
58+
GITHUB_TOKEN=<token> ./release-notes --start-sha=0ed6978fd199e3ca10326b82b4b8b8e916211c9b --end-sha=3cb3d2f18ed8cb40371c6d8886edcabd1f27e7b9 \
59+
--github-org=kubernetes-csi --github-repo=external-attacher -branch=master -output out.md
60+
```
61+
* `--start-sha` should point to the last release from the same branch. For
62+
example:
63+
* `1.X-1.0` tag when releasing `1.X.0`
64+
* `1.X.Y-1` tag when releasing `1.X.Y`
65+
1. Compare the generated output to the new commits for the release to check if
66+
any notable change missed a release note.
67+
1. Reword release notes as needed. Make sure to check notes for breaking
68+
changes and deprecations.
69+
1. If release is a new major/minor version, create a new `CHANGELOG-<major>.<minor>.md`
70+
file. Otherwise, add the release notes to the top of the existing CHANGELOG
71+
file for that minor version.
72+
1. Submit a PR for the CHANGELOG changes.
73+
1. Submit a PR for README changes, in particular, Compatibility, Feature status,
74+
and any other sections that may need updating.
75+
1. Check that all [canary CI
76+
jobs](https://k8s-testgrid.appspot.com/sig-storage-csi-ci) are passing,
77+
and that test coverage is adequate for the changes that are going into the release.
78+
1. Make sure that no new PRs have merged in the meantime, and no PRs are in
79+
flight and soon to be merged.
80+
1. Create a new release following a previous release as a template. Be sure to select the correct
81+
branch. This requires Github release permissions as required by the prerequisites.
82+
[external-provisioner example](https://github.com/kubernetes-csi/external-provisioner/releases/new)
83+
1. If release was a new major/minor version, create a new `release-<minor>`
84+
branch at that commit.
85+
1. Update [kubernetes-csi/docs](https://github.com/kubernetes-csi/docs) sidecar
86+
and feature pages with the new released version.
87+
1. After all the sidecars have been released, update
88+
CSI hostpath driver with the new sidecars in the [CSI repo](https://github.com/kubernetes-csi/csi-driver-host-path/tree/master/deploy)
89+
and [k/k
90+
in-tree](https://github.com/kubernetes/kubernetes/tree/master/test/e2e/testing-manifests/storage-csi/hostpath/hostpath)

release-tools/build.make

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
# including build.make.
2323
REGISTRY_NAME=quay.io/k8scsi
2424

25+
# Can be set to -mod=vendor to ensure that the "vendor" directory is used.
26+
GOFLAGS_VENDOR=
27+
2528
# Revision that gets built into each binary via the main.version
2629
# string. Uses the `git describe` output based on the most recent
2730
# version tag with a short revision suffix or, if nothing has been
@@ -57,12 +60,18 @@ else
5760
TESTARGS =
5861
endif
5962

63+
ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
64+
6065
# Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
6166
# to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
6267

63-
build-%:
68+
build-%: check-go-version-go
6469
mkdir -p bin
65-
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$* ./cmd/$*
70+
CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$* ./cmd/$*
71+
if [ "$$ARCH" = "amd64" ]; then \
72+
CGO_ENABLED=0 GOOS=windows go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$*.exe ./cmd/$* ; \
73+
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$*-ppc64le ./cmd/$* ; \
74+
fi
6675

6776
container-%: build-%
6877
docker build -t $*:latest -f $(shell if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi) --label revision=$(REV) .
@@ -92,19 +101,19 @@ push: $(CMDS:%=push-%)
92101
clean:
93102
-rm -rf bin
94103

95-
test:
104+
test: check-go-version-go
96105

97106
.PHONY: test-go
98107
test: test-go
99108
test-go:
100109
@ echo; echo "### $@:"
101-
go test `go list ./... | grep -v 'vendor' $(TEST_GO_FILTER_CMD)` $(TESTARGS)
110+
go test $(GOFLAGS_VENDOR) `go list $(GOFLAGS_VENDOR) ./... | grep -v -e 'vendor' -e '/test/e2e$$' $(TEST_GO_FILTER_CMD)` $(TESTARGS)
102111

103112
.PHONY: test-vet
104113
test: test-vet
105114
test-vet:
106115
@ echo; echo "### $@:"
107-
go vet `go list ./... | grep -v vendor $(TEST_VET_FILTER_CMD)`
116+
go vet $(GOFLAGS_VENDOR) `go list $(GOFLAGS_VENDOR) ./... | grep -v vendor $(TEST_VET_FILTER_CMD)`
108117

109118
.PHONY: test-fmt
110119
test: test-fmt
@@ -117,8 +126,69 @@ test-fmt:
117126
false; \
118127
fi
119128

129+
# This test only runs when dep >= 0.5 is installed, which is the case for the CI setup.
130+
# When using 'go mod', we allow the test to be skipped in the Prow CI under some special
131+
# circumstances, because it depends on accessing all remote repos and thus
132+
# running it all the time would defeat the purpose of vendoring:
133+
# - not handling a PR or
134+
# - the fabricated merge commit leaves go.mod, go.sum and vendor dir unchanged
135+
# - release-tools also didn't change (changing rules or Go version might lead to
136+
# a different result and thus must be tested)
137+
# - import statements not changed (because if they change, go.mod might have to be updated)
138+
#
139+
# "git diff" is intelligent enough to annotate changes inside the "import" block in
140+
# the start of the diff hunk:
141+
#
142+
# diff --git a/rpc/common.go b/rpc/common.go
143+
# index bb4a5c4..5fa4271 100644
144+
# --- a/rpc/common.go
145+
# +++ b/rpc/common.go
146+
# @@ -21,7 +21,6 @@ import (
147+
# "fmt"
148+
# "time"
149+
#
150+
# - "google.golang.org/grpc"
151+
# "google.golang.org/grpc/codes"
152+
# "google.golang.org/grpc/status"
153+
#
154+
# We rely on that to find such changes.
155+
#
156+
# Vendoring is optional when using go.mod.
157+
.PHONY: test-vendor
158+
test: test-vendor
159+
test-vendor:
160+
@ echo; echo "### $@:"
161+
@ ./release-tools/verify-vendor.sh
162+
120163
.PHONY: test-subtree
121164
test: test-subtree
122165
test-subtree:
123166
@ echo; echo "### $@:"
124167
./release-tools/verify-subtree.sh release-tools
168+
169+
# Components can extend the set of directories which must pass shellcheck.
170+
# The default is to check only the release-tools directory itself.
171+
TEST_SHELLCHECK_DIRS=release-tools
172+
.PHONY: test-shellcheck
173+
test: test-shellcheck
174+
test-shellcheck:
175+
@ echo; echo "### $@:"
176+
@ ret=0; \
177+
if ! command -v docker; then \
178+
echo "skipped, no Docker"; \
179+
exit 0; \
180+
fi; \
181+
for dir in $(abspath $(TEST_SHELLCHECK_DIRS)); do \
182+
echo; \
183+
echo "$$dir:"; \
184+
./release-tools/verify-shellcheck.sh "$$dir" || ret=1; \
185+
done; \
186+
exit $$ret
187+
188+
# Targets in the makefile can depend on check-go-version-<path to go binary>
189+
# to trigger a warning if the x.y version of that binary does not match
190+
# what the project uses. Make ensures that this is only checked once per
191+
# invocation.
192+
.PHONY: check-go-version-%
193+
check-go-version-%:
194+
./release-tools/verify-go-version.sh "$*"

0 commit comments

Comments
 (0)