forked from kubernetes-csi/csi-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'release-tools/' changes from 4133d1d..227577e
227577e Merge pull request kubernetes-csi#258 from gnufied/enable-race-detection e1ceee2 Always enable race detection while running tests 988496a Merge pull request kubernetes-csi#257 from jakobmoellerdev/csi-prow-sidecar-e2e-path 028f8c6 chore: bump to Go 1.22.5 69bd71e chore: add CSI_PROW_SIDECAR_E2E_PATH f40f0cc Merge pull request kubernetes-csi#256 from solumath/master cfa9210 Instruction update 379a1bb Merge pull request kubernetes-csi#255 from humblec/sidecar-md a5667bb fix typo in sidecar release process 4967685 Merge pull request kubernetes-csi#254 from bells17/add-github-actions d9bd160 Update skip list in codespell GitHub Action adb3af9 Merge pull request kubernetes-csi#252 from bells17/update-go-version f5aebfc Add GitHub Actions workflows b82ee38 Merge pull request kubernetes-csi#253 from bells17/fix-typo c317456 Fix typo 0a78505 Bump to Go 1.22.3 edd89ad Merge pull request kubernetes-csi#251 from jsafrane/add-logcheck 043fd09 Add test-logcheck target d7535ae Merge pull request kubernetes-csi#250 from jsafrane/go-1.22 b52e7ad Update go to 1.22.2 14fdb6f Merge pull request kubernetes-csi#247 from msau42/prow dc4d0ae Merge pull request kubernetes-csi#249 from jsafrane/use-go-version e681b17 Use .go-version to get Kubernetes go version 9b4352e Update release playbook c7bb972 Fix release notes script to use fixed tags 463a0e9 Add script to update specific go modules b54c1ba Merge pull request kubernetes-csi#246 from xing-yang/go_1.21 5436c81 Change go version to 1.21.5 267b40e Merge pull request kubernetes-csi#244 from carlory/sig-storage b42e5a2 nominate self (carlory) as kubernetes-csi reviewer a17f536 Merge pull request kubernetes-csi#210 from sunnylovestiramisu/sidecar 011033d Use set -x instead of die 5deaf66 Add wrapper script for sidecar release f8c8cc4 Merge pull request kubernetes-csi#237 from msau42/prow b36b5bf Merge pull request kubernetes-csi#240 from dannawang0221/upgrade-go-version adfddcc Merge pull request kubernetes-csi#243 from pohly/git-subtree-pull-fix c465088 pull-test.sh: avoid "git subtree pull" error 7b175a1 Update csi-test version to v5.2.0 987c90c Update go version to 1.21 to match k/k 2c625d4 Add script to generate patch release notes f9d5b9c Merge pull request kubernetes-csi#236 from mowangdk/feature/bump_csi-driver-host-path_version b01fd53 Bump csi-driver-host-path version up to v1.12.0 984feec Merge pull request kubernetes-csi#234 from siddhikhapare/csi-tools 1f7e605 fixed broken links of testgrid dashboard de2fba8 Merge pull request kubernetes-csi#233 from andyzhangx/andyzhangx-patch-1 cee895e remove windows 20H2 build since it's EOL long time ago 670bb0e Merge pull request kubernetes-csi#229 from marosset/fix-codespell-errors 35d5e78 Merge pull request kubernetes-csi#219 from yashsingh74/update-registry 63473cc Merge pull request kubernetes-csi#231 from coulof/bump-go-version-1.20.5 29a5c76 Merge pull request kubernetes-csi#228 from mowangdk/chore/adopt_kubernetes_recommand_labels 8dd2821 Update cloudbuild image with go 1.20.5 1df23db Merge pull request kubernetes-csi#230 from msau42/prow 1f92b7e Add ginkgo timeout to e2e tests to help catch any stuck tests 2b8b80e fixing some codespell errors c10b678 Merge pull request kubernetes-csi#227 from coulof/check-sidecar-supported-versions 72984ec chore: adopt kubernetes recommand label b055535 Header bd0a10b typo c39d73c Add comments f6491af Script to verify EOL sidecar version 901bcb5 Update registry k8s.gcr.io -> registry.k8s.io git-subtree-dir: release-tools git-subtree-split: 227577e00e93c3db4e732df1a71e37676fa33bfd Signed-off-by: Terry Howe <terrylhowe@gmail.com>
- Loading branch information
Showing
11 changed files
with
669 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Run Trivy scanner for Go version vulnerabilities | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
jobs: | ||
trivy: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get Go version | ||
id: go-version | ||
run: | | ||
GO_VERSION=$(cat prow.sh | grep "configvar CSI_PROW_GO_VERSION_BUILD" | awk '{print $3}' | sed 's/"//g') | ||
echo "version=$GO_VERSION" >> $GITHUB_OUTPUT | ||
- name: Run Trivy scanner for Go version vulnerabilities | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: 'golang:${{ steps.go-version.outputs.version }}' | ||
format: 'table' | ||
exit-code: '1' | ||
ignore-unfixed: true | ||
vuln-type: 'library' | ||
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
# Copyright 2023 The Kubernetes Authors. | ||
# | ||
# 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. | ||
|
||
import argparse | ||
import datetime | ||
import re | ||
from collections import defaultdict | ||
import subprocess | ||
import shutil | ||
from dateutil.relativedelta import relativedelta | ||
|
||
def check_gh_command(): | ||
""" | ||
Pretty much everything is processed from `gh` | ||
Check that the `gh` command is in the path before anything else | ||
""" | ||
if not shutil.which('gh'): | ||
print("Error: The `gh` command is not available in the PATH.") | ||
print("Please install the GitHub CLI (https://cli.github.com/) and try again.") | ||
exit(1) | ||
|
||
def duration_ago(dt): | ||
""" | ||
Humanize duration outputs | ||
""" | ||
delta = relativedelta(datetime.datetime.now(), dt) | ||
if delta.years > 0: | ||
return f"{delta.years} year{'s' if delta.years > 1 else ''} ago" | ||
elif delta.months > 0: | ||
return f"{delta.months} month{'s' if delta.months > 1 else ''} ago" | ||
elif delta.days > 0: | ||
return f"{delta.days} day{'s' if delta.days > 1 else ''} ago" | ||
elif delta.hours > 0: | ||
return f"{delta.hours} hour{'s' if delta.hours > 1 else ''} ago" | ||
elif delta.minutes > 0: | ||
return f"{delta.minutes} minute{'s' if delta.minutes > 1 else ''} ago" | ||
else: | ||
return "just now" | ||
|
||
def parse_version(version): | ||
""" | ||
Parse version assuming it is in the form of v1.2.3 | ||
""" | ||
pattern = r"v(\d+)\.(\d+)\.(\d+)" | ||
match = re.match(pattern, version) | ||
if match: | ||
major, minor, patch = map(int, match.groups()) | ||
return (major, minor, patch) | ||
|
||
def end_of_life_grouped_versions(versions): | ||
""" | ||
Calculate the end of life date for a minor release version according to : https://kubernetes-csi.github.io/docs/project-policies.html#support | ||
The input is an array of tuples of: | ||
* grouped versions (e.g. 1.0, 1.1) | ||
* array of that contains all versions and their release date (e.g. 1.0.0, 01-01-2013) | ||
versions structure example : | ||
[((3, 5), [('v3.5.0', datetime.datetime(2023, 4, 27, 22, 28, 6))]), | ||
((3, 4), | ||
[('v3.4.1', datetime.datetime(2023, 4, 5, 17, 41, 15)), | ||
('v3.4.0', datetime.datetime(2022, 12, 27, 23, 43, 41))])] | ||
""" | ||
supported_versions = [] | ||
# Prepare dates for later calculation | ||
now = datetime.datetime.now() | ||
one_year = datetime.timedelta(days=365) | ||
three_months = datetime.timedelta(days=90) | ||
|
||
# get the newer versions on top | ||
sorted_versions_list = sorted(versions.items(), key=lambda x: x[0], reverse=True) | ||
|
||
# the latest version is always supported no matter the release date | ||
latest = sorted_versions_list.pop(0) | ||
supported_versions.append(latest[1][-1]) | ||
|
||
for v in sorted_versions_list: | ||
first_release = v[1][-1] | ||
last_release = v[1][0] | ||
# if the release is less than a year old we support the latest patch version | ||
if now - first_release[1] < one_year: | ||
supported_versions.append(last_release) | ||
# if the main release is older than a year and has a recent path, this is supported | ||
elif now - last_release[1] < three_months: | ||
supported_versions.append(last_release) | ||
return supported_versions | ||
|
||
def get_release_docker_image(repo, version): | ||
""" | ||
Extract docker image name from the release page documentation | ||
""" | ||
output = subprocess.check_output(['gh', 'release', '-R', repo, 'view', version], text=True) | ||
#Extract matching image name excluding ` | ||
match = re.search(r"docker pull ([\.\/\-\:\w\d]*)", output) | ||
docker_image = match.group(1) if match else '' | ||
return((version, docker_image)) | ||
|
||
def get_versions_from_releases(repo): | ||
""" | ||
Using `gh` cli get the github releases page details then | ||
create a list of grouped version on major.minor | ||
and for each give all major.minor.patch with release dates | ||
""" | ||
# Run the `gh release` command to get the release list | ||
output = subprocess.check_output(['gh', 'release', '-R', repo, 'list'], text=True) | ||
# Parse the output and group by major and minor version numbers | ||
versions = defaultdict(lambda: []) | ||
for line in output.strip().split('\n'): | ||
parts = line.split('\t') | ||
# pprint.pprint(parts) | ||
version = parts[0] | ||
parsed_version = parse_version(version) | ||
if parsed_version is None: | ||
continue | ||
major, minor, patch = parsed_version | ||
|
||
published = datetime.datetime.strptime(parts[3], '%Y-%m-%dT%H:%M:%SZ') | ||
versions[(major, minor)].append((version, published)) | ||
return(versions) | ||
|
||
|
||
def main(): | ||
manual = """ | ||
This script lists the supported versions Github releases according to https://kubernetes-csi.github.io/docs/project-policies.html#support | ||
It has been designed to help to update the tables from : https://kubernetes-csi.github.io/docs/sidecar-containers.html\n\n | ||
It can take multiple repos as argument, for all CSI sidecars details you can run: | ||
./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 | ||
With the output you can then update the documentation manually. | ||
""" | ||
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=manual) | ||
parser.add_argument('--repo', '-R', required=True, action='append', dest='repos', help='The name of the repository in the format owner/repo.') | ||
parser.add_argument('--display', '-d', action='store_true', help='(default) Display EOL versions with their dates', default=True) | ||
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') | ||
|
||
args = parser.parse_args() | ||
|
||
# Verify pre-reqs | ||
check_gh_command() | ||
|
||
# Process all repos | ||
for repo in args.repos: | ||
versions = get_versions_from_releases(repo) | ||
eol_versions = end_of_life_grouped_versions(versions) | ||
|
||
if args.display: | ||
print(f"Supported versions with release date and age of `{repo}`:\n") | ||
for version in eol_versions: | ||
print(f"{version[0]}\t{version[1].strftime('%Y-%m-%d')}\t{duration_ago(version[1])}") | ||
|
||
# TODO : generate proper doc output for the tables of: https://kubernetes-csi.github.io/docs/sidecar-containers.html | ||
if args.doc: | ||
print("\nSupported Versions with docker images for each end of life version:\n") | ||
for version in eol_versions: | ||
_, image = get_release_docker_image(repo, version[0]) | ||
print(f"{version[0]}\t{image}") | ||
print() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2023 The Kubernetes Authors. | ||
# | ||
# 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. | ||
|
||
|
||
# Usage: generate_patch_release_notes.sh | ||
# | ||
# Generates and creates PRs for kubernetes-csi patch releases. | ||
# | ||
# Required environment variables | ||
# CSI_RELEASE_TOKEN: Github token needed for generating release notes | ||
# GITHUB_USER: Github username to create PRs with | ||
# | ||
# Required tools: | ||
# - gh | ||
# - release-notes (https://github.com/kubernetes/release/blob/master/cmd/release-notes/README.md) | ||
# | ||
# Instructions: | ||
# 1. Install the required tools | ||
# 2. Login with "gh auth login" | ||
# 3. Copy this script to the kubernetes-csi directory (one directory above the repos) | ||
# 4. Update the repos and versions in the $releases array | ||
# 5. Set environment variables | ||
# 6. Run script from the kubernetes-csi directory | ||
# | ||
# Caveats: | ||
# - This script doesn't handle regenerating and updating existing PRs yet. | ||
# It might work if you comment out the PR creation line | ||
|
||
set -e | ||
set -x | ||
|
||
releases=( | ||
# "external-attacher 4.4.1" | ||
# "external-provisioner 3.6.1" | ||
# "external-snapshotter 6.2.3" | ||
) | ||
|
||
function gen_patch_relnotes() { | ||
rm out.md || true | ||
rm -rf /tmp/k8s-repo || true | ||
GITHUB_TOKEN="$CSI_RELEASE_TOKEN" \ | ||
release-notes --start-rev="$3" --end-rev="$2" --branch="$2" \ | ||
--org=kubernetes-csi --repo="$1" \ | ||
--required-author="" --markdown-links --output out.md | ||
} | ||
|
||
for rel in "${releases[@]}"; do | ||
read -r repo version <<< "$rel" | ||
|
||
# Parse minor version | ||
minorPatchPattern="(^[[:digit:]]+\.[[:digit:]]+)\.([[:digit:]]+)" | ||
[[ "$version" =~ $minorPatchPattern ]] | ||
minor="${BASH_REMATCH[1]}" | ||
patch="${BASH_REMATCH[2]}" | ||
|
||
echo "$repo $version $minor $patch" | ||
prevPatch="$((patch-1))" | ||
prevVer="v$minor.$prevPatch" | ||
|
||
pushd "$repo/CHANGELOG" | ||
|
||
git fetch upstream | ||
|
||
# Create branch | ||
branch="changelog-release-$minor" | ||
git checkout master | ||
git branch -D "$branch" || true | ||
git checkout --track "upstream/release-$minor" -b "$branch" | ||
|
||
# Generate release notes | ||
gen_patch_relnotes "$repo" "release-$minor" "$prevVer" | ||
cat > tmp.md <<EOF | ||
# Release notes for v$version | ||
[Documentation](https://kubernetes-csi.github.io) | ||
EOF | ||
|
||
cat out.md >> tmp.md | ||
echo >> tmp.md | ||
rm out.md | ||
|
||
file="CHANGELOG-$minor.md" | ||
cat "$file" >> tmp.md | ||
mv tmp.md "$file" | ||
|
||
git add -u | ||
git commit -m "Add changelog for $version" | ||
git push -f origin "$branch" | ||
|
||
# Create PR | ||
prbody=$(cat <<EOF | ||
\`\`\`release-note | ||
NONE | ||
\`\`\` | ||
EOF | ||
) | ||
gh pr create --title="Changelog for v$version" --body "$prbody" --head "$GITHUB_USER:$branch" --base "release-$minor" --repo="kubernetes-csi/$repo" | ||
|
||
popd | ||
done |
Oops, something went wrong.