Skip to content

Commit 02293b4

Browse files
committed
Squashed 'release-tools/' changes from e322ce5e5..670bb0ef1
670bb0ef1 Merge pull request kubernetes-csi#229 from marosset/fix-codespell-errors 35d5e783c Merge pull request kubernetes-csi#219 from yashsingh74/update-registry 63473cc96 Merge pull request kubernetes-csi#231 from coulof/bump-go-version-1.20.5 29a5c76c7 Merge pull request kubernetes-csi#228 from mowangdk/chore/adopt_kubernetes_recommand_labels 8dd28211b Update cloudbuild image with go 1.20.5 1df23dba6 Merge pull request kubernetes-csi#230 from msau42/prow 1f92b7e7c Add ginkgo timeout to e2e tests to help catch any stuck tests 2b8b80ead fixing some codespell errors c10b67804 Merge pull request kubernetes-csi#227 from coulof/check-sidecar-supported-versions 72984ec0a chore: adopt kubernetes recommand label b05553510 Header bd0a10b65 typo c39d73c33 Add comments f6491af0e Script to verify EOL sidecar version 4133d1df0 Merge pull request kubernetes-csi#226 from msau42/cloudbuild 8d519d237 Pin buildkit to v0.10.6 to workaround v0.11 bug with docker manifest 6e04a0301 Merge pull request kubernetes-csi#224 from msau42/cloudbuild 26fdfffdd Update cloudbuild image 6613c3980 Merge pull request kubernetes-csi#223 from sunnylovestiramisu/update 0e7ae993d Update k8s image repo url 77e47cce8 Merge pull request kubernetes-csi#222 from xinydev/fix-dep-version 155854b09 Fix dep version mismatch 8f839056a Merge pull request kubernetes-csi#221 from sunnylovestiramisu/go-update 1d3f94dd5 Update go version to 1.20 to match k/k v1.27 901bcb5a9 Update registry k8s.gcr.io -> registry.k8s.io git-subtree-dir: release-tools git-subtree-split: 670bb0ef135a53be44643cc34440eff22ad3ac8c
1 parent 9252f57 commit 02293b4

File tree

5 files changed

+196
-16
lines changed

5 files changed

+196
-16
lines changed

SIDECAR_RELEASE_PROCESS.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
102102
1. If release was a new major/minor version, create a new `release-<minor>`
103103
branch at that commit.
104104
1. Check [image build status](https://k8s-testgrid.appspot.com/sig-storage-image-build).
105-
1. Promote images from k8s-staging-sig-storage to k8s.gcr.io/sig-storage. From
105+
1. Promote images from k8s-staging-sig-storage to registry.k8s.io/sig-storage. From
106106
the [k8s image
107-
repo](https://github.com/kubernetes/k8s.io/tree/HEAD/k8s.gcr.io/images/k8s-staging-sig-storage),
107+
repo](https://github.com/kubernetes/k8s.io/tree/HEAD/registry.k8s.io/images/k8s-staging-sig-storage),
108108
run `./generate.sh > images.yaml`, and send a PR with the updated images.
109109
Once merged, the image promoter will copy the images from staging to prod.
110110
1. Update [kubernetes-csi/docs](https://github.com/kubernetes-csi/docs) sidecar

build.make

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ DOCKER_BUILDX_CREATE_ARGS ?=
148148
$(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
149149
set -ex; \
150150
export DOCKER_CLI_EXPERIMENTAL=enabled; \
151-
docker buildx create $(DOCKER_BUILDX_CREATE_ARGS) --use --name multiarchimage-buildertest; \
151+
docker buildx create $(DOCKER_BUILDX_CREATE_ARGS) --use --name multiarchimage-buildertest --driver-opt image=moby/buildkit:v0.10.6; \
152152
trap "docker buildx rm multiarchimage-buildertest" EXIT; \
153153
dockerfile_linux=$$(if [ -e ./$(CMDS_DIR)/$*/Dockerfile ]; then echo ./$(CMDS_DIR)/$*/Dockerfile; else echo Dockerfile; fi); \
154154
dockerfile_windows=$$(if [ -e ./$(CMDS_DIR)/$*/Dockerfile.Windows ]; then echo ./$(CMDS_DIR)/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \

cloudbuild.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See https://github.com/kubernetes/test-infra/blob/HEAD/config/jobs/image-pushing/README.md
1414
# for more details on image pushing process in Kubernetes.
1515
#
16-
# To promote release images, see https://github.com/kubernetes/k8s.io/tree/HEAD/k8s.gcr.io/images/k8s-staging-sig-storage.
16+
# To promote release images, see https://github.com/kubernetes/k8s.io/tree/HEAD/registry.k8s.io/images/k8s-staging-sig-storage.
1717

1818
# This must be specified in seconds. If omitted, defaults to 600s (10 mins).
1919
# Building three images in external-snapshotter takes more than an hour.
@@ -26,7 +26,7 @@ steps:
2626
# The image must contain bash and curl. Ideally it should also contain
2727
# the desired version of Go (currently defined in release-tools/prow.sh),
2828
# but that just speeds up the build and is not required.
29-
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20210917-12df099d55'
29+
- name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20230623-56e06d7c18'
3030
entrypoint: ./.cloudbuild.sh
3131
env:
3232
- GIT_TAG=${_GIT_TAG}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Copyright 2023 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import argparse
16+
import datetime
17+
import re
18+
from collections import defaultdict
19+
import subprocess
20+
import shutil
21+
from dateutil.relativedelta import relativedelta
22+
23+
def check_gh_command():
24+
"""
25+
Pretty much everything is processed from `gh`
26+
Check that the `gh` command is in the path before anything else
27+
"""
28+
if not shutil.which('gh'):
29+
print("Error: The `gh` command is not available in the PATH.")
30+
print("Please install the GitHub CLI (https://cli.github.com/) and try again.")
31+
exit(1)
32+
33+
def duration_ago(dt):
34+
"""
35+
Humanize duration outputs
36+
"""
37+
delta = relativedelta(datetime.datetime.now(), dt)
38+
if delta.years > 0:
39+
return f"{delta.years} year{'s' if delta.years > 1 else ''} ago"
40+
elif delta.months > 0:
41+
return f"{delta.months} month{'s' if delta.months > 1 else ''} ago"
42+
elif delta.days > 0:
43+
return f"{delta.days} day{'s' if delta.days > 1 else ''} ago"
44+
elif delta.hours > 0:
45+
return f"{delta.hours} hour{'s' if delta.hours > 1 else ''} ago"
46+
elif delta.minutes > 0:
47+
return f"{delta.minutes} minute{'s' if delta.minutes > 1 else ''} ago"
48+
else:
49+
return "just now"
50+
51+
def parse_version(version):
52+
"""
53+
Parse version assuming it is in the form of v1.2.3
54+
"""
55+
pattern = r"v(\d+)\.(\d+)\.(\d+)"
56+
match = re.match(pattern, version)
57+
if match:
58+
major, minor, patch = map(int, match.groups())
59+
return (major, minor, patch)
60+
61+
def end_of_life_grouped_versions(versions):
62+
"""
63+
Calculate the end of life date for a minor release version according to : https://kubernetes-csi.github.io/docs/project-policies.html#support
64+
65+
The input is an array of tuples of:
66+
* grouped versions (e.g. 1.0, 1.1)
67+
* array of that contains all versions and their release date (e.g. 1.0.0, 01-01-2013)
68+
69+
versions structure example :
70+
[((3, 5), [('v3.5.0', datetime.datetime(2023, 4, 27, 22, 28, 6))]),
71+
((3, 4),
72+
[('v3.4.1', datetime.datetime(2023, 4, 5, 17, 41, 15)),
73+
('v3.4.0', datetime.datetime(2022, 12, 27, 23, 43, 41))])]
74+
"""
75+
supported_versions = []
76+
# Prepare dates for later calculation
77+
now = datetime.datetime.now()
78+
one_year = datetime.timedelta(days=365)
79+
three_months = datetime.timedelta(days=90)
80+
81+
# get the newer versions on top
82+
sorted_versions_list = sorted(versions.items(), key=lambda x: x[0], reverse=True)
83+
84+
# the latest version is always supported no matter the release date
85+
latest = sorted_versions_list.pop(0)
86+
supported_versions.append(latest[1][-1])
87+
88+
for v in sorted_versions_list:
89+
first_release = v[1][-1]
90+
last_release = v[1][0]
91+
# if the release is less than a year old we support the latest patch version
92+
if now - first_release[1] < one_year:
93+
supported_versions.append(last_release)
94+
# if the main release is older than a year and has a recent path, this is supported
95+
elif now - last_release[1] < three_months:
96+
supported_versions.append(last_release)
97+
return supported_versions
98+
99+
def get_release_docker_image(repo, version):
100+
"""
101+
Extract docker image name from the release page documentation
102+
"""
103+
output = subprocess.check_output(['gh', 'release', '-R', repo, 'view', version], text=True)
104+
#Extract matching image name excluding `
105+
match = re.search(r"docker pull ([\.\/\-\:\w\d]*)", output)
106+
docker_image = match.group(1) if match else ''
107+
return((version, docker_image))
108+
109+
def get_versions_from_releases(repo):
110+
"""
111+
Using `gh` cli get the github releases page details then
112+
create a list of grouped version on major.minor
113+
and for each give all major.minor.patch with release dates
114+
"""
115+
# Run the `gh release` command to get the release list
116+
output = subprocess.check_output(['gh', 'release', '-R', repo, 'list'], text=True)
117+
# Parse the output and group by major and minor version numbers
118+
versions = defaultdict(lambda: [])
119+
for line in output.strip().split('\n'):
120+
parts = line.split('\t')
121+
# pprint.pprint(parts)
122+
version = parts[0]
123+
parsed_version = parse_version(version)
124+
if parsed_version is None:
125+
continue
126+
major, minor, patch = parsed_version
127+
128+
published = datetime.datetime.strptime(parts[3], '%Y-%m-%dT%H:%M:%SZ')
129+
versions[(major, minor)].append((version, published))
130+
return(versions)
131+
132+
133+
def main():
134+
manual = """
135+
This script lists the supported versions Github releases according to https://kubernetes-csi.github.io/docs/project-policies.html#support
136+
It has been designed to help to update the tables from : https://kubernetes-csi.github.io/docs/sidecar-containers.html\n\n
137+
It can take multiple repos as argument, for all CSI sidecars details you can run:
138+
./get_supported_version_csi-sidecar.py -R kubernetes-csi/external-attacher -R kubernetes-csi/external-provisioner -R kubernetes-csi/external-resizer -R kubernetes-csi/external-snapshotter -R kubernetes-csi/livenessprobe -R kubernetes-csi/node-driver-registrar -R kubernetes-csi/external-health-monitor\n
139+
With the output you can then update the documentation manually.
140+
"""
141+
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=manual)
142+
parser.add_argument('--repo', '-R', required=True, action='append', dest='repos', help='The name of the repository in the format owner/repo.')
143+
parser.add_argument('--display', '-d', action='store_true', help='(default) Display EOL versions with their dates', default=True)
144+
parser.add_argument('--doc', '-D', action='store_true', help='Helper to https://kubernetes-csi.github.io/docs/ that prints Docker image for each EOL version')
145+
146+
args = parser.parse_args()
147+
148+
# Verify pre-reqs
149+
check_gh_command()
150+
151+
# Process all repos
152+
for repo in args.repos:
153+
versions = get_versions_from_releases(repo)
154+
eol_versions = end_of_life_grouped_versions(versions)
155+
156+
if args.display:
157+
print(f"Supported versions with release date and age of `{repo}`:\n")
158+
for version in eol_versions:
159+
print(f"{version[0]}\t{version[1].strftime('%Y-%m-%d')}\t{duration_ago(version[1])}")
160+
161+
# TODO : generate proper doc output for the tables of: https://kubernetes-csi.github.io/docs/sidecar-containers.html
162+
if args.doc:
163+
print("\nSupported Versions with docker images for each end of life version:\n")
164+
for version in eol_versions:
165+
_, image = get_release_docker_image(repo, version[0])
166+
print(f"{version[0]}\t{image}")
167+
print()
168+
169+
if __name__ == '__main__':
170+
main()

prow.sh

+21-11
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ configvar CSI_PROW_BUILD_PLATFORMS "linux amd64 amd64; linux ppc64le ppc64le -pp
8686
# which is disabled with GOFLAGS=-mod=vendor).
8787
configvar GOFLAGS_VENDOR "$( [ -d vendor ] && echo '-mod=vendor' )" "Go flags for using the vendor directory"
8888

89-
configvar CSI_PROW_GO_VERSION_BUILD "1.19" "Go version for building the component" # depends on component's source code
89+
configvar CSI_PROW_GO_VERSION_BUILD "1.20" "Go version for building the component" # depends on component's source code
9090
configvar CSI_PROW_GO_VERSION_E2E "" "override Go version for building the Kubernetes E2E test suite" # normally doesn't need to be set, see install_e2e
9191
configvar CSI_PROW_GO_VERSION_SANITY "${CSI_PROW_GO_VERSION_BUILD}" "Go version for building the csi-sanity test suite" # depends on CSI_PROW_SANITY settings below
9292
configvar CSI_PROW_GO_VERSION_KIND "${CSI_PROW_GO_VERSION_BUILD}" "Go version for building 'kind'" # depends on CSI_PROW_KIND_VERSION below
@@ -101,7 +101,10 @@ configvar CSI_PROW_GINKGO_VERSION v1.7.0 "Ginkgo"
101101

102102
# Ginkgo runs the E2E test in parallel. The default is based on the number
103103
# of CPUs, but typically this can be set to something higher in the job.
104-
configvar CSI_PROW_GINKO_PARALLEL "-p" "Ginko parallelism parameter(s)"
104+
configvar CSI_PROW_GINKGO_PARALLEL "-p" "Ginkgo parallelism parameter(s)"
105+
106+
# Timeout value for the overall ginkgo test suite.
107+
configvar CSI_PROW_GINKGO_TIMEOUT "1h" "Ginkgo timeout"
105108

106109
# Enables building the code in the repository. On by default, can be
107110
# disabled in jobs which only use pre-built components.
@@ -245,7 +248,7 @@ configvar CSI_PROW_SANITY_CONTAINER "hostpath" "Kubernetes container with CSI dr
245248

246249
# The version of dep to use for 'make test-vendor'. Ignored if the project doesn't
247250
# use dep. Only binary releases of dep are supported (https://github.com/golang/dep/releases).
248-
configvar CSI_PROW_DEP_VERSION v0.5.1 "golang dep version to be used for vendor checking"
251+
configvar CSI_PROW_DEP_VERSION v0.5.4 "golang dep version to be used for vendor checking"
249252

250253
# Each job can run one or more of the following tests, identified by
251254
# a single word:
@@ -469,7 +472,7 @@ install_dep () {
469472
if dep version 2>/dev/null | grep -q "version:.*${CSI_PROW_DEP_VERSION}$"; then
470473
return
471474
fi
472-
run curl --fail --location -o "${CSI_PROW_WORK}/bin/dep" "https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64" &&
475+
run curl --fail --location -o "${CSI_PROW_WORK}/bin/dep" "https://github.com/golang/dep/releases/download/${CSI_PROW_DEP_VERSION}/dep-linux-amd64" &&
473476
chmod u+x "${CSI_PROW_WORK}/bin/dep"
474477
}
475478

@@ -872,10 +875,17 @@ install_snapshot_controller() {
872875
cnt=0
873876
expected_running_pods=$(kubectl apply --dry-run=client -o "jsonpath={.spec.replicas}" -f "$SNAPSHOT_CONTROLLER_YAML")
874877
expected_namespace=$(kubectl apply --dry-run=client -o "jsonpath={.metadata.namespace}" -f "$SNAPSHOT_CONTROLLER_YAML")
875-
while [ "$(kubectl get pods -n "$expected_namespace" -l app=snapshot-controller | grep 'Running' -c)" -lt "$expected_running_pods" ]; do
878+
expect_key='app\.kubernetes\.io/name'
879+
expected_label=$(kubectl apply --dry-run=client -o "jsonpath={.spec.template.metadata.labels['$expect_key']}" -f "$SNAPSHOT_CONTROLLER_YAML")
880+
if [ -z "${expected_label}" ]; then
881+
expect_key='app'
882+
expected_label=$(kubectl apply --dry-run=client -o "jsonpath={.spec.template.metadata.labels['$expect_key']}" -f "$SNAPSHOT_CONTROLLER_YAML")
883+
fi
884+
expect_key=${expect_key//\\/}
885+
while [ "$(kubectl get pods -n "$expected_namespace" -l "$expect_key"="$expected_label" | grep 'Running' -c)" -lt "$expected_running_pods" ]; do
876886
if [ $cnt -gt 30 ]; then
877887
echo "snapshot-controller pod status:"
878-
kubectl describe pods -n "$expected_namespace" -l app=snapshot-controller
888+
kubectl describe pods -n "$expected_namespace" -l "$expect_key"="$expected_label"
879889
echo >&2 "ERROR: snapshot controller not ready after over 5 min"
880890
exit 1
881891
fi
@@ -1018,10 +1028,10 @@ run_e2e () (
10181028
10191029
if [ "${name}" == "local" ]; then
10201030
cd "${GOPATH}/src/${CSI_PROW_SIDECAR_E2E_IMPORT_PATH}" &&
1021-
run_with_loggers env KUBECONFIG="$KUBECONFIG" KUBE_TEST_REPO_LIST="$(if [ -e "${CSI_PROW_WORK}/e2e-repo-list" ]; then echo "${CSI_PROW_WORK}/e2e-repo-list"; fi)" ginkgo -v "$@" "${CSI_PROW_WORK}/e2e-local.test" -- -report-dir "${ARTIFACTS}" -report-prefix local
1031+
run_with_loggers env KUBECONFIG="$KUBECONFIG" KUBE_TEST_REPO_LIST="$(if [ -e "${CSI_PROW_WORK}/e2e-repo-list" ]; then echo "${CSI_PROW_WORK}/e2e-repo-list"; fi)" ginkgo --timeout="${CSI_PROW_GINKGO_TIMEOUT}" -v "$@" "${CSI_PROW_WORK}/e2e-local.test" -- -report-dir "${ARTIFACTS}" -report-prefix local
10221032
else
10231033
cd "${GOPATH}/src/${CSI_PROW_E2E_IMPORT_PATH}" &&
1024-
run_with_loggers env KUBECONFIG="$KUBECONFIG" KUBE_TEST_REPO_LIST="$(if [ -e "${CSI_PROW_WORK}/e2e-repo-list" ]; then echo "${CSI_PROW_WORK}/e2e-repo-list"; fi)" ginkgo -v "$@" "${CSI_PROW_WORK}/e2e.test" -- -report-dir "${ARTIFACTS}" -storage.testdriver="${CSI_PROW_WORK}/test-driver.yaml"
1034+
run_with_loggers env KUBECONFIG="$KUBECONFIG" KUBE_TEST_REPO_LIST="$(if [ -e "${CSI_PROW_WORK}/e2e-repo-list" ]; then echo "${CSI_PROW_WORK}/e2e-repo-list"; fi)" ginkgo --timeout="${CSI_PROW_GINKGO_TIMEOUT}" -v "$@" "${CSI_PROW_WORK}/e2e.test" -- -report-dir "${ARTIFACTS}" -storage.testdriver="${CSI_PROW_WORK}/test-driver.yaml"
10251035
fi
10261036
)
10271037
@@ -1310,7 +1320,7 @@ main () {
13101320
if tests_enabled "parallel"; then
13111321
# Ignore: Double quote to prevent globbing and word splitting.
13121322
# shellcheck disable=SC2086
1313-
if ! run_e2e parallel ${CSI_PROW_GINKO_PARALLEL} \
1323+
if ! run_e2e parallel ${CSI_PROW_GINKGO_PARALLEL} \
13141324
-focus="$focus" \
13151325
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_ALPHA}" "${CSI_PROW_E2E_SKIP}")"; then
13161326
warn "E2E parallel failed"
@@ -1320,7 +1330,7 @@ main () {
13201330
# Run tests that are feature tagged, but non-alpha
13211331
# Ignore: Double quote to prevent globbing and word splitting.
13221332
# shellcheck disable=SC2086
1323-
if ! run_e2e parallel-features ${CSI_PROW_GINKO_PARALLEL} \
1333+
if ! run_e2e parallel-features ${CSI_PROW_GINKGO_PARALLEL} \
13241334
-focus="$focus.*($(regex_join "${CSI_PROW_E2E_FOCUS}"))" \
13251335
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}")"; then
13261336
warn "E2E parallel features failed"
@@ -1368,7 +1378,7 @@ main () {
13681378
if tests_enabled "parallel-alpha"; then
13691379
# Ignore: Double quote to prevent globbing and word splitting.
13701380
# shellcheck disable=SC2086
1371-
if ! run_e2e parallel-alpha ${CSI_PROW_GINKO_PARALLEL} \
1381+
if ! run_e2e parallel-alpha ${CSI_PROW_GINKGO_PARALLEL} \
13721382
-focus="$focus.*($(regex_join "${CSI_PROW_E2E_ALPHA}"))" \
13731383
-skip="$(regex_join "${CSI_PROW_E2E_SERIAL}" "${CSI_PROW_E2E_SKIP}")"; then
13741384
warn "E2E parallel alpha failed"

0 commit comments

Comments
 (0)