From c2cae10eeb779b714c7001a94fd1e6a35867c9ac Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Sat, 16 Dec 2023 02:53:45 +0000 Subject: [PATCH] Squashed 'release-tools/' changes from f8c8cc4c7..b54c1ba49 b54c1ba49 Merge pull request #246 from xing-yang/go_1.21 5436c81e9 Change go version to 1.21.5 267b40e97 Merge pull request #244 from carlory/sig-storage b42e5a2de nominate self (carlory) as kubernetes-csi reviewer a17f536fc Merge pull request #210 from sunnylovestiramisu/sidecar 011033de2 Use set -x instead of die 5deaf667c Add wrapper script for sidecar release git-subtree-dir: release-tools git-subtree-split: b54c1ba49469d4d5d1b5d75285e8868ffe3d328f --- KUBERNETES_CSI_OWNERS_ALIASES | 1 + SIDECAR_RELEASE_PROCESS.md | 3 + go-modules-update.sh | 129 ++++++++++++++++++++++++++++++++++ prow.sh | 2 +- 4 files changed, 134 insertions(+), 1 deletion(-) create mode 100755 go-modules-update.sh diff --git a/KUBERNETES_CSI_OWNERS_ALIASES b/KUBERNETES_CSI_OWNERS_ALIASES index 04a07bfb2b..6e46cf2901 100644 --- a/KUBERNETES_CSI_OWNERS_ALIASES +++ b/KUBERNETES_CSI_OWNERS_ALIASES @@ -18,6 +18,7 @@ aliases: # when they are temporarily unable to review PRs. kubernetes-csi-reviewers: - andyzhangx + - carlory - chrishenzie - ggriffiths - gnufied diff --git a/SIDECAR_RELEASE_PROCESS.md b/SIDECAR_RELEASE_PROCESS.md index 338a62292d..4f5d033c23 100644 --- a/SIDECAR_RELEASE_PROCESS.md +++ b/SIDECAR_RELEASE_PROCESS.md @@ -46,6 +46,9 @@ naming convention `-on-`. ## Release Process 1. Identify all issues and ongoing PRs that should go into the release, and drive them to resolution. +1. Update dependencies for sidecars via + [go-modules-update.sh](https://github.com/kubernetes-csi/csi-driver-host-path/blob/HEAD/release-tools/go-modules-update.sh), + and get PRs approved and merged. 1. Check that all [canary CI jobs](https://testgrid.k8s.io/sig-storage-csi-ci) are passing, and that test coverage is adequate for the changes that are going into the release. diff --git a/go-modules-update.sh b/go-modules-update.sh new file mode 100755 index 0000000000..bd605e9701 --- /dev/null +++ b/go-modules-update.sh @@ -0,0 +1,129 @@ +#!/bin/sh + +# 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: go-modules-update.sh +# +# Batch update dependencies for sidecars. +# +# Required environment variables +# CSI_RELEASE_TOKEN: Github token needed for generating release notes +# GITHUB_USER: Github username to create PRs with +# +# Instructions: +# 1. Login with "gh auth login" +# 2. Copy this script to the kubernetes-csi directory (one directory above the +# repos) +# 3. Update the repos and master branch so locally it has the latest upstream +# change +# 4. Set environment variables +# 5. Run script from the kubernetes-csi directory +# +# Caveats: +# - This script doesn't handle interface incompatibility of updates. +# You need to resolve interface incompatibility case by case. The +# most frequent case is to update the interface(new parameters, +# name change of the method, etc.)in the sidecar repo and make sure +# the build and test pass. + + +set -e +set -x + +MAX_RETRY=10 + +# Get the options +while getopts ":u:v:" option; do + case $option in + u) # Set username + username=$OPTARG;; + v) # Set version + v=$OPTARG;; + \?) # Invalid option + echo "Error: Invalid option: $OPTARG" + exit;; + esac +done + +# Only need to do this once +gh auth login + +while read -r repo branches; do + if [ "$repo" != "#" ]; then + ( + cd "$repo" + git fetch origin + for i in $branches; do + if [ "$(git rev-parse --verify "module-update-$i" 2>/dev/null)" ]; then + git checkout master && git branch -d "module-update-$i" + fi + git checkout -B "module-update-$i" "origin/$i" + rm -rf .git/MERGE* + if ! git subtree pull --squash --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master; then + # Sometimes "--squash" leads to merge conflicts. Because we know that "release-tools" + # is an unmodified copy of csi-release-tools, we can automatically resolve that + # by replacing it completely. + if [ -e .git/MERGE_MSG ] && [ -e .git/FETCH_HEAD ] && grep -q "^# Conflict" .git/MERGE_MSG; then + rm -rf release-tools + mkdir release-tools + git archive FETCH_HEAD | tar -C release-tools -xf - + git add release-tools + git commit --file=.git/MERGE_MSG + else + exit 1 + fi + fi + RETRY=0 + while ! ./release-tools/go-get-kubernetes.sh -p "$v" && RETRY < $MAX_RETRY + do + RETRY=$((RETRY+1)) + go mod tidy && go mod vendor && go mod tidy + done + go mod tidy && go mod vendor && go mod tidy + git add --all + git commit -m "Update dependency go modules for k8s v$v" + git remote set-url origin "https://github.com/$username/$repo.git" + make test + git push origin "module-update-$i" --force + # Create PR +prbody=$(cat <