Skip to content

Commit a17f536

Browse files
authored
Merge pull request kubernetes-csi#210 from sunnylovestiramisu/sidecar
Add wrapper script for sidecar release
2 parents f8c8cc4 + 011033d commit a17f536

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

SIDECAR_RELEASE_PROCESS.md

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
4646
## Release Process
4747
1. Identify all issues and ongoing PRs that should go into the release, and
4848
drive them to resolution.
49+
1. Update dependencies for sidecars via
50+
[go-modules-update.sh](https://github.com/kubernetes-csi/csi-driver-host-path/blob/HEAD/release-tools/go-modules-update.sh),
51+
and get PRs approved and merged.
4952
1. Check that all [canary CI
5053
jobs](https://testgrid.k8s.io/sig-storage-csi-ci) are passing,
5154
and that test coverage is adequate for the changes that are going into the release.

go-modules-update.sh

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/bin/sh
2+
3+
# Copyright 2023 The Kubernetes 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+
18+
# Usage: go-modules-update.sh
19+
#
20+
# Batch update dependencies for sidecars.
21+
#
22+
# Required environment variables
23+
# CSI_RELEASE_TOKEN: Github token needed for generating release notes
24+
# GITHUB_USER: Github username to create PRs with
25+
#
26+
# Instructions:
27+
# 1. Login with "gh auth login"
28+
# 2. Copy this script to the kubernetes-csi directory (one directory above the
29+
# repos)
30+
# 3. Update the repos and master branch so locally it has the latest upstream
31+
# change
32+
# 4. Set environment variables
33+
# 5. Run script from the kubernetes-csi directory
34+
#
35+
# Caveats:
36+
# - This script doesn't handle interface incompatibility of updates.
37+
# You need to resolve interface incompatibility case by case. The
38+
# most frequent case is to update the interface(new parameters,
39+
# name change of the method, etc.)in the sidecar repo and make sure
40+
# the build and test pass.
41+
42+
43+
set -e
44+
set -x
45+
46+
MAX_RETRY=10
47+
48+
# Get the options
49+
while getopts ":u:v:" option; do
50+
case $option in
51+
u) # Set username
52+
username=$OPTARG;;
53+
v) # Set version
54+
v=$OPTARG;;
55+
\?) # Invalid option
56+
echo "Error: Invalid option: $OPTARG"
57+
exit;;
58+
esac
59+
done
60+
61+
# Only need to do this once
62+
gh auth login
63+
64+
while read -r repo branches; do
65+
if [ "$repo" != "#" ]; then
66+
(
67+
cd "$repo"
68+
git fetch origin
69+
for i in $branches; do
70+
if [ "$(git rev-parse --verify "module-update-$i" 2>/dev/null)" ]; then
71+
git checkout master && git branch -d "module-update-$i"
72+
fi
73+
git checkout -B "module-update-$i" "origin/$i"
74+
rm -rf .git/MERGE*
75+
if ! git subtree pull --squash --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master; then
76+
# Sometimes "--squash" leads to merge conflicts. Because we know that "release-tools"
77+
# is an unmodified copy of csi-release-tools, we can automatically resolve that
78+
# by replacing it completely.
79+
if [ -e .git/MERGE_MSG ] && [ -e .git/FETCH_HEAD ] && grep -q "^# Conflict" .git/MERGE_MSG; then
80+
rm -rf release-tools
81+
mkdir release-tools
82+
git archive FETCH_HEAD | tar -C release-tools -xf -
83+
git add release-tools
84+
git commit --file=.git/MERGE_MSG
85+
else
86+
exit 1
87+
fi
88+
fi
89+
RETRY=0
90+
while ! ./release-tools/go-get-kubernetes.sh -p "$v" && RETRY < $MAX_RETRY
91+
do
92+
RETRY=$((RETRY+1))
93+
go mod tidy && go mod vendor && go mod tidy
94+
done
95+
go mod tidy && go mod vendor && go mod tidy
96+
git add --all
97+
git commit -m "Update dependency go modules for k8s v$v"
98+
git remote set-url origin "https://github.com/$username/$repo.git"
99+
make test
100+
git push origin "module-update-$i" --force
101+
# Create PR
102+
prbody=$(cat <<EOF
103+
Ran kubernetes-csi/csi-release-tools go-get-kubernetes.sh -p ${v}.
104+
105+
106+
\`\`\`release-note
107+
Update kubernetes dependencies to v${v}
108+
\`\`\`
109+
EOF
110+
)
111+
gh pr create --title="Update dependency go modules for k8s v$v" --body "$prbody" --head "$username:module-update-master" --base "master" --repo="kubernetes-csi/$repo"
112+
done
113+
)
114+
fi
115+
done <<EOF
116+
csi-driver-host-path master
117+
csi-driver-iscsi master
118+
csi-driver-nfs master
119+
csi-lib-utils master
120+
csi-proxy master
121+
csi-test master
122+
external-attacher master
123+
external-health-monitor master
124+
external-provisioner master
125+
external-resizer master
126+
external-snapshotter master
127+
livenessprobe master
128+
node-driver-registrar master
129+
EOF

0 commit comments

Comments
 (0)